Note: these weblog posts now appear at a leasurely once-a-week pace. Although the summer vacation time is now over, I have decided to stick to this schedule for a while: more time to think and prepare new posts.
The following exploration falls squarely into the “simply because I can” category.
With last week’s implementation of a low-end PDP-8, it’s not hard to take this “let’s emulate a PDP” theme onto other platforms. Such as the STM32F103 µC, which has 20K of RAM and 64K or more of flash: plenty!
The main change needed to make this work – as expected – was the console I/O, which is actually a bit simpler for an embedded environment, since it more closely matches what the PDP-8 needs. In this case, I used this example as starting point, which uses the excellent libopencm3 runtime library, made for a wide range of ARM Cortex µCs.
And here’s the result, running on this thing:
The source code files are on GitHub.
At 35 KB, the firmware ends up fairly large: 9 KB is due to the embedded Focal
“paper tape” image, much of the rest is probably due to a floating-point
enabled printf
.
For a taste of the (computationally) roaring sixties, check out this demo - this is a literal transcript of me entering new code, running it, dumping it, and showing free space stats:
LOAD 0000-7577 CHECK 1153
CONGRATULATIONS!!
YOU HAVE SUCCESSFULLY LOADED 'FOCAL,1969' ON A PDP-8 COMPUTER.
SHALL I RETAIN LOG, EXP, ATN ?:YES
PROCEED.
*ERASE ALL
*1.03 ASK "SINE WAVE AMPLITUDE", AMPL, !
*1.04 ASK "DAMPING FACTOR COEFFICIENT", T, !
*1.05 FOR K=0,60; TYPE "."
*1.06 TYPE !; FOR I=0,.5,15; DO 1.11; TYPE "*"; DO 3
*1.07 QUIT
*1.11 FOR J=0,30+AMPL*FSIN(I)*FEXP(-T*I); DO 2; T " "
*2.1 IF (J-32) 2.3, 2.2, 2.3
*2.2 TYPE "."
*2.3 RETURN
*3.1 IF (31-J) 3.3, 3.2; FOR K=J,30; TYPE " "
*3.2 TYPE "."
*3.3 TYPE !; RETURN
*GO
SINE WAVE AMPLITUDE:15
DAMPING FACTOR COEFFICIENT:.135
.............................................................
*.
. *
. *
. *
. *
. *
*
* .
* .
* .
* .
* .
* .
*
. *
. *
. *
. *
*
* .
* .
* .
* .
* .
* .
* .
*
*
. *
*
*
*WRITE
C-FOCAL,1969
01.03 ASK "SINE WAVE AMPLITUDE", AMPL, !
01.04 ASK "DAMPING FACTOR COEFFICIENT", T, !
01.05 FOR K=0,60; TYPE "."
01.06 TYPE !; FOR I=0,.5,15; DO 1.11; TYPE "*"; DO 3
01.07 QUIT
01.11 FOR J=0,30+AMPL*FSIN(I)*FEXP(-T*I); DO 2; T " "
02.10 IF (J-32) 2.3, 2.2, 2.3
02.20 TYPE "."
02.30 RETURN
03.10 IF (31-J) 3.3, 3.2; FOR K=J,30; TYPE " "
03.20 TYPE "."
03.30 TYPE !; RETURN
*LIST
3206
3511
3542
4617
All running in a mere 4096 12-bit words!