Skip to content

Savage & Drake (1967): AGC Basic Training Manual

R-393 tells you what the Apollo Guidance Computer is. E-2052 tells you how to program it. Hopkins, Alonso, and Blair-Smith wrote the architecture specification for computer designers. Savage and Drake wrote the training manual for the people who would actually write the flight software — the engineers who built COLOSSUS and LUMINARY.

This is a teaching document, approved by E.M. Copps Jr. (group leader of Apollo guidance software), David G. Hoag (G&N program director), and Ralph R. Ragan (deputy director of the Instrumentation Laboratory). Its existence tells us something important: MIT IL did not assume that smart engineers could figure out the AGC on their own. There was a formal training pipeline. New programmers studied this manual before they touched flight code. The quality of Apollo software was cultivated, not accidental.

E-2052 covers the Block II AGC — the version that flew to the Moon — and it documents two distinct programming languages that lived on the same 15-bit machine.

The AGC had, in effect, two instruction sets:

PropertyBasicInterpretive
DesignerHugh Blair-SmithCharles Muntz
Instructions8 opcodes + ~15 extracodes~40 operations
Precision15 bits (single)30 bits (double)
ArithmeticInteger, ones complementFixed-point, scaled fractions
SpeedNative hardware~5x slower than Basic
Code densityBaseline~3x more compact than Basic
Used forExecutive, I/O, time-critical loopsGuidance equations, navigation

Basic is the assembly language — direct hardware instructions. Eight three-bit opcodes plus a set of “extracodes” accessed through the INDEX 5777 prefix. Every instruction the hardware can execute is a Basic instruction.

Interpretive is a virtual machine. The programmer writes TC INTPRET to enter the interpreter, which then fetches and executes its own instruction stream using Basic operations underneath. A vector cross product in interpretive code might cost hundreds of microseconds, but it occupies a fraction of the memory that the equivalent Basic code would require.

This is arguably the first practical use of a bytecode interpreter on a flight computer. The motivation was not abstraction — it was memory. With 36,864 words of core rope for the entire spacecraft, the guidance equations simply would not fit in native assembly. The interpreter traded the one resource the AGC had (time between guidance cycles) for the one resource it did not (program memory).

Section I: Basic — The Hardware Language

Section titled “Section I: Basic — The Hardware Language”

E-2052 documents the Block II AGC, which tripled the fixed memory and doubled the erasable memory compared to the Block I described in R-393:

RegionAddresses (Octal)SizeAccess
Unswitched erasable0000—0377256 wordsAlways visible
Switched erasable0400—07778 banks × 256Via EB register
Common fixed2000—37771,024 wordsAlways visible (“fixed-fixed”)
Fixed switchable4000—777736 banks × 1,024Via FB register

Total erasable: 2,048 words. Total fixed: 36,864 words.

The 12-bit address field directly addresses only 4,096 locations. Everything else requires bank switching. E-2052 teaches programmers the bank-crossing protocols — TC BANKCALL, TC POSTJUMP, the CADR (Complete Address) format — as core skills, not advanced topics. These are the first things a new AGC programmer had to learn after the instruction set itself.

The first 62 addresses in erasable memory are not general storage — they are hardware registers. E-2052 walks through each one:

RegisterAddressWidthFunction
A000016 bitsAccumulator (extra bit for overflow detection)
L000115 bitsLower product / second word of double-precision pair
Q000215 bitsReturn address (saved by TC)
EB000315 bitsErasable bank selector (bits 9—11)
FB000415 bitsFixed bank selector (bits 11—15)
Z000515 bitsProgram counter
BB000615 bitsBoth banks (EB + FB combined)
ZERO0007Hardwired to +0

The accumulator is one bit wider than memory. This is how the AGC detects overflow: bits 15 and 16 of A disagree when an addition has overflowed the 15-bit word. The TS instruction checks this condition and skips the next instruction on overflow, providing a branch-on-overflow without a dedicated test opcode.

The eight basic instructions are the same as R-393 documents for Block I: TC, CCS, INDEX, XCH, CS, TS, AD, MASK. E-2052 teaches each one with worked examples — what happens to the accumulator, what happens to the source word, what happens to the program counter.

The Block II addition is the extracode mechanism. The instruction INDEX 5777 (octal) sets a hardware flag that causes the next instruction to be decoded from an alternate table. This doubles the effective opcode space without changing the 3-bit opcode field:

