Source Code

These source-code files are part of a reconstructed copy of Comanche 45/2 (AKA Manche45 revision 2), the final, flown mission release of the Apollo 10 Command Module (CM) Apollo Guidance Computer (AGC) software. Comanche 45/2 was preceded by Comanche 44 and Comanche 45. The reconstruction is believed to be exactly accurate, but in the absence of an actual Apollo-era listing of Comanche 45/2, some explanation of the reconstruction process is needed to insure confidence in that accuracy.

The starting point was the source code of Comanche 45 (itself previously accurately reconstructed). Comanche 45 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 45 and 45/2. The now-reconstructed Comanche 45/2 source code was verified by assembling it and checking that the assembled code had the expected known-correct memory-bank checksums. Note that page numbers in the reconstructed code tend to match those in the Comanche 55, the most-similar revision of Comanche for which we have access to an actual non-reconstructed hardcopy; the source code would likely have different page numbers in a contemporary Comanche 45 listing.

Annotations that were not present in the contemporary source code have been added to the reconstructed code to justify each change relative to Comanche 44. Here's a guide to the Apollo documentation referenced in those annotations:
Comments expected to have been present in 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.

021465,000002:                                                                                                  ## Copyright:   Public domain.
021466,000003:                                                                                                  ## Filename:    R31.agc
021467,000004:                                                                                                  ## Purpose:     A section of Manche45 revision 2.
021468,000005:                                                                                                  ##              It is part of the reconstructed source code for the
021469,000006:                                                                                                  ##              final, flown release of the flight software for the Command
021470,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
021471,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
021472,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
021473,000010:                                                                                                  ##              exactly match those specified for Manche 45/2 in NASA drawing
021474,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
021475,000012:                                                                                                  ##              reconstruction is correct.
021476,000013:                                                                                                  ## Assembler:   yaYUL
021477,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
021478,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
021479,000016:                                                                                                  ## Mod history: 2020-12-24 MAS  Created from Comanche 45.
021480,000017: 

Page 505

021482,000019: 34,2002                                           BANK     34                                    
021483,000020: 31,2000                                           SETLOC   R31                                   
021484,000021: 31,2000                                           BANK                                           
021485,000022: 
021486,000023: 31,2000                                           COUNT*   $$/R31                                
021487,000024: 
021488,000025: 31,2000           35057        R31CALL            CAF      PRIO3                                 
021489,000026: 31,2001           05147                           TC       FINDVAC                               
021490,000027: 31,2002  E4,1770                                  EBANK=   SUBEXIT                               
021491,000028: 31,2002           02032 62064                     2CADR    V83CALL                               
021492,000029: 
021493,000030: 31,2004           35041        DSPDELAY           CAF      1SEC                                  
021494,000031: 31,2005           04662                           TC       BANKCALL                              
021495,000032: 31,2006           01732                           CADR     DELAYJOB                              
021496,000033: 31,2007           31044                           CA       EXTVBACT                              
021497,000034: 31,2010           75004                           MASK     BIT12                                 
021498,000035: 31,2011           00006                           EXTEND                                         
021499,000036: 31,2012           12004                           BZF      DSPDELAY                              
021500,000037: 
021501,000038: 31,2013           30105        DISPN5X            CA       FLAGWRD9                              #  TEST R31FLAG (IN SUNDANCE R31FLAG WILL
021502,000039: 31,2014           75014                           MASK     BIT4                                  #        ALWAYS BE SET AS R34 DOES NOT EXIST)
021503,000040: 31,2015           00006                           EXTEND                                         
021504,000041: 31,2016           12021                           BZF      +3                                    
021505,000042: 31,2017           32136                           CAF      V16N54                                #  R31   USE NOUN 54
021506,000043: 31,2020           02022                           TC       +2                                    
021507,000044: 31,2021           32137                           CAF      V16N53                                #  R34   USE NOUN 53
021508,000045: 31,2022           04662                           TC       BANKCALL                              
021509,000046: 31,2023           20561                           CADR     GOMARKF                               
021510,000047: 31,2024           05625                           TC       B5OFF                                 
021511,000048: 31,2025           05625                           TC       B5OFF                                 
021512,000049: 31,2026           12013                           TCF      DISPN5X                               
021513,000050: 
021514,000051: 31,2027           06006        V83                TC       INTPRET                               
021515,000052: 31,2030           77650                           GOTO                                           
021516,000053: 31,2031           62171                                    HAVEBASE                              #  INTEG STATE VECTORS
021517,000054: 31,2032           06006        V83CALL            TC       INTPRET                               
021518,000055: 31,2033           77650                           GOTO                                           
021519,000056: 31,2034           62140                                    STATEXTP                              #  EXTRAPOLATE STATE VECTORS
021520,000057: 31,2035           52375        COMPDISP           VLOAD    VSU                                   
021521,000058: 31,2036           00001                                    RATT                                  
021522,000059: 31,2037           02327                                    RONE                                  
021523,000060: 31,2040           51406                           PUSH     ABVAL                                 #  RATT-RONE TO 0D       PD= 6
021524,000061: 31,2041           02321                           STORE    RANGE                                 #  METERS B-29
021525,000062: 31,2042           77301                           NORM     VLOAD                                 
021526,000063: 31,2043           00047                                    X1                                    #  RATT-RONE             PD= 0
021527,000064: 31,2044           77762                           VSR1                                           
021528,000065: 31,2045           53457                           VSL*     UNIT                                  
021529,000066: 31,2046           20201                                    0,1                                   
021530,000067: 31,2047           52315                           PDVL     VSU                                   #  UNIT(LOS) TO 0D       PD= 6

