ProductSphere and the Apollo 11 Code: A Modernisation Case Study

ProductSphere mapped and documented Apollo 11’s flight software. Our engineers then rewrote one routine and tested it against the 1969 original.

What if your most critical legacy system were as difficult to understand as the software that took humans to the Moon?

Before an enterprise can safely modernise decades-old software, it must understand what the system does, why its components interact, and which behaviours cannot change.

Most large enterprises have learned this the hard way: 79% of IT leaders report a failed modernisation project, at an average cost of about $1.5 million and 16 months. The expensive part is rarely the rewrite. It is changing a system nobody fully understood, and finding out in production which behaviours mattered.

The enterprise version of the problem
800bn+lines of COBOL in production and daily use. 92% of respondents called their COBOL applications strategic.Vanson Bourne survey of 1,104 respondents, commissioned by COBOL vendor Micro Focus, 2022
75%of the US federal IT budget went on running and maintaining existing systems in fiscal 2015. Some were written in assembly, around 56 years earlier.US GAO-16-468, May 2016
79%of IT leaders at large companies reported a failed modernisation project, at an average of about $1.5 million and 16 months.vFunction and Wakefield Research, 2022
The COBOL figure comes from a survey commissioned by a COBOL vendor, Micro Focus. Every figure is linked under Sources below.

We used Apollo 11’s preserved flight-software repository to explore how ProductSphere approaches that challenge: understand the code, document its behaviour, modernise it incrementally, and test the result against the original.

Apollo 11: the extreme version of the problem

Apollo 11 flew two computers, one in each spacecraft, each running its own program: Comanche055 in the Command Module and Luminary099 in the Lunar Module. Each computer had 2,048 words of erasable memory and 36,864 words of program woven by hand into core rope.

Two spacecraft, two computers, two programs
Command Module"Columbia"The mothership. Circled the Moon and brought the crew home.Comanche055
Lunar Module"Eagle"The lander. Took two astronauts down to the surface and back up.Luminary099
2,048 words of erasable memory
36,864 words of fixed core rope, woven by hand
32 kg or so, designed at MIT
All the memory it had, to scale erasable fixed rope

The software has every classic legacy problem, at the extreme. Its authors are long gone, its knowledge lives in scanned printouts, and one comment in the landing guidance, on a call that flew, still reads “TEMPORARY, I HOPE HOPE HOPE”.

Apollo has every legacy problem, at the extreme
The usual legacy problemIn a typical enterpriseIn Apollo 11
The builders have goneRetired COBOL teamsEngineers from the 1960s
Nothing is written downKnowledge lives in old commentsKnowledge lives in paper printouts
Tools can't read itOld languages and dialectsA language mainstream code tools don’t support
You can't tell what calls whatBatch jobs and shared copybooksIndirect calls through schedulers

What we did, and how you can check it

The code is public: the MIT Museum scanned the original printouts, volunteers at the Virtual AGC project transcribed and proofread them, and the result sits on GitHub. That means every claim below can be checked, so we have sorted them by where they come from.

What we did, and how you can check it
ProductSphere, on the full repository
  • Read all 175 source files, no unrecognised instructions
  • Catalogued 14,531 routines, data and files
  • Mapped 12,235 connections and 265 entry points
  • Answered questions in chat, citing file and line
Our engineers, on the real code
  • Added a small language module so ProductSphere could read Apollo’s assembly
  • Assembled the full Lunar Module program, Luminary099, after fixing two file names
  • Ran the original SPSIN and SPCOS on an emulator of the Apollo Guidance Computer, 65,536 calls
  • Rewrote both routines in TypeScript
  • Tested the rewrite against every original result
Cross-checked by hand
  • ProductSphere’s counts against a raw count of the files
  • Every KILLTASK caller and both NOVACs, against the source
  • Our assembled program against the proofread core-rope listing: identical where SPSIN and SPCOS live, 4 words different elsewhere
  • The test itself, against three deliberately planted bugs
