Source Code

These source-code files are part of a reconstructed copy of LM131 revision 1, the final release of the Apollo 13 Lunar Module (LM) Apollo Guidance Computer (AGC) software.

The source reconstruction began with source code of Luminary 131 previously transcribed from a digitized copy of that program. A dump of the flight spare core rope memory module B5, part number 2010802-171, serial number RAY 411, was obtained. This module is the only module different between Luminary 131 and LM131 revision 1. The dump was disassembled and all changes were incorporated into these source files. Note that page numbers in the reconstructed code match those on the Luminary 131 printout, although the changed code would likely have changed page numbers for a real LM131 revision 1 listing.

Comments from the original source code are prefixed with a single '#' symbol, whereas comments added later are prefixed by "##" or "###". Report any errors noted by creating an issue report at the Virtual AGC project's GitHub repository.

033316,000002:                                                                                                  ## Copyright:   Public domain.
033317,000003:                                                                                                  ## Filename:    THROTTLE_CONTROL_ROUTINES.agc
033318,000004:                                                                                                  ## Purpose:     A section of LM131 revision 1.
033319,000005:                                                                                                  ##              It is part of the reconstructed source code for the final
033320,000006:                                                                                                  ##              release of the flight software for the Lunar Module's (LM)
033321,000007:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13. The code has
033322,000008:                                                                                                  ##              been reconstructed from a listing of Luminary 131 and a dump
033323,000009:                                                                                                  ##              of a core rope memory module B5, part number 2010802-171,
033324,000010:                                                                                                  ##              which is the only module different between LM131 revision 1
033325,000011:                                                                                                  ##              and Luminary 131. The executable generated from this source
033326,000012:                                                                                                  ##              has been verified against the module dump, so while the names,
033327,000013:                                                                                                  ##              comments, and ordering may not be exactly correct, the
033328,000014:                                                                                                  ##              resulting binary is.
033329,000015:                                                                                                  ## Reference:   pp. 788-792
033330,000016:                                                                                                  ## Assembler:   yaYUL
033331,000017:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
033332,000018:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
033333,000019:                                                                                                  ## Mod history: 2022-10-28 MAS  Created from Luminary 131.
033334,000020: 

Page 788

