Re-implementing the venerable PDP minicomputers with modern hardware
GitHub repository: https://github.com/jeelabs/embello/tree/master/explore/1638-pdp8
The PDP-8 is a surprisingly simple computer, easily emulated in software as the above weblog posts illustrate. Here is another build, running on the “Blue Pill” (which costs about as much as that coin next to it):
This one is really as basic as it gets. It has the FOCAL language interpreter in flash memory and emulates a single 4 Kword “field” using 8 KB RAM. A USB console driver is included, so it’s all plug-and-play.
This emulator is written in Forth, which allows for very concise coding. Here is the implementation of 6 of the 8 opcodes in a PDP-8, as well as the main instruction fetch/decode/execute handler:
: op0 ( u -- ) addr m@ 10000 or ac and ac! ; \ AND : op1 ( u -- ) addr m@ ac + low13 ac! ; \ TAD : op2 ( u -- ) addr dup m@ 1+w dup rot m! 0= if ++pc then ; \ ISZ : op3 ( u -- ) addr ac dup low12 rot m! clr12 ac! ; \ DCA : op4 ( u -- ) addr pc over m! 1+w pc! ; \ JMS : op5 ( u -- ) addr pc! ; \ JMP \ op6 and op7 are more involved and omitted here for brevity... create op-tab ' op0 , ' op1 , ' op2 , ' op3 , ' op4 , ' op5 , ' op6 , ' op7 , : cycle ( -- ) \ execute one instruction iena @ 2/ iena ! \ bit 0 determines whether interrupts are enabled pc dup 1+w pc! m@ dup 7 rshift %11100 and op-tab + @ execute ;