A 2025 manual to the DEC PDP-1

1 month ago 6
Appendix: Understanding the PiDP-1 hard/software setup
This appendix goes into the inner workings of the PiDP-1 hard/software. That may be of use when you want to customise your setup. The software is written as separate modules that interconnect over network ports. So it is quite easy to customise or improve one of these modules.

Of course, it is always a good idea to have a general understanding of the software setup - which is the first section below.

Software - overview

Everything about the PiDP-1 lives in the /opt/pidp1 directory. The sources are part of the package, the install script compiles the programs in the src/ directory.
All the executables are in the bin/ directory - note that most are symlinks to the actual compiled binaries in their src/ subdirectories. So if you recompile any source file, the PDP-1 simulator will immediately use the new version.

All PDP-1 paper tapes are stored in the tapes/ directory. They typically have .rim, .pt or .bin as their extension. The extension does not matter to the PiDP-1, it just tells you what kind of paper tape this is - .bin is likely to hold alphanumeric data, .bin might be a binary without RIM loader, .rim will have the RIM loader. But the extensions are not applied all that consistently. Use tape_visualizer to inspect them.
In the sources subdirectory, the source code is stored for review. A doc subdirectory holds manuals.

Boot options: the Sense switches One way to boot up the PiDP-1 is to use the 6 sense switches on the front panel. The idea is, you set an octal number on the sense switches before starting the simulator. A little config file then auto-mounts the desired paper tape in the reader, and can set some hardware configuration settings for the PDP-1.
These config files are stored in the bootcfg/ directory. Their filename tells you what sense switch number they are linked to.
You can change, add or renumber the cfg files to your preference. There's not much special about them.

Software - panel driver, virtual & physical front panels
Please note that the whole PiDP-1 software package can run on regular Linux just as well as on a Raspberry Pi. You woud then use the virtual front panel instead of the PiDP-1 hardware. It will work on Windows as well, if you set up the WSL2 subsystem with graphics display. We're looking for a Windows user who can do a little write-up about that!
The main programs, all in /opt/pidp1/bin:
  • pdp1: the actual simulator. It uses telnet connections 1040 for direct command entry (not used, but type ? for the menu) and 1041 for connecting to the simulated typewriter. TCP ports are used to connect to the other peripherals, so these may run locally on the Pi or remotely on your laptop.
  • panel_pidp1: the hardware driver for the PiDP-1 front panel.
  • vpanel_pdp1: the virtual front panel you can use instead of the PiDP1 hardware
  • pdp1control.sh: the bash script that starts up the whole system, and can reconfigure it. Have a look inside, it's just a script.
Software - GUI interface
  • pdp1_periph: the all-in one window that typically runs locally. You could use it from a remote machine as well, though.
  • pdp1.sh: used to attach peripherals, mount tapes, etc during regular use. Have a look at the script, it will show you how it is done and how you could hack your own configuration.
Software - Web server interface
  • /opt/pidp1/web_pidp1 contains the web server
  • to connect to the web server, you would typically use a browser and URL http://[pi's host name].local:8080
    Note that you could configure the Pi so it can be reached from anywhere, offering PDP-1 compute time as a valuable public service :-)
Software - Apps interface
  • tapevis: visualises the paper tapes.
  • p7sim/p7simES: the type 30 display
    a Second Type 30 can be attached, by running the same program as p7simES -p 3401 localhost. The ES version has a lighter CPU load but almost the same image quality. It is preferred.
  • load/save_ptr.sh: little scripts that mount paper tapes. Again, just look inside for how it's done.
  • pdp1.sh is used here as well as in GUI mode. Look inside for how to use the various programs.
Hardware - theory of operation
pdp1 is the actual simulator.
It uses telnet connections 1040 for direct command entry (not used, but type ? for the menu) and 1041 for connecting to the simulated typewriter. TCP ports are used to connect to the other peripherals, so any of these may run locally on the Pi or remotely on your laptop.
The simulator is an interesting one: it simulates the circuit of the PDP-1 on the lowest level, rather than just simulating CPU instructions. The original version was, in fact, FPGA code, now converted to a simulation in C. have a look at the source code in /opt/pidp1/src/blincolnlights/pdp1/pdp1.c
The PDP-1 used non-volatile core memory. So after a power-down, the memory would still be intact. You can inspect the saved core memory in the file /opt/pidp1/coremem. It is in human-readable format.

The core pdp1 simulator needs a front panel attached to it to do anything useful. Either the hardware PiDP-1 driver or the virtual panel. It's not hard to write your own front panel controller if you'd like to do something customised, like a front panel web page or something.

PDP-1: AI programming assistant & example code
This is work in progress - under heavy construction but regularly updated as we progress with the project

We have created some .md text files that you can literally paste into ChatGPT, Claude Code or any other AI, telling the AI to learn about the PDP-1 and become your programming aide. Try this! It gives you a very smart side-kick when writing programs, or understanding them. Just paste one or more of the .md files into the AI, let it process the information, then start asking questions or giving tasks.

  • PDP1.md: the text you want to paste into your AI.
  • learnings.md: teach the AI to avoid nasty programming pitfalls
  • PDP1-inside.md: teach the AI about the inner guts of the PDP-1, which may help when you get stuck with some mysterious bug in your code.
PDP-1.md will be sufficient most of the time to have a tutor that can explain code snippets and suggest new ones.

We're writing a book on PDP-1 programming. Until that is out, here are some code snippets you might find useful:

Simple helloworld.mac: hello / above: title line - was punched in human readable letters on paper tape / below: location specifier - told assembler what address to assemble to 100/ lup, lac i ptr / load ac from address stored in pointer cli / clear io register lu2, rcl 6s / rotate combined ac + io reg 6 bits to the left / left 6 bits in ac move into right 6 bits of io reg tyo / type out character in 6 right-most bits of io reg sza / skip next instr if accumulator is zero jmp lu2 / otherwise do next character in current word idx ptr / increment pointer to next word in message sas end / skip next instr if pointer passes the end of message jmp lup / otherwise do next word in message hlt / halt machine ptr, msg / pointer to current word in message msg, text "hello, world" / 3 6-bit fiodec chars packed into each 18-bit word end, . / sentinel for end of message start 100 / tells assembler where program starts Try and make the above program print out the user-friendly 'hello, world' and you see that this way of printing strings might not be flexible enough. Our friendly AI Claude struggled hard with making a program that prints "hello world", then asks the user for his name, and print 'hello, [name]!'. Here is that program. See how much more elegant you can make it! We eagerly await contributions for the most efficient version of this program. tinkering with it will teach you all about the typewriter I/O, so we leave it in its raw AI-generated ugliness (hiding the fact that your author is quite sure he will not be the one with the most elegant solution, we're all learning here). / hello world program with interactive input 400/ / Main program lac greeting dac ptr jmp printloop / Print message printloop, lac i ptr dac word cli law 3 dac count lu2, lac word lio word rcl 6s dac word / Check if character is carriage return (077) lio word / get character in IO register dio temp / save character lac temp / load character to AC sub cret / subtract carriage return value sza / skip if it's carriage return jmp prtchr / not CR, print it hlt / CR found, halt program prtchr, tyo lac count sub one dac count sza jmp lu2 idx ptr sas endmsg jmp printloop / Call input subroutine jsp input / Print greeting with name after input lac complete dac ptr jmp printloop hlt / Input subroutine - read line of text until carriage return input, dac input / save return address / Input loop using DDT pattern law namebuf / reset name buffer pointer to start dac nameptr / store in pointer / Clear name buffer (4 words) cla dac namebuf dac namebuf+1 dac namebuf+2 dac namebuf+3 law 3 / load character count (3 chars per word) dac chrcnt / store character counter cla / clear packed word accumulator dac pckwrd / initialize packed word storage inloop, cla / clear accumulator cli / clear IO register clf 1 / clear program flag 1 wait, szf i 1 / skip if program flag 1 is zero (indirect) jmp wait / flag still zero, keep waiting tyi / flag set, read character / Process the character dio temp / save character from IO register lac temp / load character to AC for testing tyo / echo character back to user / Check if carriage return (FIODEC 077) sub cret / subtract carriage return value sza / skip if zero (character was CR) jmp store / not CR, store character and continue jmp endinp / CR found, finish current word and return / Handle end of input - store partial word if needed endinp, lac chrcnt / check if we have partial word sub three / compare with 3 sza / skip if chrcnt was 3 (no partial word) jmp partwd / partial word exists, store it lac cret / no partial word - add carriage return terminator dac i nameptr / store carriage return as string terminator jmp i input / return partwd, / Pad partial word with carriage returns in empty positions lac chrcnt / get remaining empty positions in current word pad, sza / skip if no more padding needed jmp dopad / need to pad jmp donepad / no padding needed dopad, lac pckwrd / load current word rcl 6s / shift left 6 bits to make room dac pckwrd / save shifted word lac cret / load carriage return add pckwrd / add CR to rightmost position dac pckwrd / save padded word lac chrcnt / get remaining count sub one / decrement dac chrcnt / store count jmp pad / continue padding donepad, lac pckwrd / load final padded word dac i nameptr / store it in name buffer idx nameptr / move to next location lac cret / load carriage return terminator dac i nameptr / store separate CR terminator as backup jmp i input / return / Pack character into FIODEC word (3 chars per 18-bit word) store, lac pckwrd / load current packed word rcl 6s / rotate left 6 bits to make room for new character dac pckwrd / save shifted word lac temp / load the new character add pckwrd / add character to packed word (in low 6 bits) dac pckwrd / save updated packed word lac chrcnt / load character counter sub one / decrement counter dac chrcnt / save counter sza / skip if counter is zero (word complete) jmp inloop / not zero, continue packing more chars (back to input loop) / Word complete - store it and start new word lac pckwrd / load completed packed word dac i nameptr / store packed word in name buffer idx nameptr / increment name buffer pointer law 3 / reset character count for next word dac chrcnt / store counter cla / clear packed word for next word dac pckwrd / initialize for next word jmp inloop / continue reading next character / Data ptr, 0 word, 0 count, 0 one, 1 temp, 0 cret, 077 three, 3 nameptr, 0 chrcnt, 0 pckwrd, 0 greeting, testmsg testmsg, text "hello world" 777777 text "what is your name?" endmsg, . complete, donemsg donemsg, text "Hello again, " namebuf, 0 0 0 0 0 namend, 0 777777 . start 400

We left this for the end of this section, and that is wrong. It should be the first thing you go through: the dozens of pages on masswerk.at that take you through the PDP-1, its assembly language, commented source code of many programs. Norbert Landsteiner is the 21st century Godfather of the PDP-1. Spend many hours on his site, treasures are hidden all around it. We will add a summary of them here later on.

Read Entire Article