033336,000022: 31,2144                                           BANK     31                                    
033337,000023: 31,2000                                           SETLOC   FTHROT                                
033338,000024: 31,2000                                           BANK                                           
033339,000025: 31,2144  E7,1612                                  EBANK=   PIF                                   
033340,000026: 31,2144                                           COUNT*   $$/THROT                              
033341,000027: 
033342,000028:                                                                                                  #  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
033343,000029:                                                                                                  #  HERE FC, DESIRED THRUST, AND FP, PRESENT THRUST, UNWEIGHTED, ARE COMPUTED.
033344,000030: 
033345,000031: 31,2144           31245        THROTTLE           CA       ABDELV                                #  COMPUTE PRESENT ACCELERATION IN UNITS OF
033346,000032: 31,2145           00006                           EXTEND                                         #  2(-4) M/CS/CS, SAVING SERVICER TROUBLE
033347,000033: 31,2146           72356                           MP       /AF/CNST                              
033348,000034: 31,2147           00006                 +3        EXTEND                                         
033349,000035: 31,2150           23607                           QXCH     RTNHOLD                               
033350,000036: 31,2151           02337        AFDUMP             TC       MASSMULT                              
033351,000037: 31,2152           53470                           DXCH     FP                                    #  FP = PRESENT THRUST
033352,000038: 31,2153           00006                           EXTEND                                         
033353,000039: 31,2154           31464                           DCA      /AFC/                                 
033354,000040: 31,2155           02337                           TC       MASSMULT                              
033355,000041: 31,2156           55615                           TS       FC                                    #  FC = THRUST DESIRED BY GUIDANCE
033356,000042: 31,2157           53466                           DXCH     FCODD                                 #  FCODD = WHAT IT IS GOING TO GET
033357,000043: 
033358,000044:                                                                                                  #  COMPUTE DESIRED THRUST FOR DISPLAY AS A PERCENTAGE OF 10,500 POUNDS
033359,000045: 
033360,000046: 31,2160           32360                           CAF      4FMAXNOM                              #  MOVE 4FMAXNOM TO ERASABLE FOR DV BELOW
033361,000047: 31,2161           54002                           TS       Q                                     
033362,000048: 31,2162           31615                           CA       FC                                    
033363,000049: 31,2163           72357                           MASK     OCT17777                              #  FOR SAFETY
033364,000050: 31,2164           00006                           EXTEND                                         
033365,000051: 31,2165           10002                           DV       Q                                     
033366,000052: 31,2166           00006                           EXTEND                                         
033367,000053: 31,2167           75003                           MP       4SECS                                 
033368,000054: 31,2170           55750                           TS       THRDISP                               #  FOR DISPLAY IN N92
033369,000055: 
033370,000056:                                                                                                  #  IF IT HAS BEEN LESS THAN 3 SECONDS SINCE THE LAST THROTTLING, AUGMENT FP USING THE FWEIGHT CALCULATED THEN.
033371,000057: 
033372,000058: 31,2171           41617                           CS       TTHROT                                #  THIS CODING ASSUMES A FLATOUT WITHIN
033373,000059: 31,2172           60025                           AD       TIME1                                 #        80 SECONDS BEFORE FIRST THROTTLE CALL
033374,000060: 31,2173           74733                           MASK     POSMAX                                
033375,000061: 31,2174           40000                           COM                                            
033376,000062: 31,2175           65002                           AD       3SECS                                 
033377,000063: 31,2176           00006                           EXTEND                                         
033378,000064: 31,2177           62203                           BZMF     WHERETO                               #  BRANCH IF (TIME1-TTHROT +1) > 3 SECONDS

Page 789