Page 506

021532,000069: 31,2050           00007                                    VATT                                  
021533,000070: 31,2051           02335                                    VONE                                  
021534,000071: 31,2052           77641                           DOT                                            #  (VATT-VONE).UNIT(LOS) PD= 0
021535,000072: 31,2053           77752                           SL1                                            
021536,000073: 31,2054           36323                           STCALL   RRATE                                 #  RANGE RATE M/CS B-7
021537,000074: 31,2055           47477                                    CDUTRIG                               #  TO INITIALIZE FOR *NBSM*
021538,000075: 31,2056           77624                           CALL                                           
021539,000076: 31,2057           62311                                    R34LOS                                #  NOTE.  PDL MUST = 0.
021540,000077: 31,2060           53575        R34ANG             VLOAD    UNIT                                  
021541,000078: 31,2061           02327                                    RONE                                  
021542,000079: 31,2062           77715                           PDVL                                           #  UR TO 0D              PD= 6
021543,000080: 31,2063           15333                                    THISAXIS                              #  UNITX FOR CM, UNITZ FOR LM
021544,000081: 31,2064           77214                           BON      VLOAD                                 #  CHK R31FLAG.  ON=R31 THETA, OFF=R34 PHI
021545,000082: 31,2065           04713                                    R31FLAG                               
021546,000083: 31,2066           62070                                    +2                                    #  R31-THETA
021547,000084: 31,2067           00015                                    12D                                   
021548,000085: 31,2070           77624                           CALL                                           
021549,000086: 31,2071           47646                                    *NBSM*                                
021550,000087: 31,2072           41505                           VXM      PUSH                                  #  UXORZ TO 6D           PD=12D
021551,000088: 31,2073           01736                                    REFSMMAT                              
021552,000089: 31,2074           72431                           VPROJ    VSL2                                  
021553,000090: 31,2075           00001                                    0D                                    
021554,000091: 31,2076           53445                           BVSU     UNIT                                  
021555,000092: 31,2077           00007                                    6D                                    
021556,000093: 31,2100           47315                           PDVL     VXV                                   #  UP/2 TO 12D           PD=18D
021557,000094: 31,2101           02327                                    RONE                                  
021558,000095: 31,2102           02335                                    VONE                                  
021559,000096: 31,2103           47256                           UNIT     VXV                                   
021560,000097: 31,2104           02327                                    RONE                                  
021561,000098: 31,2105           63241                           DOT      PDVL                                  #  SIGN TO 12D, UP/2 TO MPAC     PD=18D
021562,000099: 31,2106           00015                                    12D                                   
021563,000100: 31,2107           50372                           VSL1     DOT                                   #  UP.UXORZ
021564,000101: 31,2110           00007                                    6D                                    
021565,000102: 31,2111           72565                           SIGN     SL1                                   
021566,000103: 31,2112           00015                                    12D                                   
021567,000104: 31,2113           77726                           ACOS                                           
021568,000105: 31,2114           26325                           STOVL    RTHETA                                
021569,000106: 31,2115           02327                                    RONE                                  
021570,000107: 31,2116           51041                           DOT      BPL                                   
021571,000108: 31,2117           00007                                    6D                                    
021572,000109: 31,2120           62125                                    +5                                    
021573,000110: 31,2121           44345                           DLOAD    BDSU                                  #  IF UXORZ.R NEG, RTHETA = 1 - RTHETA
021574,000111: 31,2122           02325                                    RTHETA                                
021575,000112: 31,2123           15343                                    DPPOSMAX                              
021576,000113: 31,2124           02325                           STORE    RTHETA                                #  RTHETA BETWEEN 0 AND 1 REV.
021577,000114: 31,2125           77776                           EXIT                                           
021578,000115: 31,2126           35013                           CAF      BIT5                                  #  HAVE WE BEEN ANSWERED
021579,000116: 31,2127           71044                           MASK     EXTVBACT                              
021580,000117: 31,2130           00006                           EXTEND                                         
021581,000118: 31,2131           15534                           BZF      ENDEXT                                #  YES, DIE

