PDP-8 different subroutine techniques, but no returns

There are different subroutine techniques including parameters after JMS, multiple return paths, linked lists and software-managed stacks (auto-index). Not sure if all works on the 6100 as well due to different auto-index behaviour.

I think I don’t have any of those. Linked lists don’t have JMS, stacks need manual definitions first. For the rest is no space. On my code I have many JMS, but I haven’t found any returns. Return addresses were written but never called (JMP I). Maybe Intersil has something else. Or the code is constructed in a run as this is on the Zero page.

On my Festo device when importing data (push keys extern, F0 and parameters) there is an output of / + XOn. As the TTY needs ASCII and Xon is not coded in Sixbit, I’ve converted both to octal making 57 and 21 which I found together at 6542, 6543. At code after each value is a JMS 175 subroutine probably for printing. Later is IOF. Elsewhere it’s similar with CR+LF for export. So very plausible. Inside a subroutine, there are loops (due to missing hardware) and further conditional branches and long jumps. So I have to manually skip and change PC or AC.

It’s very hard to keep track of everything due to the overwritten data. Some emulators support extended memory. I could rewrite the code but it’s too much work.

Data is even easier to be detected on a palbart disassembly. Longer data section here

       addr  word
 3482 06540  5024          JMP L00024
 3483 06541  2500  D06541, 2500
 3484 06542  0057  D06542, 0057 -2F Hex ="/" - used on TAD instr
 3485 06543  0021  D06543, 0021 -11 Hex =Xon -TAD
 3486 06544  6200  D06544, 6200 -? 3rd value -TAD
 3487 06545  7767  D06545, 7767 -TAD
 3488 06546  0100  D06546, 0100 - AND instr 
 3489 06547  0177  P06547, P00177 -DCA
 3490 06550  2200  D06550, 2200 -TAD
 3491 06551  6700  D06551, 6700 -TAD
 3492 06552  4452  D06552, 4452 -TAD
 3493 06553  7325          CLA CLL CML RAL IAC

