Skip to content
0 / 17
Pre-launch Review

Reading the Apollo Code

The source code preserved in this archive is among the most consequential software ever written. It ran on the Apollo Guidance Computer (AGC) — a machine built at MIT’s Instrumentation Laboratory under the technical direction of Margaret Hamilton — and it guided humans to the Moon and back.

Two complete programs are included here: Comanche055 for the Command Module and Luminary099 for the Lunar Module. Both were assembled on July 14, 1969 — six days before the first lunar landing.

The AGC Block II was, by any measure, a constrained computer. Understanding its limits makes the achievement of the software that much more striking.

SpecificationValue
Word size15 bits (plus parity)
Fixed memory (ROM)36,864 words (~72 KB)
Erasable memory (RAM)2,048 words (~4 KB)
Clock speed2.048 MHz (one instruction per ~11.7 microseconds)
Weight70 lbs
Power consumption55 watts

Fixed memory was literally woven by hand — women in factories threaded copper wire through or around tiny magnetic cores to encode each bit. This is why it was called core rope memory. A wire passing through a core was a 1; bypassing it was a 0. Once woven, the program could not be changed.

Erasable memory used conventional magnetic core storage, but only 2,048 words of it. Every byte mattered. The entire software team shared this space across the Executive, the Waitlist, guidance equations, the autopilot, and the display system.

AGC assembly uses a fixed instruction set with some conventions that look unusual to anyone accustomed to modern architectures.

The AGC had a small set of working registers:

  • A (Accumulator) — the primary register for arithmetic and logic
  • L — the lower half of a double-precision pair, or used independently
  • Q — return address register (set by TC instructions)
  • Z — the program counter
  • BBANK / FBANK — bank selection registers for accessing different regions of memory

A handful of instructions do most of the work:

TC LABEL # Transfer Control (subroutine call). Sets Q = return address.
CA REGISTER # Copy register/memory into A
CS REGISTER # Copy the complement into A
AD REGISTER # Add to A
TS REGISTER # Transfer (store) A to a register
CCS REGISTER # Count, Compare, and Skip — a four-way branch
INDEX REGISTER # Modify the next instruction's address by the value in REGISTER
EXTEND # Prefix for "extended" instructions (multiply, divide, I/O)

Astronauts communicated with the AGC through the DSKY (Display/Keyboard) using a two-number system: Verbs specified actions, Nouns specified data. For example:

  • Verb 06, Noun 63 — Display altitude, altitude rate, and lateral velocity
  • Verb 37 — Change major program
  • Verb 16, Noun 68 — Monitor range to landing site

This interface was originally built as a quick demo to impress visitors to the Instrumentation Lab. Nobody planned for it to survive into the flight software. It did.

The AGC could only address a limited window of memory at once. Programs were stored across numbered banks, and the code constantly switches between them using BANK, SETLOC, and BANKCALL instructions. This bank-switching is one reason the code can look dense — a great deal of bookkeeping is spent just moving between memory regions.

The Command Module computer managed navigation, guidance during translunar and transearth coast, and reentry. Comanche055 is the software that brought the crew home.

The Lunar Module computer handled everything related to the descent and ascent: landing guidance equations, engine ignition sequencing, the autopilot, abort monitoring, and rendezvous. Luminary099 is the software that landed on the Moon — and the software whose Executive kept running when the 1202 alarms fired during descent.

Most of the famous routines explored in this archive come from Luminary099.

The following pages are annotated guides to the most interesting parts of the Apollo 11 source code — the routines with the best stories, the comments that reveal the engineers’ personality, and the code that mattered most at the critical moment.

The source code in this archive exists because of the Virtual AGC project, led by Ron Burkey. The project recovered the original AGC source from hardcopy printouts held at the MIT Museum, transcribing thousands of pages of assembly code by hand. Paul Fjeld performed the digitization of the MIT Museum’s printout, and Deborah Douglas of the Museum arranged access.

The result is a faithful digital reconstruction of the code that was assembled at 16:27 on July 14, 1969 — the date stamped on every source file in the archive. The Virtual AGC project also produced yaYUL, an assembler capable of rebuilding the original binaries, and a full AGC emulator that can run the flight software.

The complete source is available at ibiblio.org/apollo and on GitHub.