Page 507

021583,000120: 31,2132           41044                           CS       EXTVBACT                              
021584,000121: 31,2133           75004                           MASK     BIT12                                 
021585,000122: 31,2134           27044                           ADS      EXTVBACT                              
021586,000123: 
021587,000124: 31,2135           12027                           TCF      V83                                   
021588,000125: 31,2136           04066        V16N54             VN       1654                                  
021589,000126: 31,2137           04065        V16N53             VN       1653                                  
021590,000127: 

Page 508

021592,000129:                                                                                                  #  STATEXTP DOES AN INITIAL PRECISION EXTRAPOLATION OF THE
021593,000130:                                                                                                  #  LEM STATE VECTOR TO PRESENT TIME OR TO PIPTIME IF AV G
021594,000131:                                                                                                  #  IS ON AND SAVES AS BASE VECTOR. IF AV G IS ON RN + VN
021595,000132:                                                                                                  #  ARE USED AS THE CM STATE VECTOR AND THE INITIAL R RDOT
021596,000133:                                                                                                  #  RTHETA ARE COMPUTED WITH NO FURTHER INTEGRATION. IF AV
021597,000134:                                                                                                  #  G IS OFF A PRECISION EXTRAPOLATION IS MADE OF THE CM
021598,000135:                                                                                                  #  STATE VECTOR TO PRESENT TIME AND.....
021599,000136: 
021600,000137:                                                                                                  #    THE CM + LM STATE VECTORS ARE INTEGRATED TO PRES TIME
021601,000138:                                                                                                  #    USING PRECISION OR CONIC AS SURFFLAG IS SET OR CLEAR.
021602,000139: 
021603,000140:                                                                                                  #    IF AV G IS ON THEN SUBSEQUENT PASSES WILL PROVIDE
021604,000141:                                                                                                  #      USE OF RN + VN AS CM STATE VECTOR AND THE LM STATE
021605,000142:                                                                                                  #      VECTOR WILL BE PRECISION INTEGRATED USING LEMPREC
021606,000143: 
021607,000144:                                                                                                  #    IF SURFFLAG IS SET.
021608,000145:                                                                                                  #      CM STATE VECTOR RONE VONE + LM STATE VECTOR RATT
021609,000146:                                                                                                  #      VATT ARE USED IN COMPUTING R RDOT RTHETA.
021610,000147: 
021611,000148: 
021612,000149: 31,2140           43034        STATEXTP           RTB      BOF                                   #  INITIAL INTEGRATION
021613,000150: 31,2141           45510                                    LOADTIME                              
021614,000151: 31,2142           03751                                    V37FLAG                               
021615,000152: 31,2143           62146                                    +3                                    #  AV G OFF, USE PRES TIME
021616,000153: 31,2144           77624                           CALL                                           
021617,000154: 31,2145           62273                                    GETRVN                                #       ON,  USE RN VN PIPTIME
021618,000155: 31,2146           02343                           STORE    BASETIME                              #  PRES TIME OR PIPTIME
021619,000156: 31,2147           34041                           STCALL   TDEC1                                 
021620,000157: 31,2150           27105                                    LEMPREC                               
021621,000158: 31,2151           77775                           VLOAD                                          #  BASE VECTOR, LM
021622,000159: 31,2152           00017                                    RATT1                                 
021623,000160: 31,2153           26225                           STOVL    BASEOTP                               #    POS.
021624,000161: 31,2154           00025                                    VATT1                                 
021625,000162: 31,2155           02241                           STORE    BASEOTV                               #    VEL.
021626,000163: 31,2156           71214                           BON      DLOAD                                 
021627,000164: 31,2157           03711                                    V37FLAG                               
021628,000165: 31,2160           62035                                    COMPDISP                              #  COMPUTE R RDOT RTHETA FROM
021629,000166:                                                                                                  #  RONE(RN) VONE(VN) RATT+VATT(LEMPREC)
021630,000167: 31,2161           00015                                    TAT                                   
021631,000168: 31,2162           34041                           STCALL   TDEC1                                 
021632,000169: 31,2163           27071                                    CSMPREC                               
021633,000170: 31,2164           77775                           VLOAD                                          #  BASE VECTOR, CM
021634,000171: 31,2165           00017                                    RATT1                                 
021635,000172: 31,2166           26255                           STOVL    BASETHP                               #   POS.
021636,000173: 31,2167           00025                                    VATT1                                 
021637,000174: 31,2170           02263                           STORE    BASETHV                               #   VEL.
021638,000175: 31,2171           47014        HAVEBASE           BON      RTB                                   #  SUBSEQUENT INTEGRATIONS
021639,000176: 31,2172           03711                                    V37FLAG                               
021640,000177: 31,2173           62256                                    GETRVN5                               
021641,000178: 31,2174           45510                                    LOADTIME                              
021642,000179: 31,2175           34041                           STCALL   TDEC1                                 #  AV G OFF. SET INTEG. OF CM
021643,000180: 31,2176           27442                                    INTSTALL                              
021644,000181: 31,2177           43175                           VLOAD    CLEAR                                 
021645,000182: 31,2200           02255                                    BASETHP                               

