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.
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- program, translated directly from Kilburn's 1948 notebook, loaded and executed in full. Produces the correct answer: 131,072 ().
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+.