Search › A-Z › A › Apollo Guidance Computer
Apollo Guidance Computer
The Apollo Guidance Computer (AGC) was the flight computer designed at the MIT Instrumentation Laboratory for NASA's Apollo program. One AGC flew in each Command Module and each Lunar Module, guiding the missions that landed astronauts on the Moon. It is a 15-bit, one's-complement machine, and the crew talked to it through the DSKY, a display and keypad driven by VERB and NOUN codes.
This online build runs the real Colossus 249 flight rope on the Virtual AGC engine (yaAGC), compiled to WebAssembly via MoonJS, with the DSKY drawn in the browser.
Runs on: Web browser
Apollo Guidance Computer Online Emulator
Play Apollo Guidance Computer using JavaScript directly in your browser.
Controls
Configurations
| Configuration | Emulator | Machine | OS | Legal | |
|---|---|---|---|---|---|
| Apollo Guidance Computer · Colossus 249 | Apollo Guidance Computer | Apollo Guidance Computer | open | Open ⛶ |
Machines emulated
Chips
Notes
Embedding
The Apollo Guidance Computer core is MoonJS - the Virtual AGC engine (yaAGC) compiled from C to WebAssembly with Emscripten. It is vendored as one self-contained agc.js (the wasm is inlined and the Colossus 249 core rope, Core.bin, is embedded), so there are no runtime fetches to self-host.
Boot. The module factory instantiates the engine, runs agc_engine_init() with the rope, then we own a loop that runs the core and pumps the DSKY:
const M = await createAGC();
const advance = M.cwrap('advance', 'number', []); // run the AGC for 10 ms
const sendPort = M.cwrap('sendPort', 'number', ['number','number']); // key -> input channel 015
const scanPort = M.cwrap('scanPort', 'number', ['number']); // DSKY relays (chan 010/011/013)
(function loop(){
advance(); // 935 AGC instructions
let d; while ((d = scanPort(0xB00))) drawRelay(d); // paint the seven-seg + lamps
requestAnimationFrame(loop);
})();
The DSKY is the screen. The astronaut interface is a set of seven-segment displays (PROG, VERB, NOUN and the three signed 5-digit registers R1–R3), indicator lamps, and a keypad. The engine drives it entirely through output channels 010, 011 and 013, whose relay words we decode and paint onto a <canvas>; key presses go the other way into input channel 015 (and channel 032 bit for PRO).
Debugger integration
MoonJS ships as headless C, so to drive it from the shared debugger we compiled it with a small extra shim (added to main.c) that exposes the AGC's internals. The whole machine state is one C struct, so this is cheap:
| Export | What it does |
|---|---|
agcStep() | Run exactly one AGC instruction (calls agc_engine once); returns the new program counter Z. The single-step primitive. |
agcReg(i) / agcSetReg(i,v) | Read / write a central register. A, L, Q, EB, FB, Z, BB live at Erasable[0][0..6]. |
agcEras(b,o) / agcFixed(b,o) | Read one 15-bit word of erasable RAM (8×256) or fixed rope (banked). Side-effect-free. |
agcPCLinear() | The linear rope index of the word Z points at, mirroring the AGC's bank logic (FB field + channel-07 superbank), so the disassembly follows the program counter across bank switches. |
On top of these the boot shim publishes window.EMU_BOOT with a full transport: pause / resume / isPaused, stepInsn(n) (one instruction), step(n) (frames), plus breakpoints (rope program-counter values the stepper checks before each instruction) and watchpoints (erasable addresses checked for change after each instruction). When nothing is armed the loop free-runs with advance(); when a breakpoint or watchpoint is set it single-steps with agcStep(). A dedicated decoder, /debugger/src/cpus/agc.js, disassembles each 15-bit word into native octal mnemonics: the basic set (TC CCS TCF CA CS AD MASK TS XCH INDEX DAS …) and, when the preceding word is EXTEND, the extracode set (DV MP SU DCA DCS BZF BZMF QXCH AUG DIM and the channel I/O READ WRITE RAND WAND ROR WOR RXOR).
Architecture
The AGC (Block II, 1966) was designed at the MIT Instrumentation Laboratory and flew on every Apollo Command and Lunar Module. It is a 15-bit, one's-complement machine clocked at about 85 kHz.
- Word & registers: 15-bit words (plus a parity bit). The central registers, accumulator A, lower product L, return Q, program counter Z, and the bank registers EB / FB / BB, are the first words of erasable memory, addressed like any other location.
- Memory: 2K words of erasable core (RAM, 8 banks of 256) and 36K words of fixed core-rope (ROM, banked), woven by hand for each mission. This build runs Colossus 249, the Command Module rope.
- Instruction set: a small set of basic opcodes (TC, CCS, CA, CS, AD, MASK, TS, XCH, INDEX, DAS…) doubled by an
EXTENDprefix into extracode instructions (MP, DV, SU, DCA, DCS, BZF, BZMF and the channel I/O ops). - DSKY: the display-and-keyboard unit, the crew's whole interface, driven over I/O channels. Programs are selected as VERB/NOUN pairs.
Because the emulator's entire state is one C struct with word-addressable registers and memory, the debugger single-steps it, reads and writes registers and memory in octal, disassembles the rope, and enforces breakpoints and watchpoints host-side, with no change to the yaAGC core beyond the accessor shim.