Partial answer
To answer @Russell's subquestions:
My analysis isn't far enough yet to fully explain the attitude versus time calculations.
Although there are a lot of calculations done before the burn, there are also additional calculations performed inside the burn loop, so I am fairly confident that it is a continuous process. There are several flags that are set or cleared during the ascent process; apparently this is how the phases of ascent are done, but I am still analyzing how it's done.
I haven't yet found anything like the formulas in Frank Perkins' paper on linear-tangent steering laws. Perhaps the formulas that are actually used are mathematically equivalent -- I'm not quite there yet.
Apollo missions carried two nearly identical guidance computers. The software for the Command Module computer was called "Colossus" and later "Comanche"; the software for the Lunar Module was called "Luminary". The programmers tried to reuse code as much as possible between the two systems, as well as between similar operations on the same system. This means that there are a large number of global variables that help subroutines know what they're being called for. The CM and LEM also occasionally contact each other by radio, giving each other their positions and velocities in space, to facilitate rendezvous.
Astronauts normally took off from the lunar surface by running program P12 "Powered Ascent Guidance". The source code is in Luminary/P12.agc. Lines 35-53 clean up the existing processes/tasks that are running on the computer, and initialize global variables needed by subroutines. The DSKY user interface is configured in lines 55-72. On lines 73-74, the GUIDINIT
subroutine is called (lines 222-236), which transforms the LEM's position in moon coordinates into universal coordinates. Lines 75-76 sets a global flag that indicates a pre-ignition state. On line 77, the P12INIT
subroutine is called (lines 179-199), which initializes engine globals to that of the ascent engine. This continues into subroutine COMMINIT
(lines 200-215), which transforms the "target" CM's coordinates into universal coordinates. Control returns to lines 79-84, which calls LEMPREC
to integrate the intended orbit by the Encke method. Lines 85-109 calculate the cross-range and apolune values of the intended flight path, which are displayed to the astronauts (lines 110-113).
The computer then waits for the astronaut to press the PROCEED button (lines 111-116). Some vector calculations are performed (lines 118-143), a flag is set indicating vertical ascent (144-145), and then control jumps to ASCENT
(see below). It returns back, calculating some pitch and yaw corrections (lines 147-166), turning off the pre-ignition state (168-169), and then jumping to BURNBABY
(171-177).
BURNBABY
in file Luminary/BURN_BABY_BURN--MASTER_IGNITION_ROUTINE.agc is a widely-used routine to start the descent or ascent engine. The caller passes a pointer to a table with various parameters including the addresses of subroutines to call back when certain events occur. BURNBABY
forks several processes that perform a ullage burn of the RCS as necessary (not needed for P12), ignite the engine, read sensors, recalculate the LEM's position and velocity, query the CSM for its position and velocity, update the DSKY display, and wait for the end of the burn. One of the tasks periodically calls back the subroutine ATMAG
, which in turn calls ASCENT
.
ASCENT
in file Luminary/ASCENT_GUIDANCE.agc is where the in-flight calculations during lunar ascent are performed. I need another day to examine it. I hope to finish this answer tomorrow.