ExtracodeOperation
MPMultiply (hardware in Block II — was a subroutine in Block I)
DVDivide (hardware in Block II)
SUSubtract
BZFBranch on zero (handles both +0 and -0)
BZMFBranch on zero or minus
QXCHExchange Q with memory
LXCHExchange L with memory
DXCHDouble exchange (A,L pair with two memory words)
DCADouble clear and add
DCSDouble clear and subtract
AUGAugment (increment magnitude by 1)
DIMDiminish (decrement magnitude toward zero)

The promotion of multiply and divide from subroutines to hardware instructions was one of the most significant Block I to Block II changes. A multiply that took ~800 μs as a subroutine on Block I executed in a few memory cycles on Block II.

E-2052 devotes considerable attention to ones complement arithmetic — specifically, to the fact that there are two representations of zero. Positive zero is 15 zero bits. Negative zero is 15 one bits. They are numerically equal but not bitwise identical.

This matters because CCS (Count, Compare, and Skip) branches to one of four locations: the operand is positive, positive zero, negative, or negative zero. A programmer who writes a loop termination test using CCS must handle all four cases or risk an infinite loop on one flavor of zero.

The manual also teaches the “corrected difference” — the value CCS actually leaves in A is the absolute value of the operand minus one. This is not a side effect; it is the designed behavior, optimized for countdown loops where you want to decrement and test in a single instruction.

Section II: The Interpreter — Virtual Double Precision

Section titled “Section II: The Interpreter — Virtual Double Precision”

The interpreter is where the guidance equations live. Navigation computations require double-precision trigonometry, vector rotations, and matrix operations — none of which the Basic instruction set can express directly. The interpreter provides all of this in a compact instruction format.

Interpreter instructions use 7 bits of opcode and 7 bits of address, packed two per 15-bit word. This is entirely different from Basic’s 3+12 format. The interpreter maintains its own state: a multi-precision accumulator (MPAC), its own program counter, and index registers for address computation.

CategoryOperations
ArithmeticDAD, DSU, DMP, DDV (double add, subtract, multiply, divide)
TrigonometricSIN, COS, ASIN, ACOS (scaled fixed-point)
VectorDOT, VXV (cross product), UNIT (normalize), VXSC (vector-scalar multiply)
MatrixMXV (matrix-vector), VXM (vector-matrix), TRANSPOSE
Flow controlGOTO, CALL, RTB (return to Basic), BPL, BMN, BZE
Load/StoreVLOAD, DLOAD, SLOAD, STORE

Every operation uses fixed-point arithmetic with explicit scaling. There is no floating point. The programmer must track the binary point through every computation and insert scaling corrections where needed. A vector dot product, for example, produces a result whose scaling depends on the scaling of both input vectors — the programmer must know this and account for it.

The interpreter runs approximately 5x slower than equivalent Basic code but occupies roughly a third of the memory. For guidance equations that execute once per navigation cycle (typically once per second or once per two seconds), the speed penalty is negligible. The memory savings are not.

Consider: the entire AGC had 36,864 words of fixed memory for guidance, navigation, autopilot, display routines, the executive, the interpreter itself, and every other function aboard the spacecraft. The interpreter let the guidance engineers write their equations in something resembling mathematical notation — load a vector, cross it with another vector, take the arcsine — while the time-critical code (the executive, the digital autopilot, the I/O handlers) stayed in native Basic where every microsecond mattered.

This separation — native assembly for real-time code, interpreted bytecode for computational code — is a pattern that recurs in every embedded system that faces the same constraint. The AGC just got there first.

E-2052 was planned as two volumes. Only Volume I survives:

VolumeSectionStatus
II — AGC Programming (Basic)Present
III — The InterpreterPresent
IIIII — The ExecutiveMissing
IIIV — SUNDISK and SUNDANCEMissing

The missing Volume II would have documented the real-time executive — the priority-driven scheduler, the waitlist, restart protection, the mechanisms that saved Apollo 11 during the 1202 alarms. It would also have documented the actual mission programs. Whether Volume II was never completed or simply never scanned is unknown.

R-393 describes the executive at the architectural level. E-2052 Volume I teaches the instruction set and the interpreter. The gap between them — a practitioner’s guide to writing code that works with the executive — remains unfilled in the surviving literature.