Illustrative only
  • The chat screen: a recreation of our session, answers summarised
  • The cover art

Each step below has the same four parts: what makes it hard, what was done, the evidence you can inspect, and what a person checked before moving on.

Step 1: Understand the system

Step 1 at a glance
Challenge

Two languages in the same files, calls routed through a scheduler instead of by name, and two programs that share routine names.

ProductSphere did

Read all 175 files, once our engineers had added a small language module for Apollo’s assembly, and built a map of the system.

Evidence

A map of every routine, connection and entry point in both programs, counted in the figure below, with no routine attributed to the wrong program.

Human checkpoint

An engineer compared the counts with an independent count of the raw files: one program matched exactly, the other within 0.1%.

For a CIO, this map is the inventory a modernisation business case is built on: what exists, what depends on what, and where work begins. Without it, every estimate is a guess.

Fed into ProductSphere: 175 files, understood
Apollo 11 repositoryComanche055 + Luminary099ProductSpheresearch, explorer, chat, summaries
175 of 175 source files read, no unrecognised instructions
14,531routines, data and files catalogued
12,235connections mapped: which part uses which
265places where the computer starts work
0mix-ups between the two spacecraft programs
ProductSphere figures from a tiramai internal test on the full Apollo 11 repository, 10 October 2026. An engineer checked the counts against an independent count of the raw files: one program matched exactly, the other within 0.1%.

Step 2: Document what it does

Step 2 at a glance
Challenge

Names that mean different things in different programs, and behaviour spread across files nobody has opened in decades.

ProductSphere did

Explained routines in plain English and answered questions in chat, asking which NOVAC we meant before answering, because both programs define one.

Evidence

Every answer cites file and line. In the source, KILLTASK is called from 11 places in the Lunar Module program, each cancelling a named task.

Human checkpoint

We cross-checked the answers by hand against the public source: both NOVAC definitions are where the answer says. All 11 KILLTASK call sites in the source are listed below.

Documentation is where knowledge stops depending on who is still in the building. Because every answer carries its source line, an engineer can verify it in seconds rather than take it on trust.

Step 2: ask the code questions
ProductSpherechrislgarry/Apollo-11
What does NOVAC do?
NOVAC exists in both programs. Which one do you mean?Comanche055 · Command ModuleLuminary099 · Lunar Module
The Lunar Module.
NOVAC starts a new job in the computer’s scheduler. Here is how it works, step by step, with the source for each step. 9 places in the source cited about 10 seconds
A recreation of the ProductSphere chat from our test, with the answers summarised. Switch questions with the tabs.
Every call to KILLTASK in the Lunar Module program
Label above the callFile and lineTask it cancels
Engine ignition (BURN, BABY, BURN)
COMFAIL2BURN_BABY_BURN…:630ZOOM
NULLCLOKBURN_BABY_BURN…:797ULLGTASK
Rendezvous radar designation (P20–P25)
R21LEM12P20-P25:952BEGDES
R21LEM9P20-P25:997STDESIG
R24ENDP20-P25:1187CALLDGCH
R24LEM3P20-P25:1215CALLDGCH
NOTP20P20-P25:2706DESLOOP +2
CSMINTP20-P25:3207DESLOOP +2
CONTDESGP20-P25:4301DESLOOP +2
STORE1SP20-P25:4379DESLOOP +2
LIMALARMP20-P25:4386CALLDGCH
Read off the Luminary099 source. The task cancelled is the address on the line after each call.

Step 3: Modernise one routine

For the rewrite we chose SPSIN and SPCOS, the Lunar Module’s single-precision sine and cosine: 32 lines of assembly, small enough to show in full below, and full of the traps that make real legacy code hard to move.

Step 3 at a glance
Challenge

Ones’-complement arithmetic with a negative zero, multiplies that truncate, and a constant table that only works because of where it sits in memory.

Our engineers did

