Source Code

These source code files are a reconstruction of Sundance, the Apollo 9 LM (Lunar Module) AGC (Apollo Guidance Computer) flight software, created from binary dumps of original core rope program modules, as follows:
  • B1 — Revision 292
  • B2 — Revision 302
  • B3 — Revision 302
  • B4 — Revision 302
  • B5 — Revision 292
  • B6 — Revision 306
This means that source code does not represent a specific historical revision of Sundance, but rather a mixture of the three released versions. Nonetheless, it is capable of flying the whole Apollo 9 mission. This source code matches the binary dumps, as closely as feasible, but 100% match is not possible, due mostly to changes in memory addresses at which code and variables were allocated in different revisions of Sundance. Refer to this list of explanations for each binary mismatch.

Since only binary dumps (rather than listings) of Sundance are available as source material, all comments and labels are approximate. They have been taken from other AGC programs where possible, or, in some places, written from scratch to match what we believe would have been in the original listing.

031360,000002:                                                                                                  ## Copyright:   Public domain.
031361,000003:                                                                                                  ## Filename:    THROTTLE_CONTROL_ROUTINES.agc
031362,000004:                                                                                                  ## Purpose:     A section of a reconstructed, mixed version of Sundance
031363,000005:                                                                                                  ##              It is part of the reconstructed source code for the Lunar
031364,000006:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
031365,000007:                                                                                                  ##              No original listings of this program are available;
031366,000008:                                                                                                  ##              instead, this file was created via disassembly of dumps
031367,000009:                                                                                                  ##              of various revisions of Sundance core rope modules.
031368,000010:                                                                                                  ## Assembler:   yaYUL
031369,000011:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
031370,000012:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
031371,000013:                                                                                                  ## Mod history: 2020-06-17 MAS  Created from Luminary 69.
031372,000014: 
031373,000015:                                                                                                  ## Sundance 292
031374,000016: 
031375,000017: 31,2235                                           BANK     31                                    
031376,000018: 31,2000                                           SETLOC   FTHROT                                
031377,000019: 31,2000                                           BANK                                           
031378,000020: 31,2235  E7,1417                                  EBANK=   PIF                                   
031379,000021: 31,2235                                           COUNT*   $$/THROT                              
031380,000022: 
031381,000023:                                                                                                  #  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
031382,000024:                                                                                                  #  HERE FC, DESIRED THRUST, AND FP, PRESENT THRUST, UNWEIGHTED, ARE COMPUTED.
031383,000025: 
031384,000026: 31,2235           31245        THROTTLE           CA       ABDELV                                #  COMPUTE PRESENT ACCELERATION IN UNITS OF
031385,000027: 31,2236           00006                           EXTEND                                         #  2(-4) M/CS/CS, SAVING SERVICER TROUBLE
031386,000028: 31,2237           72414                           MP       /AF/CNST                              
031387,000029: 31,2240           00006                 +3        EXTEND                                         
031388,000030: 31,2241           23600                           QXCH     RTNHOLD                               
031389,000031: 31,2242           02373        AFDUMP             TC       MASSMULT                              
031390,000032: 31,2243           53553                           DXCH     FP                                    #  FP = PRESENT THRUST
031391,000033: 31,2244           00006                           EXTEND                                         
031392,000034: 31,2245           31570                           DCA      /AFC/                                 
031393,000035: 31,2246           02373                           TC       MASSMULT                              
031394,000036: 31,2247           53551                           DXCH     FCODD                                 #  FCODD = WHAT IT IS GOING TO GET
031395,000037: 
031396,000038:                                                                                                  #  IF IT HAS BEEN LESS THAN 3 SECONDS SINCE THE LAST THROTTLING, AUGMENT FP USING THE FWEIGHT CALCULATED THEN.
031397,000039: 
031398,000040: 31,2250           41604                           CS       TTHROT                                #  THIS CODING ASSUMES A FLATOUT WITHIN
031399,000041: 31,2251           60025                           AD       TIME1                                 #    80 SECONDS BEFORE FIRST THROTTLE CALL
031400,000042: 31,2252           75006                           MASK     POSMAX                                
031401,000043: 31,2253           40000                           COM                                            
031402,000044: 31,2254           65052                           AD       3SECS                                 
031403,000045: 31,2255           00006                           EXTEND                                         
031404,000046: 31,2256           62262                           BZMF     WHERETO                               #  BRANCH IF (TIME1-TTHROT +1) > 3 SECONDS
031405,000047: 31,2257           00006                           EXTEND                                         
031406,000048: 31,2260           31602                           DCA      FWEIGHT                               
031407,000049: 31,2261           21553                           DAS      FP                                    
031408,000050: 
031409,000051:                                                                                                  #      THIS LOGIC DETERMINES THE THROTTLING IN THE REGION 10% - 94%.  THE MANUAL THROTTLE, NOMINALLY SET AT
031410,000052:                                                                                                  #  MINIMUM BY ASTRONAUT OR MISSION CONTROL PROGRAMS, PROVIDES THE LOWER BOUND.  A STOP IN THE THROTTLE HARDWARE
031411,000053:                                                                                                  #  PROVIDES THE UPPER.
031412,000054: 
031413,000055: 31,2262           45030        WHERETO            CS       ZERO                                  #  INITIALIZE PIFPSET
031414,000056: 31,2263           55577                           TS       PIFPSET                               
031415,000057: 31,2264           42407                           CS       HIGHCRIT                              
031416,000058: 31,2265           61657                           AD       FCOLD                                 
031417,000059: 31,2266           00006                           EXTEND                                         
031418,000060: 31,2267           62301                           BZMF     LOWFCOLD                              #  BRANCH IF FCOLD < OR = HIGHCRIT
031419,000061: 31,2270           42410                           CS       LOWCRIT                               
031420,000062: 31,2271           61550                           AD       FCODD                                 
031421,000063: 31,2272           00006                           EXTEND                                         
031422,000064: 31,2273           62276                           BZMF     FCOMPSET                              #  BRANCH IF FC < OR = LOWCRIT
031423,000065: 31,2274           31552                           CA       FP                                    #  SEE NOTE 1
031424,000066: 31,2275           12306                           TCF      FLATOUT1                              
031425,000067: 
031426,000068: 31,2276           42405        FCOMPSET           CS       FMAXODD                               #  SEE NOTE 2
031427,000069: 31,2277           61552                           AD       FP                                    
031428,000070: 31,2300           12310                           TCF      FLATOUT2                              
031429,000071: 
031430,000072: 31,2301           42407        LOWFCOLD           CS       HIGHCRIT                              
031431,000073: 31,2302           61550                           AD       FCODD                                 
031432,000074: 31,2303           00006                           EXTEND                                         
031433,000075: 31,2304           62311                           BZMF     DOPIF                                 #  BRANCH IF FC < OR = HIGHCRIT
031434,000076: 
031435,000077: 31,2305           32406                           CA       FMAXPOS                               #  NO:  THROTTLE-UP
031436,000078: 31,2306           53551        FLATOUT1           DXCH     FCODD                                 
031437,000079: 31,2307           35020                           CA       FEXTRA                                
031438,000080: 31,2310           55577        FLATOUT2           TS       PIFPSET                               
031439,000081: 
031440,000082:                                                                                                  #  NOTE 1        FC IS SET EQUAL TO FP SO PIF WILL BE ZERO.  THIS IS DESIRABLE
031441,000083:                                                                                                  #                AS THERE IS ACTUALLY NO THROTTLE CHANGE.
031442,000084: 
031443,000085:                                                                                                  #  NOTE2         HERE, SINCE WE ARE ABOUT TO RETURN TO THE THROTTLEABLE REGION
031444,000086:                                                                                                  #                (BELOW 55%) THE QUANTITY -(FMAXODD-FP) IS COMPUTED AND PUT
031445,000087:                                                                                                  #                INTO PIFPSET TO COMPENSATE FOR THE DIFFERENCE BETWEEN THE
031446,000088:                                                                                                  #                NUMBER OF BITS CORRESPONDING TO FULL THROTTLE (FMAXODD) AND THE
031447,000089:                                                                                                  #                NUMBER CORRESPONDING TO ACTUAL THRUST (FP).  THUS THE TOTAL
031448,000090:                                                                                                  #                THROTTLE COMMAND PIF = FC - FP - (FMAXODD - FP) = FC - FMAXODD.
031449,000091: 
031450,000092: 31,2311           03562        DOPIF              TC       FASTCHNG                              #  RESTART PROTECTION
031451,000093: 31,2312           00006                           EXTEND                                         
031452,000094: 31,2313           31551                           DCA      FCODD                                 
031453,000095: 31,2314           55657                           TS       FCOLD                                 
031454,000096: 31,2315           53420                           DXCH     PIF                                   
031455,000097: 31,2316           00006                           EXTEND                                         
031456,000098: 31,2317           41553                           DCS      FP                                    
031457,000099: 31,2320           21420                           DAS      PIF                                   #  PIF = FC - FP, NEVER EQUALS +0
031458,000100: 
031459,000101: 31,2321           31417        DOIT               CA       PIF                                   
031460,000102: 31,2322           61577                           AD       PIFPSET                               #  ADD IN PIFPSET, WITHOUT CHANGING PIF
031461,000103: 31,2323           55603                           TS       PSEUDO55                              
031462,000104: 31,2324           54055                           TS       THRUST                                
031463,000105: 31,2325           35023                           CAF      BIT4                                  
031464,000106: 31,2326           00006                           EXTEND                                         
031465,000107: 31,2327           05014                           WOR      CHAN14                                
031466,000108: 31,2330           30025                           CA       TIME1                                 
031467,000109: 31,2331           55604                           TS       TTHROT                                
031468,000110: 
031469,000111:                                                                                                  #  SINCE /AF/ IS NOT AN INSTANTANEOUS ACCELERATION, BUT RATHER AN "AVERAGE" OF THE ACCELERATION LEVELS DURING
031470,000112:                                                                                                  #  THE PRECEEDING PIPA INTERVAL, AND SINCE FP IS COMPUTED DIRECTLY FROM /AF/, FP IN ORDER TO CORRESPOND TO THE
031471,000113:                                                                                                  #  ACTUAL THRUST LEVEL AT THE END OF THE INTERVAL MUST BE WEIGHTED BY
031472,000114: 
031473,000115:                                                                                                  #                  PIF(PPROCESS + TL)     PIF /PIF/
031474,000116:                                                                                                  #        FWEIGHT = ------------------ + -------------
031475,000117:                                                                                                  #                       PGUID           2 PGUID FRATE
031476,000118: 
031477,000119:                                                                                                  #  WHERE PPROCESS IS THE TIME BETWEEN PIPA READING AND THE START OF THROTTLING, PGUID IS THE GUIDANCE PERIOD, AND
031478,000120:                                                                                                  #  FRATE IS THE THROTTLING RATE (32 UNITS PER CENTISECOND).  PGUID IS ASSUMED TO BE 2 SECONDS.  THE "TL" IN THE
031479,000121:                                                                                                  #  FIRST TERM REPRESENTS THE ENGINE'S RESPONSE LAG.  HERE FWEIGHT IS COMPUTED FOR USE NEXT PASS.
031480,000122: 
031481,000123: 31,2332           35053                           CA       4SECS                                 
031482,000124: 31,2333           54002                           TS       Q                                     
031483,000125: 31,2334           41234                           CS       PIPTIME    +1                         #  TIME OF LAST PIPA READING
031484,000126: 31,2335           60025                           AD       TIME1                                 
031485,000127: 31,2336           62412                           AD       THROTLAG                              #  COMPENSATE FOR ENGINE RESPONSE LAG
031486,000128: 31,2337           74371                           MASK     LOW8                                  #  MAKE SURE SMALL AND POSITIVE
031487,000129: 31,2340           22007                           ZL                                             
031488,000130: 31,2341           00006                           EXTEND                                         
031489,000131: 31,2342           10002                           DV       Q                                     
031490,000132: 31,2343           00006                           EXTEND                                         
031491,000133: 31,2344           71417                           MP       PIF                                   
031492,000134: 31,2345           60000                           DOUBLE                                         
031493,000135: 31,2346           53602                           DXCH     FWEIGHT                               
031494,000136: 31,2347           32413                           CA       2.PG.FRT                              
031495,000137: 31,2350           54002                           TS       Q                                     
031496,000138: 31,2351           11417                           CCS      PIF                                   
031497,000139: 31,2352           65026                           AD       ONE                                   
031498,000140: 31,2353           12355                           TCF      +2                                    
031499,000141: 31,2354           65026                           AD       ONE                                   
031500,000142: 31,2355           00006                           EXTEND                                         
031501,000143: 31,2356           71417                           MP       PIF                                   
031502,000144: 31,2357           00006                           EXTEND                                         
031503,000145: 31,2360           10002                           DV       Q                                     
031504,000146: 31,2361           22007                           ZL                                             
031505,000147: 31,2362           21602                           DAS      FWEIGHT                               
031506,000148: 
031507,000149: 31,2363           01600        THDUMP             TC       RTNHOLD                               
031508,000150: 
031509,000151:                                                                                                  #  FLATOUT THROTTLES UP THE DESCENT ENGINE, AND IS CALLED AS A BASIC SUBROUTINE.
031510,000152: 
031511,000153: 31,2364           35012        FLATOUT            CAF      BIT13                                 #  4096 PULSES
031512,000154: 31,2365           55577        WHATOUT            TS       PIFPSET                               #  USE PIFPSET SO FWEIGHT WILL BE ZERO
031513,000155: 31,2366           45030                           CS       ZERO                                  
031514,000156: 31,2367           55417                           TS       PIF                                   
031515,000157: 31,2370           00006                           EXTEND                                         
031516,000158: 31,2371           23600                           QXCH     RTNHOLD                               
031517,000159: 31,2372           12321                           TCF      DOIT                                  
031518,000160: 
031519,000161:                                                                                                  #  MASSMULT SCALES ACCELERATION, ARRIVING IN A AND L IN UNITS OF 2(-4) M/CS/CS, TO FORCE IN PULSE UNITS.
031520,000162: 
031521,000163: 31,2373           00006        MASSMULT           EXTEND                                         
031522,000164: 31,2374           22130                           QXCH     BUF                                   
031523,000165: 31,2375           00006                           EXTEND                                         
031524,000166: 31,2376           71243                           MP       MASS                                  #  LEAVES ODDLY SCALED FORCE IN A AND L
031525,000167: 31,2377           52155                           DXCH     MPAC                                  
031526,000168: 31,2400           07057                           TC       DMP                                   #  LEAVES PROPERLY SCALED FORCE IM MPAC
031527,000169: 31,2401           02415                           ADRES    SCALEFAC                              
031528,000170: 31,2402           52156                           DXCH     MPAC       +1                         
031529,000171: 31,2403           00130                           TC       BUF                                   
031530,000172: 
031531,000173:                                                                                                  #  CONSTANTS:-
031532,000174: 
031533,000175: 31,2404           07452        FMAXMAX            DEC      +3882      B-14                       
031534,000176: 31,2405           07432        FMAXODD            DEC      +3866      B-14                       #  THROTTLE SATURATION THRESHOLD
031535,000177: 31,2406           07100        FMAXPOS            DEC      +3648      B-14                       #  FMAX    43245 NEWTONS
031536,000178: 31,2407           04616        HIGHCRIT           DEC      2446       B-14                       
031537,000179: 31,2410           04127        LOWCRIT            DEC      2135       B-14                       
031538,000180: 31,2411     5020               FEXTRA             =        BIT7                                  
031539,000181: 31,2411           00666        DEC438             DEC      438        B-14                       
031540,000182: 31,2412           00024        THROTLAG           DEC      20         B-14                       #  EMPIRICALLY DETERMINED THROTTLE LAG TIME
031541,000183: 31,2413           31000        2.PG.FRT           DEC      12800      B-14                       
031542,000184: 31,2414           04143        /AF/CNST           DEC      .13107                                
031543,000185: 31,2415           00317 31157  SCALEFAC           2DEC     51.947     B-12                       #  SCALES A (AT 2(-4) M/CS/CS) TIMES MASS
031544,000186:                                                                                                  #  (AT 2(16) KGS. ) TO PULSE UNITS.
031545,000187: 
031546,000188:                                                                                                  #  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

End of include-file THROTTLE_CONTROL_ROUTINES.agc.  Parent file is MAIN.agc