(all PDP-8 blog entries can be seen by clicking here)

I wanted to do a quick “Hello World” test in a programming language on the PDP-8 but it was not to be. Something is wrong with the standard BASIC interpreter. It fails to function on any of the PDP-8 OS/8 distributions I have tried. I’ve also tried multiple versions of SIMH. No luck.

After some quick looking, I found the PDP-8’s business basic here:

http://www.pdp8online.com/pdp8cgi/os8_html?act=dir;fn=images/os8/business_basic.rx01;sort=name

This version of BASIC will actually work.

These instructions show how to get PDP-8 business BASIC and install it onto the hard drive formatted in the last PDP-8 blog entry.

In the link above, click on “download this image …” to download the image of a floppy disk to your PC.

Run PDP-8, mounting the hard disk (RK0) and the floppy (RX0):

[c:\pdp8]pdp8 PDP-8 simulator V3.9-0 sim> set cpu 32k sim> set cpu idle sim> att rk0 rk0.dsk sim> att rx0 business_basic.rx01 RX: buffering file in memory sim> boot rk0 .

Now copy the contents of the floppy drive to the hard drive;

.COPY RKA0:<RXA0:*.* FILES COPIED: BCOMP.SV CCL.SV BASIC.AF BASIC.SF BASIC.FF BASIC.UF ECHO.SV ABSLDR.SV BASIC.OV FOTP.SV DIRECT.SV EDIT.SV PIP.SV SET.SV BASIC.SV BRTS.SV BLOAD.SV BASIC.WS

Now start the BASIC interpreter, create a new program called TEST, enter the single line to print “Hello World”, and finally run it:

.BASIC NEW OR OLD--NEW TEST READY 10 PRINT "HELLO WORLD" LIST TEST BA 6A 10 PRINT "HELLO WORLD" READY SAVE READY RUN TEST BA 6A HELLO WORLD READY

Need something larger to try? Here is the game Tic-Tac-Toe taken from the diag-games-kermit disk. Simply copy from here and paste into the BASIC interpreter:

.BASIC NEW OR OLD--NEW FILE NAME--TICTAC READY 1 DATA 2,3,4,9,1,5,8,7,6 2 DATA 2,3,4,9,1,5,8,7,6,2,9,8,3,1,7 3 DATA 4,5,6,2,1,6,4,1,8 4 DATA 0,1,-1,1,-1,1,-1,1,-1 5 DIM A(9) 6 DIM B(9) 7 DIM C(24) 8 DIM D(24) 9 DIM F(9) 10 FOR I=1 TO 9 11 READ A(I) 12 NEXT I 13 FOR I=1 TO 24 14 READ C(I) 15 NEXT I 16 FOR I=1 TO 9 17 READ F(I) 18 NEXT I 19 PRINT "TIC-TAC-TOE" 20 PRINT 21 PRINT "THE MOVE POSITIONS ARE:" 22 PRINT 23 PRINT "1 2 3" 24 PRINT "4 5 6" 25 PRINT "7 8 9" 26 GOSUB 133 27 GOSUB 133 32 LET E=0 33 LET G=2 34 LET K=0 35 FOR I=1 TO 9 36 LET B(I)=0 37 NEXT I 38 FOR I=1 TO 24 39 LET D(I)=0 40 NEXT I 41 PRINT 42 PRINT 43 PRINT "--BEGIN GAME--" 44 PRINT "YOU WILL BE 'X', I WILL BE 'O'" 47 PRINT "TYPE 0 IF YOU WANT ME TO GO FIRST"; 48 INPUT I 49 IF I=0 THEN 65 50 LET L=-1 51 PRINT "YOUR MOVE"; 52 INPUT I 53 PRINT 54 PRINT 55 LET H=INT(ABS(I)) 56 IF H<>I THEN 50 57 IF H < 1 THEN 50 58 IF H>9 THEN 50 59 LET H=A(H) 60 IF B(H) <> 0 THEN 50 61 IF K=1 THEN 64 62 LET G=F(H) 63 LET K=1 64 GOSUB 111 65 LET L=1 66 FOR I=1 TO 22 STEP 3 67 IF D(I) + D(I+1) + D(I+2) = -3 THEN 92 68 NEXT I 69 FOR I=1 TO 22 STEP 3 70 IF D(I) + D(I+1) + D(I+2) = 2 THEN 90 71 NEXT I 72 FOR I=1 TO 22 STEP 3 73 IF D(I) + D(I+1) + D(I+2) = -2 THEN 106 74 NEXT I 75 IF E=1 THEN 77 76 IF G = -1 THEN 78 77 IF B(1)=0 THEN 100 78 IF G <> 0 THEN 82 79 FOR I=2 TO 8 STEP 2 80 IF B(I)=0 THEN 101 81 NEXT I 82 IF H=8 THEN 86 83 FOR I=H+1 TO 8 84 IF B(I)=0 THEN 101 85 NEXT I 86 FOR I=2 TO 9 87 IF B(I)=0 THEN 101 88 NEXT I 89 GO TO 98 90 PRINT "I WIN" 91 GOTO 900 92 PRINT "YOU ARE NOT ALLOWED TO WIN" 93 FOR I=1 TO 9 94 LET B(I)=1 95 NEXT I 96 GOSUB 117 97 GOTO 900 98 PRINT "DRAW" 99 GOTO 900 100 LET I=1 101 LET H=I 102 GOSUB 111 103 LET E=1 104 GOSUB 117 105 GO TO 50 106 FOR J=I TO I+2 107 IF D(J)=0 THEN 109 108 NEXT J 109 LET I=C(J) 110 GO TO 101 111 LET B(H)=L 112 FOR M=1 TO 24 113 IF C(M) <> H THEN 115 114 LET D(M)=L 115 NEXT M 116 RETURN 117 FOR N=1 TO 9 118 IF B(N)=0 THEN 200 119 NEXT N 120 IF N<100 THEN 98 121 FOR N=1 TO 9 STEP 3 122 FOR O= 0 TO 2 123 IF B(A(O+N))=0 THEN 127 124 IF B(A(O+N))=1 THEN 129 125 PRINT "X "; 126 GO TO 130 127 PRINT "- "; 128 GO TO 130 129 PRINT "O "; 130 NEXT O 131 PRINT 132 NEXT N 133 PRINT 136 RETURN 137 STOP 200 LET N=1000 210 GOTO 119 900 GOTO 910 910 PRINT "TRY AGAIN (IF SO TYPE 0)"; 920 INPUT I 930 IF I<>0 THEN 999 940 GOTO 27 999 END SAVE READY RUN TICTAC BA 6A TIC-TAC-TOE THE MOVE POSITIONS ARE: 1 2 3 4 5 6 7 8 9 --BEGIN GAME-- YOU WILL BE 'X', I WILL BE 'O' TYPE 0 IF YOU WANT ME TO GO FIRST?

Now that you’ve got a real program running you can ‘compile’ it so you don’t need to run the basic interpreter first.

I will compile the TICTAC program entered above. SAVE the BASIC program to disk if you haven’t already, then exit BASIC:

SAVE READY BYE .

Now run the BCOMP program, and tell it to compile TICTAC.BA. It will compile the program into memory:

.R BCOMP *TICTAC.BA/K .

Finally you need to save the memory image to disk (for some reason you MUST specify the device, RKA0: in this case):

.SAV RKA0:TICTAC .

And to now run the ‘compiled’ program:

.R TICTAC TIC-TAC-TOE THE MOVE POSITIONS ARE: 1 2 3 4 5 6 7 8 9

I am putting ‘compiled’ in quotes because this really isn’t compiling the program. It appears it loads the BASIC run time plus the program into memory and then you save an image of that to disk. The TICTAC.SV (binary image) will not run unless the files BRTS.SV, BASIC.AF, BASIC.SF, and BASIC.FF are also present.

So there you have it – the ability to create, run, and ‘compile’ BASIC programs on the PDP-8.

Many many thanks for this excellent explanation. It has helped me mount devices as well as run Basic again.