Page 509

021647,000184: 31,2201           00263                                    MOONFLAG                              
021648,000185: 31,2202           25535                           STOVL    RCV                                   
021649,000186: 31,2203           02263                                    BASETHV                               
021650,000187: 31,2204           15543                           STODL    VCV                                   
021651,000188: 31,2205           02343                                    BASETIME                              
021652,000189: 31,2206           43014                           BOF      SET                                   #  GET APPROPRIATE MOONFLAG SETTING
021653,000190: 31,2207           04343                                    MOONTHIS                              
021654,000191: 31,2210           62212                                    +2                                    
021655,000192: 31,2211           00063                                    MOONFLAG                              
021656,000193: 31,2212           77614                           CLEAR                                          
021657,000194: 31,2213           01673                                    INTYPFLG                              
021658,000195: 31,2214           43014                           BON      SET                                   
021659,000196: 31,2215           04307                                    SURFFLAG                              
021660,000197: 31,2216           62220                                    +2                                    #  PREC. IF LM DOWN
021661,000198: 31,2217           01473                                    INTYPFLG                              #  CONIC IF LM NOT DOWN
021662,000199: 31,2220           35517                           STCALL   TET                                   
021663,000200: 31,2221           27135                                    INTEGRVS                              #  INTEGRATION --- AT LAST---
021664,000201: 31,2222           77775                           VLOAD                                          
021665,000202: 31,2223           00001                                    RATT                                  
021666,000203: 31,2224           26327                           STOVL    RONE                                  
021667,000204: 31,2225           00007                                    VATT                                  
021668,000205: 31,2226           16335                           STODL    VONE                                  #  GET SET FOR CONIC EXTRAP.,OTHER
021669,000206: 31,2227           00015                                    TAT                                   
021670,000207: 31,2230           45014                           BON      CALL                                  
021671,000208: 31,2231           04307                                    SURFFLAG                              
021672,000209: 31,2232           62267                                    GETRVN6                               #  LEMPREC IF LM DOWN
021673,000210: 31,2233           27442                                    INTSTALL                              #  ..CONIC IF NOT DOWN
021674,000211: 31,2234           77614                           SET                                            
021675,000212: 31,2235           01473                                    INTYPFLG                              
021676,000213: 31,2236           00041        OTHINT             STORE    TDEC1                                 #  ENTERED IF AV G ON TO INTEG LM
021677,000214: 31,2237           43175                           VLOAD    CLEAR                                 
021678,000215: 31,2240           02225                                    BASEOTP                               
021679,000216: 31,2241           00263                                    MOONFLAG                              
021680,000217: 31,2242           25535                           STOVL    RCV                                   
021681,000218: 31,2243           02241                                    BASEOTV                               
021682,000219: 31,2244           15543                           STODL    VCV                                   
021683,000220: 31,2245           02343                                    BASETIME                              
021684,000221: 31,2246           43014                           BOF      SET                                   
021685,000222: 31,2247           04343                                    MOONTHIS                              
021686,000223: 31,2250           62252                                    +2                                    
021687,000224: 31,2251           00063                                    MOONFLAG                              
021688,000225: 31,2252           35517                           STCALL   TET                                   
021689,000226: 31,2253           27135                                    INTEGRVS                              
021690,000227: 31,2254           77650                           GOTO                                           
021691,000228: 31,2255           62035                                    COMPDISP                              #  COMPUTE R RDOT RTHETA         
021692,000229: 31,2256           77624        GETRVN5            CALL                                           #  AV G ON
021693,000230: 31,2257           62273                                    GETRVN                                
021694,000231: 31,2260           45014                           BON      CALL                                  
021695,000232: 31,2261           04307                                    SURFFLAG                              
021696,000233: 31,2262           62267                                    GETRVN6                               #  LM DOWN, LMPREC