Rewrote SPSIN and SPCOS, the Lunar Module’s sine and cosine, in TypeScript from their intent: same polynomial, same flight constants, same rounding rules.

Evidence

The full original and the full rewrite, side by side below, and the map of everything in the program that depends on them.

Human checkpoint

Every AGC rule the rewrite depends on is written down as a comment, so a reviewer can check each one against the original listing.

First, the blast radius. The source says who depends on these two routines, and it is not a short list: the autopilot’s timer interrupt, the navigation and guidance cycle, the landing displays and the rendezvous radar. One of the callers, QUICTRIG, exists because it is, in its own comment, 10 times as fast as the general routine. Speed is why sine was a cheap polynomial in the first place.

Know the blast radius before you rewrite

Pick any part of the program. Everything that would feel a change to it lights up. Start with SPSIN / SPCOS at the bottom.

Nothing selected yet.
Drawn by our engineers from the Luminary099 source. Every line is a call, except the landing displays, which read GPMATRIX’s results (dashed).

Then the traps. The AGC used ones’-complement arithmetic, which has a negative zero. Its multiplies keep the high word of an exact product, so they truncate. And the routine folds angles past 90° using a three-entry table it reaches by stepping one word either side of a constant called LIMITS. The table only works because of where the constants sit in memory; the source warns that one of them “must be two locations in front of BIT14”. It is exactly the kind of dependency a rewrite breaks without anyone noticing.

Before and after: SPSIN and SPCOS in full
1969 · Luminary099 · AGC assembly, 32 lines
SPCOS   AD      HALF+90°SPSIN   TS      TEMK        TCF     SPT        CS      TEMKpast 180°: wrapSPT     DOUBLEscale to π/2        TS      TEMKoverflow = past 90°        TCF     POLLEY        XCH     TEMK        INDEX   TEMKstep ±1 word…        AD      LIMITS…either side of LIMITS        COM        AD      TEMKmirror at 32768        TS      TEMK        TCF     POLLEY        TCF     ARG90exactly 90°POLLEY  EXTEND        MP      TEMKt²        TS      SQ        EXTEND        MP      C5/2        AD      C3/2        EXTEND        MP      SQ        AD      C1/2        EXTEND        MP      TEMK× t, exact        DDOUBLdouble, then keep high word        TS      TEMKoverflow → ARG90        TC      QARG90   INDEX   A        CS      LIMITS±full scale        TC      Q
Today · TypeScript
function fold(x) {  const t = 2 * x  if (Math.abs(t) <= MAX) return t  const r = t > 0 ? 32768 - t : -32768 - t  if (Math.abs(r) > MAX) return 'full'  return r}function polynomial(t) {  const t2 = mul(t, t)  const a = mul(t2, C5) + C3  const inner = mul(a, t2) + C1  const y = Math.trunc((2 * inner * t) / ONE)  return Math.max(-MAX, Math.min(MAX, y))}function spsin(x) {  const t = fold(x)  if (t === 'full') return x > 0 ? MAX : -MAX  return polynomial(t)}function spcos(x) {  const shifted = x + ONE / 2  return spsin(shifted <= MAX ? shifted : ONE / 2 - x)}
The original is SINGLE_PRECISION_SUBROUTINES.agc in Luminary099 (public domain); the rewrite is shown without its comments and types. The number beside each line is the job it does; pick a job to light it up on both sides.

Step 4: Test it against the original

Step 4 at a glance
Challenge

Legacy systems rarely have tests, so there is nothing to tell you whether the new code behaves like the old.

Our engineers did

Ran the original routines from the flight binary on Virtual AGC, an emulator of the Apollo Guidance Computer, for all 32,768 possible inputs, and compared the rewrite against every result.

Evidence

0 mismatches in 65,536 calls. The obvious rewrite, using Math.sin, changed 66% of the outputs, each by up to 4/16,384.

Human checkpoint

