Search › A-Z › I › Intel 4004 (Busicom 141-PF)
Intel 4004 (Busicom 141-PF)
This is a from-scratch, in-browser emulator of the Busicom 141-PF - the first calculator built around a microprocessor, driven by a faithful JavaScript re-implementation of the Intel 4004, the world's first commercially produced microprocessor (1971). It models the whole MCS-4 board: the 4004 CPU, five 4001 ROMs holding the calculator firmware, two 4002 RAMs and three 4003 shift registers, plus the mechanical drum printer and the scanned keypad. The 141-PF has no digital display. Watch the drum printer strike the paper tape.
Because the entire machine is plain JavaScript, it plugs into the shared debugger: single-step the 4004, set breakpoints, and inspect every register and memory nibble live.
Behavioural reference project ↗
Runs on: Web browser
Intel 4004 (Busicom 141-PF) Online Emulator
Play Intel 4004 (Busicom 141-PF) using JavaScript directly in your browser.
Controls
Configurations
| Configuration | Emulator | Machine | OS | Legal | |
|---|---|---|---|---|---|
| Busicom 141-PF (12 + 34 =) | Intel 4004 (Busicom 141-PF) | Busicom 141-PF | grey | Open ⛶ | |
| Busicom 141-PF (keypad) | Intel 4004 (Busicom 141-PF) | Busicom 141-PF | grey | Open ⛶ |
Machines emulated
Chips
Notes
Embedding
There is no upstream runtime to vendor here. The Intel 4004 core is written from scratch as three plain-global JavaScript modules, loaded in order:
// 1. the ROM image, 2. the MCS-4 chip set, 3. the Busicom harness
<script src="busicom-rom.js"></script> // window.BUSICOM_ROM: 1280 bytes (5x 4001)
<script src="mcs4.js"></script> // window.MCS4: CPU/ROM4001/RAM4002/Shifter4003/Board
<script src="busicom.js"></script> // window.Busicom: printer + keypad + loop
Boot. Construct the machine on a <canvas> and run your own loop. One refresh() is a 16 ms burst of ~1481 machine cycles followed by the printer drum step; you own it, so the debugger can pause and step it:
var m = new Busicom(canvas, BUSICOM_ROM, { demo: demoKeys });
(function loop(){
for (var i = 0; i < m.speed; i++) m.refresh(bps); // bps = breakpoint Set
m.render();
requestAnimationFrame(loop);
})();
The machine is plain objects No wasm heap, so the debugger reaches everything directly:
| Member | Kind | What it does |
|---|---|---|
m.board.runCycle() | method | Run exactly one 4004 machine cycle (fetch + execute). Two-byte instructions take two cycles. |
m.stepInsn(n) | method | Run n whole CPU instructions, the debugger's single-step primitive. |
m.board.cpu | field | Live 4004 state: acc, carry, test, pc, regs (R0..R15), stack. |
m.board.roms[i] | field | The five 4001 ROMs: .data (256 bytes) and .ports (the 4-bit I/O port wired to keypad / printer). |
m.board.rams[i] | field | The two 4002 RAMs: .chars / .status nibbles and .ports (drives the printer hammers and LEDs). |
m.press(scan) | method | Queue a keypad scan code, how both the on-screen keypad and the physical keyboard inject presses. |
Debugger integration
The debugger plug-in (i4004-debug.js) reads window.EMU_BOOT and calls EmuKit.defineMachine. Because the whole machine is ordinary JavaScript, single-stepping is just m.stepInsn(1), registers are read and written straight off m.board.cpu, and execution breakpoints are a host-side Set the loop checks against the program counter at each instruction boundary.
A new i4004 disassembler (/debugger/src/cpus/i4004.js) decodes the 4004's 8-bit opcodes, a high nibble (operation) and low nibble (register / condition / immediate), flagging the five two-byte instructions (JCN, FIM, JUN, JMS, ISZ) and rendering everything else as one byte.
Architecture
The Busicom 141-PF was the calculator the 4004 was designed for. This emulator models the whole MCS-4 board that shipped inside it:
4004- the 4-bit CPU: a 12-bit program counter, a 4-bit accumulator and carry, sixteen 4-bit index registers (R0..R15) and a 3-level address stack. Instructions take 8–16 clocks (10.8–21.6 µs).4001×5, 256-byte ROM chips holding the 1280-byte calculator firmware, each with a 4-bit I/O port. Those ports scan the keypad and clock the printer.4002×2 - RAM chips (registers + status nibbles) with output ports that fire the printer hammers and light the status LEDs.4003×3, 10-bit shift registers: one scans the keypad matrix, two cascade to select which of the 18 printer columns the hammers strike.- Printer, a rotating drum of 13 character bands. The firmware spins the drum and fires the hammers as the wanted character passes, printing a number one column at a time onto the paper tape.
The 4004 core is a faithful re-implementation (ported behaviour-for-behaviour from the veniamin-ilmer Rust MCS-4 model), which is exactly what makes it a clear debugging target: every nibble of state is visible and steppable.