Page 510

021698,000235: 31,2263           27442                                    INTSTALL                              
021699,000236: 31,2264           52014                           CLEAR    GOTO                                  
021700,000237: 31,2265           01673                                    INTYPFLG                              
021701,000238: 31,2266           62236                                    OTHINT                                
021702,000239: 31,2267           34041        GETRVN6            STCALL   TDEC1                                 
021703,000240: 31,2270           27105                                    LEMPREC                               
021704,000241: 31,2271           77650                           GOTO                                           
021705,000242: 31,2272           62035                                    COMPDISP                              #  COMPUTE R RDOT RTHETA
021706,000243: 31,2273           77620        GETRVN             STQ                                            
021707,000244: 31,2274           00000                                    0D                                    
021708,000245: 31,2275           52175                           VLOAD    GOTO                                  #  AV G ON, RONE = RN VONE = VN
021709,000246: 31,2276           01171                                    RN                                    #   AND USE PIPTIME
021710,000247: 31,2277           62300                                    +1                                    
021711,000248: 31,2300           36327                           STCALL   RONE                                  
021712,000249: 31,2301           62302                                    +1                                    
021713,000250: 31,2302           52175                           VLOAD    GOTO                                  
021714,000251: 31,2303           01177                                    VN                                    
021715,000252: 31,2304           62305                                    +1                                    
021716,000253: 31,2305           16335                           STODL    VONE                                  
021717,000254: 31,2306           01205                                    PIPTIME                               
021718,000255: 31,2307           77650                           GOTO                                           
021719,000256: 31,2310           00000                                    0D                                    
021720,000257: 31,2000                                           SETLOC   R34                                   
021721,000258: 31,2000                                           BANK                                           
021722,000259: 31,2311           77776        R34LOS             EXIT                                           
021723,000260: 31,2312           30036                           CA       CDUS                                  
021724,000261: 31,2313           50120                           INDEX    FIXLOC                                
021725,000262: 31,2314           54011                           TS       9D                                    
021726,000263: 31,2315           30035                           CA       CDUT                                  
021727,000264: 31,2316           50120                           INDEX    FIXLOC                                
021728,000265: 31,2317           54013                           TS       11D                                   
021729,000266: 31,2320           30120                           CA       FIXLOC                                
021730,000267: 31,2321           66211                           AD       SIX                                   
021731,000268: 31,2322           40000                           COM                                            
021732,000269: 31,2323           50120                           INDEX    FIXLOC                                
021733,000270: 31,2324           54046                           TS       X1                                    
021734,000271: 31,2325           06006                           TC       INTPRET                               
021735,000272: 31,2326           77624                           CALL                                           
021736,000273: 31,2327           46000                                    SXTNB                                 
021737,000274: 31,2330           34015                           STCALL   12D                                   
021738,000275: 31,2331           62060                                    R34ANG                                

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