The pass rule was set before the run: the same value as the original on every input. Three deliberately planted bugs showed the test can fail.

Legacy systems rarely come with tests, so we used the original as the test. We assembled the full Luminary099 program (after fixing two file names in the repository) and compared it with Virtual AGC’s proofread core-rope listing: the memory bank holding SPSIN and SPCOS is identical, and 4 words differ elsewhere. We then ran the original routines from the proofread listing on Virtual AGC’s emulator of the Apollo Guidance Computer for every possible input, and compared each rewrite against all 65,536 results.

Test results: the rewrite against the 1969 original
The obvious rewriteMath.sin and Math.cos, roundedFail
43,250 of 65,536 calls differ · up to 4 units in the last place
Rewrite from intentflight polynomial, flight constants, AGC roundingPass
0 of 65,536 calls differ · the same value on every input
Does the test have teeth? Three bugs planted in the passing rewrite
Double after truncating, not beforecaught on 32,488 calls
Mirror angles at 32767, not 32768caught on 20,850 calls
Round the multiplies instead of truncatingcaught on 22,976 calls
Measured on 22 October 2026. “The same value” means the same number on every input; the original never returns negative zero, so none was lost. One unit in the last place is 1/16,384.

The obvious rewrite is the instructive failure. Math.sin is more accurate than the 1969 polynomial, and in a code review it looks like an improvement. It also changes two out of every three answers, because the original is approximate on purpose, in a smooth, repeatable way:

Why the obvious rewrite fails: the original is approximate on purpose
1969 original (and the rewrite from intent) Math.sin rewrite
-10+1+20°30°45°60°90°1969 originalMath.sin
Error against the true sine, in units of 1/16,384, averaged over 1.4° steps
AngleTrue value × 16,3841969 originalMath.sin rewrite
10° 016162844.3628442844
30° 052538192.9181948193 differs by 1
45° 1000011585.241158711585 differs by 2
60° 1252514188.441419114188 differs by 3
Mean error over each 1.4° step, from the emulator run. Individual inputs reach 4.2 units from the true sine. Hover the chart to read both lines.

Whether a difference of 3/16,384 matters depends on everything downstream of it. That is exactly why the test compares against the original rather than against the textbook.

What this proves, and what it does not

Apollo is a demonstration of specific capabilities, not proof that every enterprise migration is now easy. It shows that ProductSphere can understand and document a system written in a language mainstream code tools don’t support, and that one routine can be modernised and shown to give the same values as the original.

It does not show a whole program migrated. Each routine was tested on its own, with interrupts off, on an emulator rather than flight hardware. Understanding the source code is an important starting point; real modernisation also needs environment-specific validation, integration testing and operational acceptance by the people who run the system.

Start with a Legacy-Code Assessment

If you have a system nobody wants to touch, the first step is the one we took with Apollo: understand it before you change it. We agree the scope with you before anything starts.

ProductSphere Legacy-Code Assessment
You bring An agreed repository scope A named engineer for the checkpoints
ProductSphereLegacy-Code Assessment
You get A dependency map of the agreed scope Source-grounded documentation, cited to file and line The change risks, with the blast radius of each A proposed pilot plan
Book a ProductSphere Legacy-Code Assessment

Sources

  • #ProductSphere
  • #legacy modernisation
  • #Apollo 11
  • #code understanding
  • #equivalence testing
  • #COBOL
Share
Written byAkash RajAI Product Manager, tiramai
Follow tiramai on LinkedIn
Talk to us

Working through this for your organisation? Our team can walk you through it on your own use case.

See the platform

How tiramai runs governed AI in the cloud, your private cloud or fully on-premises.

Explore ProductSphere
FAQ

Questions About This Topic

ProductSphere read all 175 source files of Apollo 11’s two flight programs, catalogued 14,531 routines, data and files, mapped 12,235 connections and 265 entry points, and answered questions in chat with citations to file and line. Its counts were checked against an independent count of the raw files.