033380,000066: 31,2200           00006                           EXTEND                                         
033381,000067: 31,2201           31611                           DCA      FWEIGHT                               
033382,000068: 31,2202           21470                           DAS      FP                                    
033383,000069: 
033384,000070:                                                                                                  #  THIS LOGIC DETERMINES THE THROTTLING IN THE REGION 10% - 94%.  THE MANUAL THROTTLE, NOMINALLY SET AT
033385,000071:                                                                                                  #  MINIMUM BY ASTRONAUT OR MISSION CONTROL PROGRAMS, PROVIDES THE LOWER BOUND.  A STOP IN THE THROTTLE HARDWARE
033386,000072:                                                                                                  #  PROVIDES THE UPPER.
033387,000073: 
033388,000074: 31,2203           35014        WHERETO            CA       EBANK5                                #  INITIALIZE L*WCR*T AND H*GHCR*T FROM
033389,000075: 31,2204           54003                           TS       EBANK                                 #        PAD LOADED ERASABLES IN W-MATRIX
033390,000076: 31,2205  E5,1506                                  EBANK=   LOWCRIT                               
033391,000077: 31,2205           00006                           EXTEND                                         
033392,000078: 31,2206           31507                           DCA      LOWCRIT                               
033393,000079: 31,2207           52131                           DXCH     L*WCR*T                               
033394,000080: 31,2210           35016                           CA       EBANK7                                
033395,000081: 31,2211           54003                           TS       EBANK                                 
033396,000082: 31,2212  E7,1612                                  EBANK=   PIF                                   
033397,000083: 31,2212           44755                           CS       ZERO                                  #  INITIALIZE PIFPSET
033398,000084: 31,2213           55606                           TS       PIFPSET                               
033399,000085: 31,2214           40131                           CS       H*GHCR*T                              
033400,000086: 31,2215           61620                           AD       FCOLD                                 
033401,000087: 31,2216           00006                           EXTEND                                         
033402,000088: 31,2217           62231                           BZMF     LOWFCOLD                              #  BRANCH IF FCOLD < OR = HIGHCRIT
033403,000089: 31,2220           40130                           CS       L*WCR*T                               
033404,000090: 31,2221           61465                           AD       FCODD                                 
033405,000091: 31,2222           00006                           EXTEND                                         
033406,000092: 31,2223           62226                           BZMF     FCOMPSET                              #  BRANCH IF FC < OR = LOWCRIT
033407,000093: 31,2224           31467                           CA       FP                                    #  SEE NOTE 1
033408,000094: 31,2225           12236                           TCF      FLATOUT1                              
033409,000095: 
033410,000096: 31,2226           42002        FCOMPSET           CS       FMAXODD                               #  SEE NOTE 2
033411,000097: 31,2227           61467                           AD       FP                                    
033412,000098: 31,2230           12240                           TCF      FLATOUT2                              
033413,000099: 
033414,000100: 31,2231           40131        LOWFCOLD           CS       H*GHCR*T                              
033415,000101: 31,2232           61465                           AD       FCODD                                 
033416,000102: 31,2233           00006                           EXTEND                                         
033417,000103: 31,2234           62241                           BZMF     DOPIF                                 #  BRANCH IF FC < OR = HIGHCRIT
033418,000104: 
033419,000105: 31,2235           32003                           CA       FMAXPOS                               #  NO:  THROTTLE-UP
033420,000106: 31,2236           53466        FLATOUT1           DXCH     FCODD                                 
033421,000107: 31,2237           34737                           CA       FEXTRA                                
033422,000108: 31,2240           55606        FLATOUT2           TS       PIFPSET                               
033423,000109: 
033424,000110:                                                                                                  #  NOTE 1        FC IS SET EQUAL TO FP SO PIF WILL BE ZERO.  THIS IS DESIRABLE
033425,000111:                                                                                                  #                AS THERE IS ACTUALLY NO THROTTLE CHANGE.
033426,000112: 
033427,000113:                                                                                                  #  NOTE2         HERE, SINCE WE ARE ABOUT TO RETURN TO THE THROTTLEABLE REGION

Page 790

