"I want to know exact details, hard information about everything!" J.G. Ballard told an interviewer, in the pre-Internet year of 1982. Expressing his hope that "the computer and TV revolution will bring about...a scientific information channel where you can just press a button" and be deluged by the kind of obscure data that fed his imagination as a visionary novelist, Ballard rhapsodized, "I want to know everything about everything! I mean, I want to know the exact passenger list of that DC-10 that crashed outside Malaga two weeks ago, I want to know the latest automobile varnishes that are being used by the Pontiac division of General Motors, I want to know what Charles Manson has for breakfast—everything!" But, he lamented, "it's very difficult to get this information—access is the great problem."
Not anymore, of course, and it seems a fitting tribute to Ballard's interest in what he called "invisible literature" that lists of the Last Meals of Death-Row Inmates (if not daily updates on Manson's breakfasts) have become a clickbait staple. "The Sad, Stately Photo of Nixon's Resignation Lunch," posted by the NPR food and agriculture correspondent Dan Charles, isn't exactly a snapshot of a last meal, but it's close kin to it, symbolically, though how much of that has to do with our historical awareness that this was a meal about to be eaten by a political pariah whose bags were packed for the purgatory of San Clemente ("This is the lunch that President Richard Nixon ate on August 8, 1974, just before going on national television to announce that he was resigning," writes Charles) and how much of it has to do with the dispiritingly geriatric, assisted-living-cafeteria aesthetics of the meal, who knows?
This is a lunch from a lost world, when grown men drank milk and fallout-shelter fare like a scoop of cottage cheese girdled by a pineapple ring (straight out of a can, no doubt) was still on lunch menus. The official White House emblem on the plate stirs unsettling memories of Hitler's dinner service, pilfered from Berchtesgaden by American G.I.'s. Did Nixon dine alone that day? (I imagine him eating alone in a pin-drop silence broken only by the clink of cutlery and the sound of swallowing, a Nixonian version the aging astronaut eating his last supper in 2001.) Why the White House photographer, Robert Knudsen, captured this melancholy repast on film, we don't know, but in a better America the Resignation Lunch would, by an act of congress, be a fixture on the White House menu—a memento mori in cottage cheese and pineapple, designed to remind all who would be King of America that even presidential power must pass.
If you ever go to a computer history museum, you’ll be struck by how bland most modern computers look. Prior to 1980 computers had lights and switches, and sometimes dials and meters. Some had switchboard-like wiring panels and some even had oscilloscope-like displays. There’s something about a machine with all those switches and lights and displays that gets your hacker juices flowing. Have you ever wanted to get started in retrocomputing? Is it difficult? Do you need a lot of money? That depends on what your goals are.
There are at least three ways you can go about participating in retrocomputing: You can pony up the money to buy actual antique computers, you can build or buy old computers recreated with anywhere from zero to one hundred percent of period-authentic components, or you can experiment with emulators that run on a modern computer. As a hybrid of the second and third option there are also emulations in FPGAs.
You can see that the first option can be very expensive and you will probably have to develop a lot of repair and restoration skills. Watching [Mattis Lind] twiddle the bits on an actual PDP-8 in the clip above is great, but you’ll need to work up to it. The two techniques which get you going without the original hardware don’t have to break the bank or even cost anything presuming you already have a PC.
Although some sneer at emulation, for some machines it is almost the only way to go. You couldn’t buy the original EDSAC, for example. It is also a good way to get started without a lot of expense or risk. But regardless of how you do it, there’s one thing in common: you have to know how to operate the thing.
Simh and BlinkenBone
One common way to emulate an old computer is to use the SimH suite. It has emulations for a large number of old computers. Normally, the emulation has a console and you appear to be entering data into some sort of terminal. Technically, that’s fine but it doesn’t give you that feel of handling the old hardware.
However, SimH does support an interface that can drive a real or simulated front panel for some machines. For example, earlier we covered the PiDP-8 kit, which uses SimH on a Raspberry Pi driving a fairly authentic-looking PDP-8 front panel. With BlinkenBone, though, you can run a Java front panel for many classic machines and thanks to SimH, they aren’t just mock ups. They work.
So let’s look at what it takes to operate a PDP-8 through the front panel. The PDP-8 — from DEC or Digital Equipment Corporation — started life in 1965. A base model cost about $18,500 — a whole lot of money in those days. The “straight 8” was full of discrete components and was the size of a refrigerator. We’ll look at a PDP-8/I, a machine made with ICs around 1968. While it was large by today’s standards, it wasn’t the size of a fridge.
Why the PDP-8? Well, there are several reasons. First, the PDP-8 is very simple, yet fairly representative of early computers. Second, thanks to BlinkenBone, you can play along with no hardware at all. If you have a PiDP-8, that will work too. If you are lucky enough to have access to a real working PDP-8, then you are all set.
If you don’t want to read the blow-by-blow, you might prefer watching the video, below.
A Tour of the PDP-8/I Front Panel
The PDP-8/I has 26 switches. There are also two obvious key switches: one for on/off, and another to lock the panel (both of these are missing on the PiDP-8). Starting at the left, you’ll see the following switches:
Data field (3) – Sets the data field (which has 4K page of memory used for data)
Instruction field (3) – Sets the instruction field
Address/Data switches (12) – Sets the 12-bit address or 12-bit data word. Up position is zero and the leftmost switch is bit 0. Color groups correspond to octal digits.
Start – Press down to run program
Load Add – Press down to load address on switches to be current address
Dep – Press up to transfer data switches to current memory location and increment the current location
Exam – Press down to load the lights with the memory contents at the current location and increment current location
Cont – Continue after a stop (as opposed to Start, which starts over)
Stop – Stop execution
Sing Step -A toggle switch that lets you step a machine cycle at a time; SimH doesn’t support this and the PiDP-8 uses this switch to do things like reboot the underlying Raspberry Pi
Sing Inst – Another toggle switch that causes the machine to handle Start and Cont by executing one instruction and halting
Your PC probably has gigabytes of RAM memory organized as 8-bit bytes. The PDP-8 has the ability to address 4K or RAM organized as 12-bit words. Even in those days, 4,096 words of memory wasn’t very much, so the data and instruction fields let you have multiple 4K fields if you could afford the extra memory.
On a real PDP-8 Dep is reversed — you push it up instead of down. This is to prevent you from accidentally writing over memory if you get the switches mixed up. The PiDP-8, by default, doesn’t reverse the switch, although you can do it with a simple modification.
The lights — and remember, on a real system these are not LEDs — show the address and data, as I mentioned earlier. It also shows registers. The lights in the panel’s right-hand box show the current instruction (first column), the current machine cycle (middle column), and the machine state (right column).
If you are wondering how the PDP-8 uses 8 lights to show what instruction is executing, it is simple. There are only 8 instructions. That may sound incredible if you are used to modern computers, but it is true. A machine that could compile Fortran programs, run Basic, and do lots of other tasks only had 8 instructions. So much for the invention of the reduced instruction set computer (RISC) many years later.
Honestly, 8 instructions is a bit of a half-truth. There are 8 opcodes. One of those op codes has a few sub codes (but only a few). Later enhancements used the I/O instruction to do things, further increasing the instruction set.
Each 12-bit instruction starts with a 3-bit opcode. You can do a logical and, a signed add, an increment and skip-if-zero operation. You can store the accumulator (and clear it in the process), or jump to a location or a subroutine. Each of those instructions allows for a 7-bit address. You can set another bit to indicate the memory address is indirect and another bit to indicate the 7-bit address is relative to the current page of memory or page zero. Obviously, with only 7 bits, instructions could not operate on any memory location, so page 0 was a way to communicate between disparate areas of your program.
One op code contains two groups of “microcode” instructions. These can do things like clear the accumulator, invert the accumulator or increment the accumulator. Not only can the instruction (the OPR instruction) do those things, it can do any or all of them in one instruction. There’s also a defined order of operation, so you do things like clear the accumulator and increment it to put a 1 in the register.
There’s no subtract (negate and add will work). There’s no logical or instruction (hint: remember DeMorgan’s law). But there is enough that you can do significant programming. It just takes a lot of instructions.
There are even more subtitles. Self-modifying code was common and some memory addresses magically increment when you use them as indirect addresses. A tutorial on programming the PDP-8 could be a whole post by itself, but I wanted to give you a flavor for what programming on a machine like this looks like. Different machines had different indirection and memory addressing schemes, but these general principles were very common in this era. If you really want to dig in, you could do worse than read [Douglas W. Jones’] reference manual.
Consider this program in octal:
7301 ; load accumulator with 1 and clear link (carry)
7001 ; increment accumulator
7430 ; skip if link=0
7402 ; halt
5001 ; jump to location 1
In operation, this will zero the accumulator and the link bit (the carry) and then add one to the accumulator repeatedly until the carry bit sets. Then the program will halt. If you restart it, it will stop on each loop since the carry won’t get cleared when you resume. You could also single step it using the rightmost switch.
How can you enter a program like this using the front panel?
Using the Front Panel
If you are using Blinkenbone, go to this page and download the package for your operating system. You’ll also find instructions on how to launch the emulator (a batch or script file).
By default, the script file will load an operating system and run, but that’s way more advanced than we want. We want to flip switches. So press the Stop button after the front panel appears (remember, depress down). Now you are ready to start flipping switches.
Press all 12 data/address switches up. Press Load Addr. Note the Program Counter lights all turn off.
Set the data/address switches to 7301 (DDD UDD UUU UUD where U is up and D is down).
Press Dep (remember, press this switch up). Note that the Program Counter is now 1, the Memory Address display is now 0, and the memory buffer shows the code you entered.
Repeat steps 2 and 3 for the other instructions (7001, 7430, 7402, and 5001).
Put the data/address switches back to zero (all up). Press Load Addr. Then press Start.
That’s it. You’ll see the accumulator flash and the link light will turn on. Then the processor will stop. If you want to examine your program, repeat step 1, but press Exam repeatedly and watch the Memory Buffer lights. You might also want to repeat step 1, press the Sing Inst button down and then press Cont repeatedly to watch the program execute one instruction at a time.
In practice, most people never did what you just did. Do you notice the box on the left of the panel marked “Rim Loader” with some numbers within? That was the stage one loader. You would toggle those codes in (starting at address 7756) and run it. Then a more advanced loader would read from some other device (probably paper tape, but maybe something more magnetic). That loader could then read what you wanted to run (like a compiler or — if you had a big system with disks or tape — an operating system).
Realistically, though, if you really want to do that, you can just restart the SimH and let it do all the work. The default for the PDP-8 plays Adventure, and if you start it, you’ll see that the data display on the front panel makes a very nice show while you play (I assume that’s deliberate).
It can be fun to learn about old computers and finding ways around these old machine’s limitations. If nothing else, coding for a PDP-8 will make PIC or AVR assembly language seem luxurious. SimH can simulate lots of machines, some with front panels. There are also many replica kits for blinking light machines ranging from fake Altair 8800s, to COSMAC Elf replacements, and more. Of course, every front panel was different, but they do tend to share common ideas.
You could argue that these old machines don’t have practical value anymore. That’s probably true. But then again, it isn’t much different from someone wanting to restore an old motorcycle, or build a model ship and people do that all the time.
Today at the Usenix Security conference, a group of University of Washington researchers will present a paper showing how they wrote a piece of malware that attacks common gene-sequencing devices and encoded it into a strand of DNA: gene sequencers that read the malware are corrupted by it, giving control to the attackers.
In the mid-1970s, if you had your own computer, you probably built it. If you had a lot of money and considerable building skill, you could make an Altair 8800 for about $395 — better than the $650 to have it built. However, cheaper alternatives were not far behind.
In 1976, Popular Electronics published plans for a computer called the COSMAC Elf which you could build for under $100, and much less if you had a good junk box. The design was simple enough that you could build it on a piece of perf board or using wire wrap. We featured the online archive of the entire Popular Electronics collection, but hit up page 33 of this PDF if you want to jump right to the article that started it all. The COSMAC Elf is a great little machine built around a 40-pin RCA 1802 processor, and for many was the first computer they owned. I lost my original 1802 computer in a storm and my recent rebuild in another completely different kind of storm. But there is a way to reclaim those glory days without starting from scratch. I’m going to repurpose another retro-computing recreation; the KIM-1.
I’ll admit it, Rewiring a real KIM-1 to take an 1802 CPU would be difficult and unnecessary and that’s not what this article is about. However, I did have a KIM UNO — [Oscar’s] respin of the classic computer using an Arduino mini pro. Looking at the keyboard, it occurred to me that the Arduino could just as easily simulate an 1802 as it could a 6502. Heck, that’s only two digits different, right?
The result is pretty pleasing. A “real” Elf had 8 toggle switches, but there were several variations that did have keypads, so it isn’t that far off. Most Elf computers had 256 bytes of memory (without an upgrade) but the 1802 UNO (as I’m calling it) has 1K. There’s also a host of other features, including a ROM and a monitor for loading and debugging programs that doesn’t require any space in the emulated 1802.
The KIM UNO has 24 switches. There are 16 for the hex digits, of course. The top two rows mimic functions from the original KIM-1. A real Elf had a way to input a byte (usually 8 toggle switches), a load switch, a run switch, a memory protect switch, and a push button wired to a CPU pin. That means the hardware has more than enough switches.
On the display side, a normal Elf had a single-byte hex display although some clones had more. There was also the Q LED that a program could light or extinguish. The KIM UNO hardware has many 7-segment displays so it is possible to put those digits to use like an Elf clone. There isn’t an LED, however, except for the Arduino’s built in LED which is not normally visible in operation. However, the digital displays have decimal points and they are connected to the Arduino. So if you don’t mind using those, you have plenty of LEDs, too.
The hardware is open source and easy to duplicate. [Oscar] sometimes has kits as well and they are very inexpensive (about $20).
The KIM UNO software is open source, so I started there. I first stripped all the code out of the main file other than the parts that drove the display and the keyboard, then built up everything need to suppot 1802 emulation. You can find all the code in my 1802UNO GitHub repository.
Inside the 1802
The 1802 instruction set is very regular and quite simple. Most instructions use the top 4 bits as an op code and the bottom 4 bits to select one of sixteen 16-bit registers. So 0x12 increments register 2 and 0x15 increments register 5. There are only a handful of op codes that don’t follow this pattern. There’s also an 8-bit accumulator called “D” (not to be confused with register D).
One unique feature in the 1802 architecture is the program counter. There isn’t one. Well, more precisely, there are up to 16. Any of the registers can be the program counter and a subroutine call can be as simple as switching the program counter. Unfortunately, that isn’t very reentrant (or good for recursion). If you want a proper subroutine call, you had to code it yourself. RCA provided the “standard call and return technique” that had the unfortunate downside of destroying the accumulator.
With so few instructions, the emulator turns out to be a few switch statements and some pretty simple code. Although it is made to run with the KIM UNO hardware, like the KIM UNO, you should be able to use it with just about any Arduino via the serial port. It isn’t quite as fun as having the real hardware, but it is simpler.
The emulator is reasonably accurate except it doesn’t simulate interrupts (since there is no source of them). However, it doesn’t faithfully reproduce the 1802’s load mode which used DMA. Instead, load mode is just completely custom code that enters data into memory. It does not simulate the cycle and register manipulations that go on in a real 1802 using DMA in load mode.
In addition to loading a program with the ersatz load mode, you can also move RAM back and forth to EEPROM or a PC via the serial port.
Serial and Push Buttons
The serial port is just the usual Arduino serial port set for 9600 baud. By default, the serial input will mimic the hardware keys. However, you can use the pipe character (‘|’) to shift the serial port into terminal mode. Then the 1802 code can read data from the serial port. You lose the front panel functions and there’s no way to go back until you cycle the power unless you make the 1802 code release the port.
A few of the push buttons have special functions if you hold them down for more than one second. For example, the AD button writes the EEPROM data into RAM. This is useful for storing a self-contained demo, for example.
You can find a summary of the keyboard and serial commands on the GitHub site. The serial port can do things you can’t do from the front panel, like set a trace mode, dump the CPU registers, and more.
The hardware doesn’t require any changes to the stock KIM UNO kit. There’s a lot to solder and once you solder the displays on, it would be hard to get the Arduino back off the board.
You could probably build the software using the Arduino IDE, but I used Platform IO. That lets me use the editor of my choice, but you ought to be able to get the code to work in the IDE, as well. There is enough memory to make the RAM slightly bigger, but I didn’t do it. Since one way to save and load the RAM is to EEPROM, I didn’t want the RAM to be larger than the EEPROM. In addition, the RAM “maps” like a real Elf (that is, RAM at location 0x0 also appears at 0x4000, 0x8000, etc). This would be more difficult if you added a little bit more than 1K of RAM.
There are a few other options at the top of 1802config.h. You can select how often the screen and keyboard refresh. Higher values are slower to refresh but faster to execute code. You can change the I/O ports associated with the keyboard, displays, and serial port. You can also change the serial escape character.
There are some examples provided that blink the LEDs and manipulate the serial port. If you look around, there’s a lot of 1802 code on the web. However, be aware that most 1802s don’t have a hardware UART. They emulate serial ports using the Q output and one of the EF inputs. That’s fine for a real device even though it takes lots of code, but for this virtual device, it isn’t practical. You’ll need to rip out any code that does serial I/O and replace it with single I/O instructions.
If you have a binary file (or a format you can convert to binary) I have a converter written in C included on GitHub. You can compile it on nearly any platform and use it to convert. It always assumes address. If that’s not right, you can always open the output in a text editor and adjust.
In addition, there are three ROMs included that you can try. By default, there is a simple high-low game. There are also two monitors, one for use with the built-in keyboard and another for use with a serial port. To select a ROM, edit 1802rom.h and change the comments so the ROM you want is not commented and the others are.
Emulators are fun, but as the song goes, there’s nothing like the real thing. If that’s not authentic enough for you, it is possible to build a very authentic looking Elf, even today. The reason real 1802s are still around is they had several desirable characteristics, namely low power consumption and resistance to radiation.
The Arduino simulation has neither of those features. However, it is a fun retrocomputing toy, inexpensive, and a great learning tool. The CPU is simple enough to program directly in machine code and the portability is better than most other old school computers.
If you want to learn more about the 1802 there are several sites dedicated to it and a very helpful Yahoo group. One site has a very prolific software author, but most of the code won’t fit in the 1802 UNO’s 1K RAM. Maybe a version with more memory is in the future.