code at 6427:

 3409 06427  6402  L06427, 6402 (Skip If Receive Word Count Overflow IOT
 3410 06430  0346          AND D06546 -100 
 3411 06431  7650          SNA CLA 
 3412 06432  5223          JMP L06423
 3413 06433  2134          ISZ P00134 7776 -2, 2 char? 
 3414 06434  5227          JMP L06427 loop to top
 3415 06435  1123          TAD P00123 7560 4+3 digits?
 3416 06436  0036          AND P00036 3070 
 3417 06437  7650          SNA CLA 
 3418 06440  5245          JMP L06445
 3419 06441  4023          JMS P00023 JMS 24 another subroutine
 3420 06442  3747          DCA I P06547
 3421 06443  1342          TAD D06542 - 57  "/"
 3422 06444  4175          JMS P00175 JMS 175+1 print char?
 3423 06445  1343  L06445, TAD D06543 - Xon
 3424 06446  4175          JMS P00175 print char
 3425 06447  1344          TAD D06544 6200
 3426 06450  6415          6415  Read Status 1
 3427 06451  6002          IOF disable IRQ 
 3428 06452  1345          TAD D06545 7767 -8
 3429 06453  3135          DCA D00135
 3430 06454  6407  L06454, 6407

and a run

[6442] IRQ,DLY,IE=0,1,0 L/AC:0/0000 MQ:0000 IR:3747 DCA I @@47 ;Deposit AC to memory then clear AC, Indexed Current page @@47
[6443] IRQ,DLY,IE=0,1,0 L/AC:0/0000 MQ:0000 IR:1342 TAD @@42   ;Add operand to AC, Current page @@42
[6444] IRQ,DLY,IE=0,1,0 L/AC:0/0057 MQ:0000 IR:4175 JMS 0175   ;Jump to subroutine ZP 0175
[0176] IRQ,DLY,IE=0,0,0 L/AC:0/0057 MQ:0000 IR:2140 ISZ 0140   ;Increment operand and skip if zero, ZP 0140
[0177] IRQ,DLY,IE=0,0,0 L/AC:0/0057 MQ:0000 IR:0000 AND 0000   ;AND operand with AC, ZP 0000 
[0200] IRQ,DLY,IE=0,0,0 L/AC:0/0044 MQ:0000 IR:1014 TAD 0014   ;Add operand to AC, ZP 0014
[0201] IRQ,DLY,IE=0,0,0 L/AC:0/1366 MQ:0000 IR:0211 AND @@11   ;AND operand with AC, Current page @@11
[0202] IRQ,DLY,IE=0,0,0 L/AC:0/1000 MQ:0000 IR:7450 SNA        ;Skip on AC <> 0
[0204] IRQ,DLY,IE=0,0,0 L/AC:0/1000 MQ:0000 IR:7041 CIA        ;2s Complement AC
[0205] IRQ,DLY,IE=0,0,0 L/AC:0/7000 MQ:0000 IR:1130 TAD 0130   ;Add operand to AC, ZP 0130
[0206] IRQ,DLY,IE=0,0,0 L/AC:1/3760 MQ:0000 IR:7640 SZA CLA    ;Skip on AC = 0, Clear AC
[0207] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:5233 JMP @@33   ;Jump Current page @@33
[0233] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:1072 TAD 0072   ;Add operand to AC, ZP 0072
[0234] IRQ,DLY,IE=0,0,0 L/AC:1/1126 MQ:0000 IR:7002 BSW        ;Byte Swap AC
[0235] IRQ,DLY,IE=0,0,0 L/AC:1/2611 MQ:0000 IR:7700 SMA CLA    ;Skip on AC < 0, Clear AC
[0236] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:5431 JMP I 0031 ;Jump Indexed ZP 0031
[1313] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:5366 JMP @@66   ;Jump Current page @@66
[1366] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:6223 CDF 2 CIF 2;KM8-E: Change to Data and Instruction Field 2
[1367] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:7325 STL CLA IAC RAL;Set L, Set AC to 0001, Rotate AC & L left
[1370] IRQ,DLY,IE=0,0,0 L/AC:0/0003 MQ:0000 IR:0132 AND 0132   ;AND operand with AC, ZP 0132
[1371] IRQ,DLY,IE=0,0,0 L/AC:0/0001 MQ:0000 IR:3101 DCA 0101   ;Deposit AC to memory then clear AC, ZP 0101
[1372] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:1133 TAD 0133   ;Add operand to AC, ZP 0133
[1373] IRQ,DLY,IE=0,0,0 L/AC:0/6753 MQ:0000 IR:3102 DCA 0102   ;Deposit AC to memory then clear AC, ZP 0102
[1374] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:5750 JMP I @@50 ;Jump Indexed Current page @@50
[5330] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:1373 TAD @@73   ;Add operand to AC, Current page @@73

same on ROM 5162, 2nd half first. Same data/relative addresses, but different Zero page 
[2442] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:3747 DCA I @@47 ;Deposit AC to memory then clear AC, Indexed Current page @@47
[2443] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:1342 TAD @@42   ;Add operand to AC, Current page @@42
[2444] IRQ,DLY,IE=0,0,0 L/AC:0/0057 MQ:0000 IR:4175 JMS 0175   ;Jump to subroutine ZP 0175
[0176] IRQ,DLY,IE=0,0,0 L/AC:0/0057 MQ:0000 IR:3061 DCA 0061   ;Deposit AC to memory then clear AC, ZP 0061
[0177] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:0000 AND 0000   ;AND operand with AC, ZP 0000 
[0200] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:1263 TAD @@63   ;Add operand to AC, Current page @@63
[0201] IRQ,DLY,IE=0,0,0 L/AC:0/0164 MQ:0000 IR:3011 DCA 0011   ;Deposit AC to memory then clear AC, ZP 0011
[0202] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:7307 CLL CLA IAC RTL;Clear L, Set AC to 0001, Rotate AC & L left twice
[0203] IRQ,DLY,IE=0,0,0 L/AC:0/0004 MQ:0000 IR:3411 DCA I 0011 ;Deposit AC to memory then clear AC, Indexed ZP 0011 [Auto pre-inc]
[0204] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:7303 CLL CLA IAC BSW;Clear L, set AC to 0100
[0205] IRQ,DLY,IE=0,0,0 L/AC:0/0100 MQ:0000 IR:1116 TAD 0116   ;Add operand to AC, ZP 0116
[0206] IRQ,DLY,IE=0,0,0 L/AC:1/0072 MQ:0000 IR:3411 DCA I 0011 ;Deposit AC to memory then clear AC, Indexed ZP 0011 [Auto pre-inc]
[0207] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:1101 TAD 0101   ;Add operand to AC, ZP 0101
[0210] IRQ,DLY,IE=0,0,0 L/AC:1/3104 MQ:0000 IR:7650 SNA CLA    ;Skip on AC <> 0, Clear AC
[0212] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:1266 TAD @@66   ;Add operand to AC, Current page @@66
[0213] IRQ,DLY,IE=0,0,0 L/AC:1/0005 MQ:0000 IR:3411 DCA I 0011 ;Deposit AC to memory then clear AC, Indexed ZP 0011 [Auto pre-inc]
[0214] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:1265 TAD @@65   ;Add operand to AC, Current page @@65
[0215] IRQ,DLY,IE=0,0,0 L/AC:1/0400 MQ:0000 IR:1101 TAD 0101   ;Add operand to AC, ZP 0101
[0216] IRQ,DLY,IE=0,0,0 L/AC:1/3504 MQ:0000 IR:3411 DCA I 0011 ;Deposit AC to memory then clear AC, Indexed ZP 0011 [Auto pre-inc]
[0217] IRQ,DLY,IE=0,0,0 L/AC:1/0000 MQ:0000 IR:7327 STL CLA IAC RTL;Set L, Set AC to 0001, Rotate AC & L left twice
[0220] IRQ,DLY,IE=0,0,0 L/AC:0/0006 MQ:0000 IR:3411 DCA I 0011 ;Deposit AC to memory then clear AC, Indexed ZP 0011 [Auto pre-inc]
[0221] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:1102 TAD 0102   ;Add operand to AC, ZP 0102
[0222] IRQ,DLY,IE=0,0,0 L/AC:0/5423 MQ:0000 IR:3411 DCA I 0011 ;Deposit AC to memory then clear AC, Indexed ZP 0011 [Auto pre-inc]
[0223] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:7330 STL CLA RAR;Set L, Move L into AC bit 0
[0224] IRQ,DLY,IE=0,0,0 L/AC:0/4000 MQ:0000 IR:3411 DCA I 0011 ;Deposit AC to memory then clear AC, Indexed ZP 0011 [Auto pre-inc]
[0225] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:1263 TAD @@63   ;Add operand to AC, Current page @@63
[0226] IRQ,DLY,IE=0,0,0 L/AC:0/0164 MQ:0000 IR:3016 DCA 0016   ;Deposit AC to memory then clear AC, ZP 0016
[0227] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:7307 CLL CLA IAC RTL;Clear L, Set AC to 0001, Rotate AC & L left twice
[0230] IRQ,DLY,IE=0,0,0 L/AC:0/0004 MQ:0000 IR:6436 SSBE       ;DP8-EAEB: Skip on Bus Error
[0231] IRQ,DLY,IE=0,0,0 L/AC:0/0004 MQ:0000 IR:6406 SCSD       ;DP8-EAEB: Clear Sync Detect
[0232] IRQ,DLY,IE=0,0,0 L/AC:0/0004 MQ:0000 IR:0235 AND @@35   ;AND operand with AC, Current page @@35
[0233] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:6437 SRCD       ;DP8-EAEB: Read Character Detected
[0234] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:4017 JMS 0017   ;Jump to subroutine ZP 0017
[0020] IRQ,DLY,IE=0,0,0 L/AC:0/0000 MQ:0000 IR:1107 TAD 0107   ;Add operand to AC, ZP 0107

Remember the CMOS chips for the PDP-8, may have stacks as IO device.

Thanks. The 6120 has 2 stack pointers. But I have a 6100 which should have no stacks.
There is a 6101 PIE chip (I mentioned elsewhere) which has vectors. But I haven’t found that chip.

I found this Intersil bulletin about this subject claiming that there are 6 RAM locations on page zero and 29 ROM locations. There is also a sample code. But I haven’t compare it yet with my code.

So it’s somehow possible with hardware or software, so the code might still be plausible. There were also solutions with external RAM and discrete logic
https://groups.google.com/g/comp.os.cpm/c/EPVpGMkVL2Q

Maybe the disassemblers didn’t handle it properly. None is perfect detecting code/data sections. Usually d8tape should clearly show and separate subroutines.

Some where I read that TTY I/O was revised on the 6101 chip from DEC TTY i/o.
Check bitsavers for the VT78, and DECMATE X

I found the 6101 manuals but haven’t compared them with the regular way. There are mainly additional 6xxx IOTs. I found some few of them in my code like 6033 (TTY keyboard), 6342, 6007, 6314 (especially latter one maybe data in my code).
Multiple instructions probably can be combined into one.
But I haven’t found most important IOTs like 604x (TTY printer).
IOTs can be user defined, though. I have eg 6147.

The bulletin is obviously just an example of a software stack.

This is slightly off-topic but I hope close enough that you’ll excuse me posting it: the PDP9 instruction set is fairly similar to the PDP8 as far as I remember, and a few years back my friend Rainer Thonnes and I recovered a 1970’s compiler for the PDP9 and PDP15 and got it running again on any system that supports C. There’s a windows binary available too at Index of /history.dcs.ed.ac.uk/archive/languages/imp-pdp15 where you can write and run Imp programs (the old style of Imp which is extremely close to Atlas Autocode) and the compiler can produce listings showing the generated PDP9 instructions aligned with the Imp source code. (Which is why I’m mentioning it, so you can see how this compiler handles subroutine calls and recursion). There’s some contemporary documentation on the compiler output there too. The windows port bundles the pdp9 code with an interpreter so that the resulting exe can be run as if it were native code.

1 Like

Looks like good reading. Does the imp compiler self compile on the pdp 9?

As far as I remember (we did this 20 years ago!) … yes. Though I have a vague recollection that there was a small tweak in the source code of the compiler itself for cross-compiling vs native compiling. Can’t remember the details right this second. There are a couple of other programs in there that compiled on the pdp9 (HAL - High-level Assembly Language) which will probably compile (so you can look at the code) but not likely run, due to some data files not being available.

But can’t the software be re-written? Getting around to it, is another story, or copy writes.
Do you have more info on HAL?

Sure, lots of info. Start at Index of /history.dcs.ed.ac.uk/archive/languages/hal

The Interdata version is probably the more definitive one. You’ll find more docs and code at Index of /history.dcs.ed.ac.uk/archive/os/interdata74-basic

G

Wow - thanks for this post @gtoal and all the goodies at the links!

Imp 15 (.i15) for PDP 15. Is imp15 another dialect or the same as imp77?

Probably similar with very few code around (unlike imp80). Same for HAL.

“Unfortunately at the moment, we do not have any HAL code to feed
through it.” (2022 readme)

So one has to study a lot and then can’t do much. For a beginner who is not familiar with PDP9/15 either it would be very, very time consuming. And need of Win 32 bit.

There are Interdata emulators for SIMH, I think 32 and 16 bit. Is interdata 70/74 supported?

I considered to continue studying IMP and EMAS but am currently too busy.
Is there any progress with imp80 (compilers)?