Hamilton at MIT in 1969 beside printed Apollo software listings produced by her and the team. These are program listings, not a stack of punch cards or code written by one person. Source: NASA / MIT Instrumentation Laboratory. Public domain; license record. Select the photo to enlarge it.
The engineer behind the photograph
Margaret Hamilton is a computer scientist and software engineer who led the Software Engineering Division at MIT’s Instrumentation Laboratory. Her team developed onboard flight software for NASA’s Apollo program, including the command module and lunar module. She helped popularize the term software engineering: programs deserved the same careful design and scrutiny as physical machines. NASA’s account of her work.
The photograph makes the work look enormous because it was. But the achievement was more than writing instructions. Engineers had to decide how programs interacted, detect failures, test difficult conditions, and recover without losing essential work.
Your mission
Explain how guidance software connects sensor readings to spacecraft control.
Use evidence to explain why priority and recovery matter under overload.
Describe Hamilton’s contribution while recognizing the larger Apollo team.
A computer has only so much time
Imagine a computer that can perform 10 units of work per cycle. Steering needs 3, attitude control needs 2, and a routine display needs 3. Radar interrupts also consume time. Can every job finish before the next cycle?
Predict first: With a radar burst, will processing the routine display first leave enough time for both essential jobs? Compare the two policies using the same radar load.
R = radar · G = guidance · A = attitude control · D = display · — = spare time
Work completed in the latest cycle
Task
Needed
Completed
Result
Ready. Choose a policy, predict an outcome, then run or step through eight cycles.
How this classroom model differs from Apollo
These task sizes, orders, eight cycles, and landing animation are invented for learning. Radar time is consumed first; the selected policy then allocates remaining time to whole or partial jobs. A missed essential deadline stops this model. Work does not carry between cycles.
The real AGC used interrupts, an Executive, a Waitlist, limited job-storage areas, and restart protection. It did not use these ten slots or these three task priorities. This model illustrates resource limits and protecting essential work; it does not emulate the AGC, reproduce alarm timing, or predict a real landing.
Three experiments
Compare: Run both policies at Burst. Record the essential deadlines missed and the display work completed.
Control one variable: Keep Protect essential tasks and change Burst to Normal. What happens to display work and recovery events?
Find the limit: Try Extreme with protection. Explain why changing priorities cannot create more computing time.
Your completed experiment results (kept while this page is open)
Policy / load
Outcome
Missed deadlines
Recovery events
Complete a run to collect evidence.
What did the guidance software actually do?
Navigation
Estimate where the spacecraft is and how it is moving, using measurements.
→
Guidance
Calculate how the current path should change to reach the target.
→
Control
Command the spacecraft’s orientation and engines to follow that path.
The software had to repeat these calculations while responding to instruments and astronaut commands. Real-time means a result must arrive when it is needed. A correct steering instruction that arrives too late is not useful.
Apollo programs used assembly language and an interpretive language for calculations. Assembly instructions closely follow the computer’s operations, so programmers had to manage details such as memory addresses. Much of the flight program was stored in core-rope memory, physically encoded by wires passing through or around magnetic cores. NASA’s technical account and NASA on Apollo programming.
Read the idea before reading assembly
This is teaching pseudocode, not Hamilton’s original code. Follow it with the Burst workload: what would change if display work came before the essential tasks?
for each cycle:
time_left = 10 - radar_work
for task in [guidance, attitude, display]:
completed = min(task.work_needed, time_left)
time_left = time_left - completed
if completed < task.work_needed:
report_unfinished(task)
if an essential task is unfinished:
report_unsafe_to_continue()
else if display is unfinished:
report_recovery_and_continue()
In this model, the list order represents a design choice. In Apollo, the team designed a much richer system to coordinate jobs and restart protected work. An alarm and a recovery mechanism had to be designed before they were needed.
Explore authentic Apollo source listings
Read the digitized Apollo 11 source, transcribed from MIT Museum listings by the Virtual AGC project and contributors. Comanche055 is command-module software; Luminary099 is lunar-module software. Start with the comments in Luminary’s Executive. Identify a comment, a symbolic name, and an instruction. This is team-authored flight software; do not assume Hamilton wrote every line.
What language did Apollo’s code use?
The onboard flight software was written in Apollo Guidance Computer (AGC) assembly language, with sections in AGC interpretive language. These were designed for Apollo’s computer. Hamilton led software work within the MIT team; the examples below are team-authored listings, not lines attributed individually to her.
Basic instructions
Short names such as CA, TS, and TC represent operations the AGC’s processor can perform. “Basic” here means native instructions, not the programming language BASIC.
Interpretive instructions
For mathematical work, the program could call an interpreter: software that carried out operations such as loading a vector. This made complex calculations more compact, at the cost of extra execution time.
The assembler
YUL, and later GAP, translated source listings into machine words. An assembler is a tool, not a separate onboard language. yaYUL is the modern reconstruction tool named in the digitized files.
A label names a location. The operation says what to do. The operand names a value or destination. A comment explains the code to people. In these modern transcriptions, # introduces comments. OCT tells the assembler to encode an octal (base-eight) constant; it is not an instruction that the processor executes.
Octal matters:1202 in these listings is base eight: 1 × 8³ + 2 × 8² + 0 × 8 + 2 = 642 in decimal. Apollo’s familiar “1202” alarm designation uses those octal digits.
CAF means “Clear and Add Fixed”; TS means “Transfer to Storage.” CAF TWO loads the constant 2 into the A register, the processor’s accumulator. The two TS instructions store that value in named memory locations. Nearby comments identify phase 2 as vertical landing.
The idea in modern notation is WCHPHOLD = 2; WCHPHASE = 2;. Those words are our translation of the idea, not Apollo syntax.
LUNLAND TC PHASCHNG
OCT 00035
TC PHASCHNG
OCT 05023
OCT 21000
TC means “Transfer Control.” Here it calls the phase-change routine. The following OCT words supply parameters to that routine. Original comments say the first call retains a task associated with accelerometer readings, and the second protects guidance and sets its priority.
This is a concrete link to reliability: the program explicitly arranges how work is protected. These five lines call supporting machinery; they do not contain the entire recovery system.
This sequence occurs after the Executive cannot find a free core set, a work area for a job. CA Q copies the Q register into A, preserving caller information before the next transfer. TC BAILOUT1 transfers control to the bailout routine; the next word provides the octal alarm code.
OCT 1202 is data read by the routine, not a command meaning “display 1202.” Elsewhere, a similar path supplies 1201 when no vector-accumulator (VAC) work area is available.
TC INTPRET enters the software interpreter. VLOAD loads the vector named UNIT/R/ into its working accumulator, and STORE writes it to UNWC/2. A vector has several components, so one mathematical operation can represent several machine-level steps.
EXIT returns to native instruction execution. The next line in the full listing transfers to STEER?. The operand on its own line is part of the listing’s syntax; it is not a missing instruction.
Choose an excerpt and watch which value or control state changes. This is an explanatory walkthrough, not an AGC emulator. It omits binary encoding, memory banks, numerical scaling, and overflow behavior.
Illustrative state
Choose an example, predict what changes, then select Next code step.
Try reading it yourself
In the phase example, what value goes into WCHPHASE? Which line puts it there?
In the alarm example, why is OCT 1202 data rather than the next processor operation?
In the vector example, which lines enter and leave the interpreter?
Check your answers
1. The value is 2; TS WCHPHASE stores it. 2. OCT creates a constant, and the bailout routine consumes that word as a parameter. 3. TC INTPRET enters; EXIT leaves.
July 20, 1969: alarms during descent
Eagle descends. Neil Armstrong and Buzz Aldrin approach the lunar surface while the guidance computer works.
1202 and 1201 alarms appear. These are Executive overflow alarms: the computer cannot accommodate all the requested jobs in its available working storage. Unexpected activity from the rendezvous radar interface consumes computing time and contributes to the overload.
The software recovers. Restart protection reestablishes essential work. The alarms report the problem; the computer continues providing guidance rather than simply freezing.
People assess the evidence. Guidance officer Steve Bales and computer specialist Jack Garman help Mission Control judge that the landing can continue. Armstrong and Aldrin still have to fly the spacecraft.
Hamilton’s leadership and work on dependable software are central to this story. MIT engineer Hal Laning devised the priority-based Executive. Many programmers, hardware engineers, testers, astronauts, and controllers contributed to the landing. MIT’s history identifies these contributions.
Hamilton later described watching the software detect the overload and recover during descent. She was monitoring the mission at MIT, not writing a last-minute fix aboard Eagle. Read Hamilton’s own recollection.
Think like a software engineer
A program should be tested against what might go wrong, as well as what should go right. Hamilton’s Apollo experience made reliability, interactions between systems, and error recovery part of the engineering problem.
Design a test for a school delivery robot
A robot must avoid obstacles, steer toward a destination, and update a decorative screen. Its obstacle sensor suddenly sends many more readings.
Identify which tasks have essential deadlines. Explain your choices.
Describe a normal test and an overload test. State the expected behavior before running either.
Decide what warning a person should see and when the robot should stop.
Explain what evidence would show that recovery worked.
Extension: Add a save-and-resume checkpoint to the pseudocode. Which state must be preserved? What would go wrong if a restart repeated an action that should happen only once?
Teacher guide and discussion prompts
Allow 5 minutes for the photograph and prediction, 12 for paired experiments, 10 for code and history, 10–15 for the authentic-code walkthroughs, and 8–15 for a test plan and exit ticket. No programming experience or account is required. Students can use Next cycle throughout; the animation is optional.
Expected model results: Normal completes all jobs under either policy. Burst with display first misses two essential deadlines in its first cycle. Burst with protection completes eight cycles, defers all display work, and records eight recovery events. Extreme misses essential deadlines even with protection. These are model results, not Apollo measurements.
Ask: Which variable did you hold constant? Does recovery mean nothing went wrong? Why might a computer report a problem while still doing useful work? For older students, distinguish task priority from deadline, CPU time from job-storage capacity, and restart protection from rebooting an entire machine.
Check your thinking
1. What does the famous photograph show?
2. Why could the landing continue after the alarms?
3. What does the Extreme experiment teach?
Exit ticket
Explain how planning for failure helped Apollo succeed. Use one observation from the lab and one historical fact. Include the difference between Hamilton’s leadership and the team’s work.