72KB of Code That Reached the Moon
The Apollo Guidance Computer had less memory than a favicon. Its source code is public domain. I opened every file.
The video version · same thesis, looser edits
72 kilobytes. That was the budget.
The Apollo Guidance Computer ran at 2 MHz. It had 72KB of ROM and 4KB of RAM. Your phone has sixteen hundred times more clock speed, seven million times more storage, and three million times more working memory. The AGC had none of the things we take for granted: no floating-point unit, no linker, no debugger, no compiler warnings. And yet this machine guided three men to the Moon and back. Twice per second, every second, for eight days.
The source code that ran on that machine is now public domain, hosted on GitHub, digitized from paper printouts at the MIT Museum by Ron Burkey and Paul Fjeld. It ships as two directories: Comanche055 for the Command Module (85 files, 65,348 lines) and Luminary099 for the Lunar Module (90 files, 64,838 lines). This is the code that actually flew.
I opened every file. What follows is a technical review.
The build system that wasn’t
There is no Makefile. No package.json. No build graph. The entire Luminary099 program is assembled through a single file: MAIN.agc. It contains nothing but $ directives, each one pulling in another source file, each one annotated with the page number from the original NASA hardcopy:
$ASSEMBLY_AND_OPERATION_INFORMATION.agc # pp. 1-27
$ERASABLE_ASSIGNMENTS.agc # pp. 90-152
$EXECUTIVE.agc # pp. 1103-1116
$WAITLIST.agc # pp. 1117-1132
$BURN_BABY_BURN--MASTER_IGNITION_ROUTINE.agc # pp. 731-751
$THE_LUNAR_LANDING.agc # pp. 785-792
$PINBALL_GAME_BUTTONS_AND_LIGHTS.agc # pp. 390-471
$ALARM_AND_ABORT.agc # pp. 1381-1385
Ninety files, assembled as one monolithic blob. No object files. No linking step. Every $ directive is the 1960s equivalent of inserting your deck of punch cards into someone else’s deck. The page numbers let you cross-reference every line against the original scanned documents at the MIT Museum. The engineers knew this code would need to be audited. They built traceability into the source format itself.
BURN_BABY_BURN: table-driven ignition
My favorite filename in the repository is BURN_BABY_BURN--MASTER_IGNITION_ROUTINE.agc. The comments trace the name back to Magnificent Montague, a Los Angeles disc jockey who shouted “Burn, baby! BURN!” when spinning records in the mid-1960s. Don Eyles, one of the two engineers who wrote and maintained this routine, confirmed the origin at the 40th anniversary celebration of the Moon landing.
The engineering is as interesting as the name. Every powered flight program on the Lunar Module (P12, P40, P42, P61, P63) calls into BURNBABY through the same entry point. The trick is a register called WHICH:
# THE MASTER IGNITION ROUTINE IS DESIGNED FOR USE BY THE FOLLOWING
# LEM PROGRAMS: P12, P40, P42, P61, P63.
# VARIATIONS AMONG PROGRAMS ARE ACCOMODATED BY MEANS OF TABLES
# CONTAINING CONSTANTS (FOR AVEGEXIT, FOR WAITLIST, FOR PINBALL)
# AND TCF INSTRUCTIONS. USERS PLACE THE ADRES OF THE HEAD OF THE
# APPROPRIATE TABLE IN ERASABLE REGISTER `WHICH' (E4). THE IGNITION
# ROUTINE THEN INDEXES BY WHICH TO OBTAIN OR EXECUTE THE PROPER
# TABLE ENTRY.
P12TABLE VN 0674 # (0)
TCF ULLGNOT # (1)
TCF COMFAIL3 # (2)
TCF GOCUTOFF # (3)
TCF TASKOVER # (4)
TCF P12SPOT # (5)
DEC 0 # (6) NO ULLAGE
Each program loads its own constants and callback addresses into WHICH, and the ignition routine indexes into those tables. It is a vtable. A dispatch table. A strategy pattern. In 1969, hand-coded in assembly, with Latin inscriptions in the comments:
# HONI SOIT QUI MAL Y PENSE
(“Shame on him who thinks evil of it.”)
# NOLI SE TANGERE
(“Touch me not.”)
These engineers had personality.
THE_LUNAR_LANDING: the code Armstrong overrode
THE_LUNAR_LANDING.agc is Program 63, the braking phase. This is what was executing when Neil Armstrong looked out the window, saw a boulder field at the designated landing site, and took semi-manual control to fly past it.
The file opens with FLAGORGY:
FLAGORGY TC INTPRET # DIONYSIAN FLAG WAVING
CLEAR CLEAR
NOTHROTL
REDFLAG
CLEAR SET
LRBYPASS
MUNFLAG
CLEAR CLEAR
P25FLAG # TERMINATE P25 IF IT IS RUNNING.
RNDVZFLG # TERMINATE P20 IF IT IS RUNNING
Yes, FLAGORGY is a real label in the code that landed humans on the Moon. The comment says “Dionysian Flag Waving.” It is the initialization section, clearing and setting the flags that control every life-or-death decision during descent: whether the engine fires, whether the landing radar is active, whether an abort is still possible.
Deeper in the file sits DDUMCALC, the iterative convergence algorithm that adjusts ignition timing. The math is dense: fixed-point arithmetic, manually scaled, with the decimal point tracked in the engineers’ heads across every variable:
# DDUMCALC IS PROGRAMMED AS FOLLOWS:-
# 2
# (RIGNZ - RGU )/16 + 16(RGU )KIGNY/B8 + ...
# 2 1
# DDUM = -----------------------------------------------
# 10
# 2 (VGU - 16 VGU KIGNX/B4)
# 2 0
No floating-point hardware. All of this runs on 15-bit words, with double precision manually managed across two words (28 bits of mantissa). The engineers chose scaling factors for each variable to maximize precision within those constraints.
The real-time operating system
The AGC was not just running landing math. It was running a full preemptive multitasking operating system, built from scratch, in assembly.
EXECUTIVE.agc is the priority-based job scheduler. Each job gets a priority number. When a higher-priority job enters the queue, the Executive suspends the current job, swaps all registers and the multi-purpose accumulator (MPAC), and dispatches the new one. The context switch is manual. Every register is saved and restored by hand:
CHANJOB INHINT
EXTEND
ROR SUPERBNK # PICK UP CURRENT SBANK FOR BBCON
XCH L # LOC IN A AND BBCON IN L.
INDEX NEWJOB # SWAP LOC AND BANKSET.
DXCH LOC
DXCH LOC
DXCH MPAC # SWAP MULTI-PURPOSE ACCUMULATOR AREAS.
INDEX NEWJOB
DXCH MPAC
DXCH MPAC
Seven core sets. Twelve registers per set. The scheduler scans all of them on every job change. There is no hash map, no heap, no linked list. Just a linear scan through fixed memory, because every byte matters.
WAITLIST.agc is the timer-driven task queue. The cron job of 1969. Tasks are scheduled by delta-time and fire on hardware interrupts.
INTERPRETER.agc is a virtual machine. It runs a higher-level interpretive language for complex math: vectors, matrices, trigonometry. The Interpreter executes pseudo-instructions that would be impossibly verbose in raw AGC assembly. It is 78,662 bytes of source, the largest file in the codebase.
PINBALL GAME BUTTONS AND LIGHTS
The DSKY (Display and Keyboard unit) interface is implemented in PINBALL_GAME_BUTTONS_AND_LIGHTS.agc. At 3,799 lines, it is the second-largest file. The astronauts communicated with the computer using a Verb-Noun system: type a two-digit verb code, then a two-digit noun code. Verb 06, Noun 43: display latitude and longitude. Verb 16, Noun 85: display the countdown to ignition.
The file opens with a Shakespeare quote:
# "IT WILL BE PROVED TO THY FACE THAT THOU HAST MEN ABOUT THEE THAT
# USUALLY TALK OF A NOUN AND A VERB, AND SUCH ABOMINABLE WORDS AS NO
# CHRISTIAN EAR CAN ENDURE TO HEAR."
# HENRY 6, ACT 2, SCENE 4
A 21st-century annotation by Ron Burkey corrects the citation: it is actually Henry VI, Part 2, Act IV, Scene VII.
The Verb-Noun interface was never meant to ship. Ramón Alonso, one of the original AGC developers, explained that it was thrown together for a demo to impress lab visitors. Nobody got around to replacing it. The coders argued (perhaps sophistically) that it was actually good. The astronauts hated it. Most of them wanted dials and switches. The coders won.
The 1202 alarm: graceful degradation
During the actual landing, the AGC started throwing 1202 and 1201 alarms. Executive overflow: too many tasks queued for the processor to handle. The alarm code lives in ALARM_AND_ABORT.agc, and the trigger is in EXECUTIVE.agc:
NEXTCORE CAF COREINC
ADS LOCCTR
CCS EXECTEM2
TCF NOVAC3
LXCH EXECTEM1
CA Q
TC BAILOUT1 # NO CORE SETS AVAILABLE.
OCT 1202
When all seven core sets are occupied and a new job arrives, the Executive calls BAILOUT1 with octal code 1202. But the critical insight is what did not happen: the computer did not crash. The priority scheduler shed low-priority tasks to keep guidance running. Navigation and landing equations kept computing. Steve Bales, the guidance officer in Mission Control, made the call: “We are GO on that alarm.”
The software saved the mission by gracefully degrading instead of failing.
The memory constraints
72KB of ROM. Hand-woven core rope memory that took weeks to manufacture at Raytheon. Each memory module was literally woven by hand: copper wires threaded through tiny magnetic cores. A wire through a core meant a 1. A wire around a core meant a 0. Once woven, the code was permanent. There were no patches in space.
4KB of RAM. Magnetic core memory with destructive reads. Every time you read a value, it was erased and had to be immediately rewritten.
No floating-point hardware. All navigation math (trigonometry, orbital mechanics, gravity compensation) done in fixed-point arithmetic with manually tracked scaling.
Bank switching: only 2KB of code were visible to the processor at any time. The rest was paged in and out through BANK and SETLOC directives that appear at the top of every file.
In those 72 kilobytes, they fit:
- A real-time operating system with priority scheduling
- Lunar landing guidance equations
- Stellar navigation and orbital integration
- An autopilot for RCS jets and engine gimbal control
- A complete display and keyboard interface
- A crash recovery system
72 kilobytes. Today, that is one website favicon. A single high-resolution emoji. About four tweets worth of text.
Why this matters right now
The same physics that constrained the AGC are constraining AI systems today.
Tesla’s FSD inference is limited by memory bandwidth, not compute. Fitting a 70-billion parameter model into 80GB of GPU VRAM requires the exact same optimization mindset the AGC engineers used in 1966. We use quantization (FP32 to INT4) to trade precision for memory. Apple’s M-series chips share unified RAM between CPU, GPU, and Neural Engine because architecture matters more than raw specs. Edge AI runs models in 6GB of phone RAM. The AGC had 4KB.
The hardware has changed by seven orders of magnitude. The physics of computing remain exactly the same: memory is finite, bandwidth is precious, and the engineers who understand the low level will always build better systems than those who do not.
The real legacy
Margaret Hamilton and her team at MIT wrote every line of this code by hand. No IDE. No autocomplete. No syntax highlighting. No AI pair programmer. Just printed listings, pencils, and brilliant minds. Hamilton coined the term “software engineering” because she believed software deserved the same rigor as hardware engineering.
She was right.
In 1969, engineers wove code into copper wires by hand. In 2026, AI agents write, test, and deploy code autonomously. The gap is fifty-seven years. But the fundamentals have not changed. Registers. Memory. Instructions. Control flow. It is all still there, underneath every abstraction layer we have built since.
The best code is not always the newest code. Sometimes it is the code that got humans home.