PDP-8 code to c converter

I’ve tested again all perl scripts by Vincent Slyngstad this time with my new 5162 ROM combination. I’ve also tested the disk dir viewers (OS8 and TSS8) with some other disk files like an SBC6120 .img file and others. Sixbit.pl needs as input .eep (There’s a converter on the pdp8emu. That format is a 16 bit hex format with 2 bytes swapped. The .sv format (bn2sv) is I think the weird DecMateII format. The weirdest one is a tss directory as it supports several users. That also has another Sixbit format A=41 instead of 01.

https://so-much-stuff.com/pdp8/tools/tools.php

Then I found the bin2c script. I’ve first tested it with the CHEKMO.BN chess file. After conversion and compilation it runs under linux. It’s not an emulation but real ELF code.

Very interesting. There are obviously different PDP8 models supported (up to PDP8-I, but maybe not the 6100) and the Extended Arithmetic Unit. And as a side effect it shows data and code segments due to a 2 pass scan.

I have another CHESS.BIN file (PDP8) that does not work. Not sure what format that is.
My Festo ROM would convert and compile and run without errors, but there’s no output to screen as my device doesn’t have any.

Some parts from CHEKMO (voids for every single address)

void S00000() { lac &= (010000|core[000000]); }
void D00001() { npc = (ib<<12)+core[2]; inh = 0; }
void P00002() { npc = 000000; inh = 0; }
void D00003() { lac &= (010000|core[000062]); }

void P00200() { lac += core[000377]; }
void I00201() { core[000026] = lac & 07777; lac &= 010000; code[000026] = &emul8; }
void I00202() { core[(ib<<12)+core[24]] = 00203; npc = (ib<<12)+core[24]+1; code[(ib<<12)+core[24]] = &emul8; inh = 0; }

} else if ((inst&07770) == 06070) { // VC8/I
} else if ((inst&07770) == 06100) { // Memory Parity, Power Low
} else if ((inst&07740) == 06140) { // 6140-6177 LINC, Type 338 display
} else if ((inst&07770) == 06330) { // LAB-8
} else if ((inst&07770) == 06340) { // LAB-8
} else if ((inst&07700) == 06400) { // PT08
} else if ((inst&07760) == 06760) { // 6760-6777 DECTape
} else {
fprintf(stderr, “IOT %05o treated as NOP\r\n”, inst);

} else if ((inst&07) == 05) { // RTF
int l = lac&04000;
gt = !!(lac&02000);
inh = !!(lac&0400);
// Contrary to documentation, RTF ignores IE and enables interrupts.

// Emulate the hard stuff:
// IOT instructions.
// Group 3 OPR instructions (dependent on mode A or B).
// Code modified at runtime.

This is a part from my 5162 ROM converted to Sixbit. More than the 2 characters like on the online emu. It also shows that at page 10 (2000o) there’s obviously a table

0007 130)0777 1417 3010 1417 3011 1417 3013 1410 G?LOXHLOXILOXKLH
0007 140)3411 2013 5337 5020 1417 3010 1410 3011 \IPK+_(PLOXHLHXI
0007 150)1410 5336 7340 3051 7330 3053 1031 3045 LH+^; X);XX+HYX%
0007 160)7305 1375 3010 1410 3054 1054 3055 1410 ;EK=XHLHX,H,X-LH
0007 170)3052 3060 3061 3062 5020 3574 0400 5776 X*X0X1X2(P]<D@/>

0010 000)3446 0400 1246 0400 3036 1200 4612 5000 \&D@J&D@X^J@&J(@
0010 010)3002 1000 3222 5400 3202 1000 3210 6400 XBH@ZR,@ZBH@ZH4@
0010 020)3206 3600 3452 5600 4050 1200 0246 0200 ZF^@\*.@ (J@B&B@
0010 030)1046 5000 2630 1200 5234 1600 1644 3600 H&(@VXJ@*\N@N$^@
0010 040)3412 1600 5204 3000 1002 5200 6446 2600 \JN@*DX@HB*@4&V@
0010 050)4612 2600 3222 3400 0204 5600 0252 1400 &JV@ZR\@BD.@B*L@
0010 060)0414 6400 0234 6400 0240 4300 0240 4500 DL4@B\4@B #@B %@
0010 070)0240 4700 0240 5100 1032 4400 0210 1000 B '@B )@HZ$@BHH@
1 Like

Some times paper trape can have more program data after the intital bootstrap load.
That could be the case with chess program.

I have inspected that other chess file. There’s a longer leader and trailer and data before that leader. But not text. Probably parts of an earlier tape and obviously a conversion from a real physical paper tape.

When removing that exceeding data that tape will load correctly in an emulator, but no output and HLT. I don’t remember where I found it. Probably corrupt like the text inside or different format or not a full chess program but a database or data for graphical output. No ORG and no data at 0. Tested running from 200 and 7600 (vector at 7777).

There’s another chess file chess1.bin on the software repository from the online emu also with longer leader and trailer (but no data before leader). By coincidence there’s also a chess1.c
First it didn’t run either and HLT. But after setting to model PDP-8E and 1KW RAM it works.

https://pop.aconit.org/Programs/

Something I know from my limited experience with paper tape images: programs may have been broken up into parts, which makes it much easier to repunch just the part you continue working on. (E.g., Spacewar! comes on 3 paper tapes and 3 source files.) Also, you may find patches after the original file (indicative of a first step of consolidation: the patch hasn’t been integrated into the program yet, but it is apparently desireable enough to punch a tape, where you would just load the next file to apply the patch.) And there may be actually patches patching into patches (rather than patching the original program, the patch may be to be applied to an earlier one, which already hooks into the program at a known point in the control flow, but this patch may be missing now.) – A program on paper tape can at times resemble more a Rube Goldberg contraption (or Heath Robinson, with regard to early computer history) than a solid file.

I’m quite sure that the chess.bin file is from bitsavers (bits/software).

I also have extracted the SBC6120 image file (perl script os8xplode) and found chess.sv and a text file. OS8 usually have .sv and I think .bn files (.bin files are different).

There’s no perl script titles sv2bin but I think it’s the 3to4 script.
Although suffix bin, I assume it’s an OS8 format. But I haven’t compared it.
There’s also a chess.bin file delivered with an Atari800XL pdp8 emulator. But that seems a real bin file probably the chekmo chess, obviously starting at 200.

Glad you found it and liked it. I wrote it as a sort of proof of concept. I had earlier written a script that emits 16 bit x86 code, so I knew it should be possible.

The emulator bolted on below (for I/O and self modifying code) never got very robust. It does do simple stuff, though.

Vince

2 Likes