SearchA-ZS › Sinclair Cambridge

Sinclair Cambridge

1973 Open source · GPL-2.0 Online

The Sinclair Cambridge runs here in your browser. It is based on Veniamin Ilmer's emulator, which runs the actual microcode he optically decoded, bit by bit, from a photograph of the calculator's chip die. The Sinclair Cambridge, introduced in August 1973, was the cheapest pocket four-function calculator of its day: Clive Sinclair's team built it around a single Texas Instruments TMS-0801, a four-function calculator chip with just three registers and a 320-word ROM.

We reproduce Ilmer's recovered ROM and its three programmable logic arrays and drive a faithful JavaScript port of his TMS-0800 core from our own loop, so the shared in-browser debugger gets a real single-instruction step, live registers, side-effect-free memory, execution breakpoints and register write-watchpoints - all decoded by the tms0800 disassembler for the 11-bit instruction word. Key a number, an operator, another number, then =. Use the on-screen keypad or your keyboard.

Read how the ROM was optically decoded ↗

Visit the official site ↗

Runs on: any modern web browser

Sinclair Cambridge Online Emulator

Play Sinclair Cambridge using JavaScript directly in your browser.

Configurations

ConfigurationEmulatorMachineOSLegal
Sinclair Cambridge (boots to 0.)Sinclair CambridgeSinclair CambridgegreyOpen ⛶

Machines emulated

Chips

Notes

Embedding

There is no build step. The core is a set of plain-global JavaScript modules loaded in order; the ROM and its three PLAs (opcode / word-select / constant tables) are the data Veniamin Ilmer optically decoded from the TMS-0801 die:

// shift-register primitive, ROM+PLA data, CPU core, and the 7-segment display
<script src="shifter.js"></script>        // serial shift register (bit / nibble, either end)
<script src="rom_cambridge.js"></script>   // CAM_ROM[320] + word-select / constant / opcode PLAs
<script src="cpu.js"></script>           // CamCPU: step() runs one 11-bit instruction
<script src="display.js"></script>       // CamDisplay: render register A/B to the LED panel

Boot. Construct the chip and display, then run your own loop so the debugger can pause and step it:

var chip = new CamCPU(CAM_ROM, CAM_ALU_OPCODES, CAM_WORD_SELECTS, CAM_CONSTANTS);
var display = new CamDisplay(canvas, chip);
(function loop(){
  for (var i = 0; i < 400; i++) chip.step();  // one instruction each; check bp/wp
  drainKey();          // apply one queued key event this frame
  display.update();
  requestAnimationFrame(loop);
})();

Keys. The chip scans its keyboard by comparing the rotating 10-bit D register against a held key code. The host sets chip.keypress to that code on press and back to 0 on release; a small FIFO applies one event per frame so a tap is held for a full key scan. The special code 512 (CE) hard-resets the program counter, exactly as the real chip's clear line does.

The machine is plain integers — no wasm heap — so the debugger reaches everything directly:

MemberKindWhat it does
chip.step()methodExecute exactly one 11-bit instruction; advances chip.pc and rotates the D scan.
chip.a / .b / .cfieldThe three 11-nibble (44-bit) BCD datapath registers, as shift-register objects (.data holds the packed value).
chip.fa / .fbfieldThe two 11-bit flag registers.
chip.pcfieldThe 9-bit program counter into the 320-word ROM.
chip.d / .carry / .keypressfieldThe 10-bit rotating key scan, the condition/carry latch, and the held key code.

Debugger integration

The debugger plug-in (sinclair-cambridge-debug.js) reads window.EMU_BOOT and calls EmuKit.defineMachine. Because the whole machine is ordinary JavaScript, single-stepping is just chip.step(), and each register digit is read and written straight off the chip.a/.b/.c shift registers.

The register panel exposes the program counter, the carry/condition latch, the key-scan latch, the D-scan value, the two 11-bit flag registers and every BCD digit of A, B and C as its own 4-bit box — so you can watch the serial digit-by-digit arithmetic that makes this chip so unusual. A side-effect-free register-file chip (33 nibbles: A, B, C) and the program ROM back the hex and disassembly views.

Breakpoints are a host-side Set the loop checks against chip.pc at every instruction boundary. Watchpoints snapshot the watched register-file nibbles before each instruction and pause when one changes — a true write-watchpoint over the chip's datapath registers, which are the only writable memory it has.

The shared tms0800 disassembler (/debugger/src/cpus/tms0800.js) decodes the 11-bit instruction word: a 2-bit class field, a 5-bit opcode and a low 4-bit mask/constant index (or a 9-bit branch target). Because the shared disasm view truncates the reader to 8 bits, the decoder reads the true 11-bit word through EMU_BOOT.peek, exactly as the LMC decoder does for its wider words.

Architecture

The Sinclair Cambridge (introduced August 1973) was the cheapest pocket calculator of its day, built around a single Texas Instruments calculator-on-a-chip:

  • TMS-0801 — a member of TI's TMS0800 four-function calculator-chip series: a 4-bit serial-BCD processor with just three 11-nibble datapath registers (A, B, C), two 11-bit flag registers, a 9-bit program counter and a 320-word ROM. There is no subroutine call and no scratch RAM.
  • Instruction word — 11 bits, one word per address, every instruction one cycle. A 2-bit class field picks register-ALU ops (add / subtract / compare / shift / copy under a word-select mask), flag and key-scan / control ops, or conditional branches on the single carry latch. Arithmetic is done one BCD digit at a time, gated by a word-select mask so one register can hold several packed fields (mantissa, exponent, sign).
  • Beyond the ROM, three Programmable Logic Arrays configure the chip like microcode: the ALU opcode map, the word-select (mask) table and the constant table. This emulator runs all three.
  • Display — an 8-digit-plus-sign red LED panel driven straight from register A, with register B marking the decimal-point position.
  • Veniamin Ilmer optically decoded the ROM and PLAs bit-by-bit from a photograph of the chip die in 2024; this simulator runs that exact recovered microcode. It builds on Ken Shirriff's earlier reverse engineering of the closely related TMS0800 used in the Sinclair Scientific.