033429,000115:                                                                                                  #                (BELOW 55%) THE QUANTITY -(FMAXODD-FP) IS COMPUTED AND PUT
033430,000116:                                                                                                  #                INTO PIFPSET TO COMPENSATE FOR THE DIFFERENCE BETWEEN THE
033431,000117:                                                                                                  #                NUMBER OF BITS CORRESPONDING TO FULL THROTTLE (FMAXODD) AND THE
033432,000118:                                                                                                  #                NUMBER CORRESPONDING TO ACTUAL THRUST (FP).  THUS THE TOTAL
033433,000119:                                                                                                  #                THROTTLE COMMAND PIF = FC - FP - (FMAXODD - FP) = FC - FMAXODD.
033434,000120: 
033435,000121: 31,2241           03677        DOPIF              TC       FASTCHNG                              
033436,000122: 31,2242           00006                           EXTEND                                         
033437,000123: 31,2243           31466                           DCA      FCODD                                 
033438,000124: 31,2244           55620                           TS       FCOLD                                 
033439,000125: 31,2245           53613                           DXCH     PIF                                   
033440,000126: 31,2246           00006                           EXTEND                                         
033441,000127: 31,2247           41470                           DCS      FP                                    
033442,000128: 31,2250           21613                           DAS      PIF                                   #  PIF = FC - FP, NEVER EQUALS +0
033443,000129: 
033444,000130: 31,2251           31612        DOIT               CA       PIF                                   
033445,000131: 31,2252           61606                           AD       PIFPSET                               #  ADD IN PIFPSET, WITHOUT CHANGING PIF
033446,000132: 31,2253           55614                           TS       PSEUDO55                              
033447,000133: 31,2254           54055                           TS       THRUST                                
033448,000134: 31,2255           34750                           CAF      BIT4                                  
033449,000135: 31,2256           00006                           EXTEND                                         
033450,000136: 31,2257           05014                           WOR      CHAN14                                
033451,000137: 31,2260           30025                           CA       TIME1                                 
033452,000138: 31,2261           55617                           TS       TTHROT                                
033453,000139: 
033454,000140:                                                                                                  #  SINCE /AF/ IS NOT AN INSTANTANEOUS ACCELERATION, BUT RATHER AN "AVERAGE" OF THE ACCELERATION LEVELS DURING
033455,000141:                                                                                                  #  THE PRECEEDING PIPA INTERVAL, AND SINCE FP IS COMPUTED DIRECTLY FROM /AF/, FP IN ORDER TO CORRESPOND TO THE
033456,000142:                                                                                                  #  ACTUAL THRUST LEVEL AT THE END OF THE INTERVAL MUST BE WEIGHTED BY
033457,000143:                                                                                                  #                  PIF(PPROCESS + TL)     PIF /PIF/
033458,000144:                                                                                                  #        FWEIGHT = ------------------ + -------------
033459,000145:                                                                                                  #                       PGUID           2 PGUID FRATE
033460,000146:                                                                                                  #  WHERE PPROCESS IS THE TIME BETWEEN PIPA READING AND THE START OF THROTTLING, PGUID IS THE GUIDANCE PERIOD, AND
033461,000147:                                                                                                  #  FRATE IS THE THROTTLING RATE (32 UNITS PER CENTISECOND).  PGUID IS EITHER 1 OR 2 SECONDS.  THE "TL" IN THE
033462,000148:                                                                                                  #  FIRST TERM REPRESENTS THE ENGINE'S RESPONSE LAG.  HERE FWEIGHT IS COMPUTED FOR USE NEXT PASS.
033463,000149: 
033464,000150: 31,2262           31762                           CA       THISTPIP   +1                         #  INITIALIZE FWEIGHT COMP AS IF FOR P66
033465,000151: 31,2263           54130                           TS       BUF                                   
033466,000152: 
033467,000153: 31,2264           41010                           CS       MODREG                                #  ARE WE IN FACT IN P66?
033468,000154: 31,2265           62452                           AD       DEC66                                 
033469,000155: 31,2266           00006                           EXTEND                                         
033470,000156: 31,2267           12274                           BZF      FWCOMP                                #  YES
033471,000157: 
033472,000158: 31,2270           31234                           CA       PIPTIME    +1                         #  NO:  INITIALIZE FOR TWO SECOND PERIOD
033473,000159: 31,2271           54130                           TS       BUF                                   
033474,000160: 31,2272           35003                           CAF      4SECS                                 
033475,000161: 31,2273           12275                           TCF      FWCOMP     +1                         

Page 791

