1965 - The PDP-8

The PDP-8 #

The PDP-8 was released in 1965 as one of the first “minicomputers”. Shown here is the first model, built with a range of flip chip cards (each holding a few transistors, diodes, and some passive components. The backplane(s) contained all the point-to-point wiring which brought the whole thing to life.

I’ve never seen such a machine in real life (my first exposure to computers was in 1969), but I did once briefly fool around with a later variant, the PDP-8/i shown below:

INTRODUCTION #

This article describes an emulator I implemented a while back, running on a minuscule microcontroller board. It does not take much to implement the basics, enough to run an interactive programming environment called FOCAL: 4 kilowords of (12-bit) memory and an ASR-33 teletype.

The ASR-33 includes a papertape reader to load data into memory. Since these PDPs had core memory, the FOCAL code is not lost when the machine is turned off, making it easy to resume work the next day.

Hardware choices #

For this setup, I used a “TenStar Mini STM32F103” board (link). The two main chips are on the back: an STM32F103 µC with 64 KB flash and 20 KB RAM and a CH340 USB-to-serial interface. Together, these are sufficient to upload firmware to the µC and to communicate with the board via serial USB.

The PDP-8 uses 12-bit words, which is an awkward fit for today’s byte-oriented microcontrollers. To maximize the amount of memory available for emulation, I will store 2 PDP-8 words in 3 ARM Cortex bytes. This allows emulating at least 8 KW (2 “fields” in PDP-8 terminology), possibly even 12 KW.

The front panel won’t be emulated, i.e. no switches or incadescent light bulbs, but I can add 12 LEDs to track the current value of the program counter and perhaps later on also some disk storage.

SOFTWARE #

The software for this configuration is really very simple: a small emulator for the core PDP-8 instruction set plus some IOT opcode emulations to poll and read the keyboard and to write to the “teleprinter” (both emulated using a serial USB port). The FOCAL program is pre-loaded in flash and copied to the emulated RAM on startup.

Note: the code for this project is available at https://git.sr.ht/~jcw/retro in the 1965/ folder.

To get the most of the limited 20 KB RAM present in the STM32F103 µC, I’ve used some C++ code trickery to squeeze a pair of 12-bit PDP-8 “words” into three 8-bit bytes in the µC. This will make it possible to fit three 4 KW “fields”, i.e. 12 KW in total, into 18 KB RAM, leaving 2 KB for some emulator state, a work stack, and a few hundred bytes needed by JeeH for the UART driver and some other tidbits. But that’ll have to wait - here’s FOCAL running in 4 KW (I’ve removed some empty lines):

focal: STM32F103xx @ 72 MHz (v7.0.2-65-g28e0ce12)

CONGRATULATIONS!!
YOU HAVE SUCCESSFULLY LOADED 'FOCAL,1969' ON A PDP-8 COMPUTER.
SHALL I RETAIN LOG, EXP, ATN ?:YES
PROCEED.
*T FEXP(100),!
= 0.26880540E+44
*

That’s an interactive calculation of e¹⁰⁰ with 24 bits of floating point precision, anno 1965 …

Adding blinking lights #

Or rather: blinkenlights. All it takes is some code to grab the value of the program counter and show it on the LEDs. Due to the human eye’s persistence of vision, there is no point updating the LEDs after every instruction: an update rate of 100 Hz is more than enough to present a real-time display. This is very easy to implement with JeeH’s timers and background tasks.

The LEDs have been connected in two groups of 6: PA0..PA5 for the lower 6 half and PB6..PB11 for the upper half. These three lines of code will copy the current pc value to the twelve LED pins:

enum { BSRR = 0x10 }; // from the reference manual (RM0008 r18 p172)
GPIOA[BSRR] = (0x003F<<16) | (pc & 0x003F);
GPIOB[BSRR] = (0xFC00<<16) | (pc & 0x0FC0);

The background task itself takes another two dozen lines of code and will trigger once every 10 ms.

TO BE CONTINUED … #