ArticlesProjectsWeeklyCredentialsAbout

TMC #0013: Manchester Baby: SSEM Stored-Program Simulator

A pure-Python simulator of the 1948 Small-Scale Experimental Machine (SSEM): all 7 original instructions, 32-word memory, and the first program ever run on a stored-program computer: finding the highest factor of 2^18.

manchester-babyssemstored-programsimulatorcomputer-historypython

On 21 June 1948, a 32-word machine in a Manchester stable ran 17 instructions and found the highest factor of 262,144. This simulator faithfully recreates that machine and reproduces that exact first run.

What It Includes

SSEM class: Complete simulator: 32 × 32-bit word memory (LSB-first encoding as on the original hardware), accumulator, current instruction register, and a fetch-decode-execute cycle implementing all seven opcodes (JMP, JRP, LDN, STO, SUB, CMP, STP).

Original first program: The 17-instruction highest-factor-of-2182^{18} program, translated directly from Kilburn's 1948 notebook, loaded and executed in full. Produces the correct answer: 131,072 (=217= 2^{17}).

Step trace: Optional verbose mode prints each instruction fetch, decoded opcode, and register state: letting you follow the machine's logic exactly as Kilburn and Williams would have read it from the CRT.

Instruction assembler: A minimal assembler that parses SSEM mnemonics (LDN 5, STO 12, CMP) into 32-bit machine words with correct bit layout for loading into the simulator.

Running It

python ssem_sim.py                   # run original first program, print result
python ssem_sim.py --trace           # step-by-step register trace
python ssem_sim.py --n 131072        # find highest factor of a different number

No external dependencies: pure Python 3.10+.

Source code
# TMC #0013 — Manchester Baby: SSEM Stored-Program Simulator

Companion code for [The Thinking Machine Chronicles #0013](/articles/tmc-0013-manchester-baby).

Simulates the 1948 Small-Scale Experimental Machine with all 7 opcodes, correct indirect-JMP semantics, and a working divisibility kernel that finds the highest factor of any integer.

## Usage

```bash
python ssem_sim.py                  # all demos
python ssem_sim.py --trace          # step-by-step register trace
python ssem_sim.py --demo divisor   # divisibility test only
python ssem_sim.py --demo factor    # highest-factor search only
```

Pure Python 3.10+, no external dependencies.