033477,000163: 
033478,000164: 31,2274           35000        FWCOMP             CAF      2SECS                                 
033479,000165: 31,2275           54002                 +1        TS       Q                                     
033480,000166: 31,2276           00006                           EXTEND                                         
033481,000167: 31,2277           74746                           MP       BIT6                                  
033482,000168: 31,2300           22131                           LXCH     BUF        +1                         
033483,000169: 31,2301           40130                           CS       BUF                                   #  TIME OF LAST PIPA READING.
033484,000170: 31,2302           60025                           AD       TIME1                                 
033485,000171: 31,2303           62004                           AD       THROTLAG                              #  COMPENSATE FOR ENGINE RESPONSE LAG
033486,000172: 31,2304           74357                           MASK     LOW8                                  #  MAKE SURE SMALL AND POSITIVE
033487,000173: 31,2305           22007                           ZL                                             
033488,000174: 31,2306           00006                           EXTEND                                         
033489,000175: 31,2307           10002                           DV       Q                                     
033490,000176: 31,2310           00006                           EXTEND                                         
033491,000177: 31,2311           71612                           MP       PIF                                   
033492,000178: 31,2312           60000                           DOUBLE                                         
033493,000179: 31,2313           53611                           DXCH     FWEIGHT                               
033494,000180: 31,2314           11612                           CCS      PIF                                   
033495,000181: 31,2315           64753                           AD       ONE                                   
033496,000182: 31,2316           12320                           TCF      +2                                    
033497,000183: 31,2317           64753                           AD       ONE                                   
033498,000184: 31,2320           00006                           EXTEND                                         
033499,000185: 31,2321           71612                           MP       PIF                                   
033500,000186: 31,2322           00006                           EXTEND                                         
033501,000187: 31,2323           10131                           DV       BUF        +1                         
033502,000188: 31,2324           22007                           ZL                                             
033503,000189: 31,2325           21611                           DAS      FWEIGHT                               
033504,000190: 
033505,000191: 31,2326           01607        THDUMP             TC       RTNHOLD                               
033506,000192: 
033507,000193:                                                                                                  #  FLATOUT THROTTLES UP THE DESCENT ENGINE, AND IS CALLED AS A BASIC SUBROUTINE.
033508,000194: 
033509,000195: 31,2327           34737        FLATOUT            CAF      BIT13                                 #  4096 PULSES
033510,000196: 31,2330           55606        WHATOUT            TS       PIFPSET                               #  USE PIFPSET SO FWEIGHT WILL BE ZERO
033511,000197: 31,2331           44755                           CS       ZERO                                  
033512,000198: 31,2332           55620                           TS       FCOLD                                 
033513,000199: 31,2333           55612                           TS       PIF                                   
033514,000200: 31,2334           00006                           EXTEND                                         
033515,000201: 31,2335           23607                           QXCH     RTNHOLD                               
033516,000202: 31,2336           12251                           TCF      DOIT                                  
033517,000203: 
033518,000204:                                                                                                  #  MASSMULT SCALES ACCELERATION, ARRIVING IN A AND L IN UNITS OF 2(-4) M/CS/CS, TO FORCE IN PULSE UNITS.
033519,000205: 
033520,000206: 31,2337           00006        MASSMULT           EXTEND                                         
033521,000207: 31,2340           22130                           QXCH     BUF                                   
033522,000208: 31,2341           52155                           DXCH     MPAC                                  
033523,000209: 31,2342           07106                           TC       DMP                                   
033524,000210: 31,2343           01243                           ADRES    MASS                                  

Page 792

033526,000212: 31,2344           07106                           TC       DMP                                   #  LEAVES PROPERLY SCALED FORCE IM MPAC
033527,000213: 31,2345           02005                           ADRES    SCALEFAC                              
033528,000214: 31,2346           07262                           TC       TPAGREE                               
033529,000215: 31,2347           30154                           CA       MPAC                                  
033530,000216: 31,2350           00006                           EXTEND                                         
033531,000217: 31,2351           12354                           BZF      +3                                    
033532,000218: 31,2352           34733                           CAF      POSMAX                                
033533,000219: 31,2353           00130                           TC       BUF                                   
033534,000220: 31,2354           52156                           DXCH     MPAC       +1                         
033535,000221: 31,2355           00130                           TC       BUF                                   
033536,000222: 
033537,000223:                                                                                                  #  CONSTANTS:-
033538,000224: 
033539,000225: 31,2356     4737               FEXTRA             =        BIT13                                 #  FEXT +5.13309020 E+4
033540,000226: 
033541,000227: 31,2356           04143        /AF/CNST           DEC      .13107                                
033542,000228: 
033543,000229: 31,2357           17777        OCT17777           OCT      17777                                 
033544,000230: 31,2360           35074        4FMAXNOM           DEC      14908      B-14                       #  EQUIVALENT TO 10,500 LBS.
033545,000231: 
033546,000232:                                                                                                  #  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

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