SearchA-ZP › DEC PDP-7

DEC PDP-7

1965 Open source · Public domain Online

A faithful DEC PDP-7 minicomputer authored for emulators.org and running in the browser. The PDP-7 is the 18-bit, one's-complement DEC machine of 1965 — a member of the PDP-4 / 7 / 9 / 15 family and the computer on which Ken Thompson wrote the first version of Unix at Bell Labs in 1969. This build models the processor, the KSR-33 console teletype and a bundled machine-code monitor, so it boots to a UNIX CONSOLE banner on a glass teletype and echoes whatever you type. It plugs into the shared debugger, where you can single-step the CPU, watch AC / PC / L / MQ change in octal, set breakpoints on the program counter, and read core memory as octal disassembly.

Runs on: Web browser

DEC PDP-7 Online Emulator

Play DEC PDP-7 using JavaScript directly in your browser.

Configurations

ConfigurationEmulatorMachineOSLegal
Console monitorDEC PDP-7DEC PDP-7openOpen ⛶

Notes

Embedding

The emulator is two small, self-contained pieces: a pure DEC PDP-7 processor (pdp7-cpu.js) and a glass-teletype canvas (pdp7-screen.js). Vendor both and drive the machine from your own loop. The core never touches the DOM, so the debugger can pause, step and breakpoint it:

var cpu = new PDP7({ onOutput: function (ch) { screen.putChar(ch); } });
cpu.load(image, 0o100);   // image = { addr: word }, start PC = 0100
while (!cpu.halted) cpu.step();   // step() = one PDP-7 instruction

The machine is plain objects. Everything the debugger needs is a live field or method on the core, so there is no wasm heap to reach into:

MemberKindWhat it does
cpu.step()methodExecute exactly one PDP-7 instruction (the single-step primitive), including one's-complement arithmetic, single-level indirect addressing and the operate microcode.
cpu.ac / cpu.pc / cpu.l / cpu.mqfieldThe 18-bit accumulator, the 13-bit program counter, the link bit and the EAE multiplier-quotient, as plain writable numbers.
cpu.srfieldThe front-panel switch register, OR-ed into AC by the OAS operate instruction.
cpu.rd(a) / cpu.wr(a,v)methodSide-effect-free read / write of one 18-bit word, what the debugger's memory views and watchpoints call.
cpu.keyFlag / cpu.keyBuffieldThe console keyboard flag and character buffer; the host raises the flag when a console key is ready.

Because the CPU and core store are ordinary JavaScript, breakpoints and watchpoints are host-side checks around cpu.step() and cpu.wr(), with no changes to the core.

Debugger integration

The boot shim publishes window.EMU_BOOT with a full transport: pause / resume / isPaused, stepInsn(n) (one instruction) and step(n) (a burst), reset, plus breakpoints (program-counter values the loop checks before each step) and watchpoints (core addresses, checked inside the write path). A dedicated CPU decoder, /debugger/src/cpus/pdp7.js, disassembles each 18-bit word into native octal mnemonics: the memory-reference set (CAL DAC JMS DZM LAC XOR ADD TAD XCT ISZ AND SAD JMP) with the indirect flag, the console IOTs (KSF KRB TSF TLS and friends), and the microcoded operate word (CLA CLL CMA CML OAS RAL RAR SMA SZA SNL SKP HLT, with the reversed skips SPA SNA SZL).

The core store is 8192 eighteen-bit words. The pdp7 decoder reads each word as three bytes, little-endian, so the plug-in exposes the store as a 24576-byte chip: byte 3n is bits 0–7 of word n, 3n+1 bits 8–15, and 3n+2 bits 16–17. Every instruction is therefore length three, and the register plug-in returns a byte-scaled pc() so the disassembly gutter, the program-counter highlight and breakpoints all line up on word boundaries. The on-screen console adds a front panel: switch-register toggles read into AC by OAS, plus START / STOP / STEP wired to the same transport the debugger toolbar uses.

Architecture

The DEC PDP-7, introduced in 1965, is an 18-bit, one's-complement minicomputer — the machine on which Ken Thompson wrote the first version of Unix at Bell Labs in 1969. It is a member of DEC's 18-bit family (PDP-4 / 7 / 9 / 15), close cousin to the earlier PDP-1.

  • Word and registers: 18-bit words held in one's-complement, an accumulator (AC), a link bit (L) that catches carries, an EAE multiplier-quotient (MQ), and a 13-bit program counter addressing up to 8192 words of core.
  • Instruction format: four bits of op code, one indirect bit, and a 13-bit address. Thirteen memory-reference orders (CAL DAC JMS DZM LAC XOR ADD TAD XCT ISZ AND SAD JMP) sit alongside three augmented groups whose address field is a function mask: EAE (extended arithmetic), IOT (in-out transfer) and OPR (the operate microcode, one combined micro-sequence rather than the PDP-8's split groups).
  • Console: a KSR-33 Teletype answers the IOT orders on device 03 (keyboard: KSF KRB) and device 04 (printer: TSF TLS), the same console over which early Unix was edited and assembled.

The bundled program is a short console monitor in genuine PDP-7 code. It starts at 0100, walks a banner string through a memory pointer with indirect LAC and ISZ, prints it with a JMS subroutine, then loops on KSF / KRB to read the keyboard and TLS to echo each key — adding a line feed after each carriage return, exactly as a Teletype console session would.