Writing BASIC-8 on the TSS/8
I recently discovered SDF’s PiDP-8. You can access it over SSH and watch the blinkenlights over its twitch stream. It runs TSS/8, a time-sharing operating system written in 1967 by Adrian van de Goor while a grad student here at CMU. I’ve been having fun tinkering with it, and I just wrote my first BASIC program1 since high school. It plots the graph of some user-specified univariate function. I don’t claim that it’s elegant or well-engineered, but it works!
10 DEF FNC(X) = 19 * COS(X/2)
20 FOR Y = 20 TO -20 STEP -1
30 FOR X = -25 TO 24
40 LET V = FNC(X)
50 GOSUB 90
60 NEXT X
70 PRINT ""
80 NEXT Y
85 STOP
90 REM SUBROUTINE PRINTS AXES AND PLOT
100 IF X = 0 THEN 150
110 IF Y = 0 THEN 150
120 REM X != 0 AND Y != 0 SO IN QUADRANT
130 GOSUB 290
140 RETURN
150 GOSUB 170
160 RETURN
170 REM SUBROUTINE PRINTS AXES (X = 0 OR Y = 0)
180 IF X + Y = 0 THEN 230
190 IF X = 0 THEN 250
200 IF Y = 0 THEN 270
210 PRINT "AXES INVARIANT VIOLATED"
220 STOP
230 PRINT "+";
240 GOTO 280
250 PRINT "I";
260 GOTO 280
270 PRINT "-";
280 RETURN
290 REM SUBROUTINE PRINTS FUNCTION GRAPH (X != 0 AND Y != 0)
300 IF 0 <= Y THEN 350
310 REM Y < 0
320 IF V <= Y THEN 410
330 REM Y < 0 AND Y < V SO OUTSIDE OF PLOT AREA
340 GOTO 390
350 REM 0 <= Y
360 IF Y <= V THEN 410
370 REM 0 <= Y AND V < Y SO OUTSIDE OF PLOT AREA
380 GOTO 390
390 PRINT " ";
400 RETURN
410 PRINT "*";
420 RETURN
430 REM COPYRIGHT 2021 RYAN KAVANAGH RAK AT RAK.AC
440 END
It produces the following output:
I
I
* ** I **
* ** I **
** ** *I* ** *
** ** *I* ** *
** *** *I* *** *
** **** *I* **** *
** **** *I* **** *
** **** *I* **** *
** **** **I** **** *
*** **** **I** **** **
*** **** **I** **** **
*** **** **I** **** **
*** ***** **I** ***** **
*** ****** **I** ****** **
*** ****** **I** ****** **
*** ****** **I** ****** **
*** ****** **I** ****** **
*** ****** ***I*** ****** **
-------------------------+------------------------
****** ****** I ****** ******
****** ****** I ****** ******
***** ****** I ****** *****
***** ****** I ****** *****
***** ***** I ***** *****
***** ***** I ***** *****
***** ***** I ***** *****
***** **** I **** *****
***** **** I **** *****
**** **** I **** ****
**** **** I **** ****
*** **** I **** ***
*** *** I *** ***
*** *** I *** ***
*** *** I *** ***
** ** I ** **
** ** I ** **
* * I * *
I
I
Next up, I am going to try my hand at writing some FORTRAN or some FOCAL69. If you like tinkering with old systems, then you should give the TSS/8 a try.
Comments: To comment on this post, send me an email following the template below. Your email address will not be posted, unless you choose to include it in the link: field. If your web browser is configured to handle mailto: links, click comment to load the template into your mail client.
To: Ryan Kavanagh <rak@rak.ac> Subject: [blog-comment] /blog/2021-04-07-writing-basic-8-on-the-tss-8/ post_id: /blog/2021-04-07-writing-basic-8-on-the-tss-8/ author: [How should you be identified? Usually your name or "Anonymous"] link: [optional link to your website] Your comments here. Markdown syntax accepted.
0 Comments