Source Code

These source-code files are part of a reconstructed copy of Comanche 51, the initial release (though not the final mission release) of the Apollo 11 Command Module (CM) Apollo Guidance Computer (AGC) software. The flown, final release was Comanche 55. The reconstruction is believed to be exactly accurate, but in the absence of an actual Apollo-era listing of Comanche 51, some explanation of the reconstruction process is needed to insure confidence in that accuracy.

The starting point was the source code of Comanche 55, whose original source code is available. Comanche 55 source code was then modified by undoing changes known to have been made between revisions 51 and 55. The most-significant steps involved reverting changes related to the R-2 lunar potential model, the details of which were known from the previous, separate, independent reconstruction of the Apollo 10 Lunar Module software Luminary 69/2. The now-reconstructed Comanche 51 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 match those on the Comanche 55 or Luminary 69 printouts, although the source code would likely have different page numbers in a contemporary Comanche 51 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 55. Here's a guide to some of the Apollo documentation relevant to those annotations:
Among documentation not actually referenced in the annotations, there is a short writeup about the reconstruction process in our software repository that may be helpful in understanding it from a different perspective. There's also a handy table that lists what the number of memory-words should be for each routine in Comanche 51, which could make a nice double-check; however, we've not performed that double-check ourselves.

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.

017777,000002:                                                                                                  ## Copyright:   Public domain.
017778,000003:                                                                                                  ## Filename:    KALCMANU_STEERING.agc
017779,000004:                                                                                                  ## Purpose:     A section of Comanche revision 051.
017780,000005:                                                                                                  ##              It is part of the reconstructed source code for the
017781,000006:                                                                                                  ##              original release of the flight software for the Command
017782,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 11.
017783,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
017784,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
017785,000010:                                                                                                  ##              exactly match those specified for Comanche 51 in NASA drawing
017786,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
017787,000012:                                                                                                  ##              reconstruction is correct.
017788,000013:                                                                                                  ## Reference:   pp. 414-419
017789,000014:                                                                                                  ## Assembler:   yaYUL
017790,000015:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
017791,000016:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
017792,000017:                                                                                                  ## Mod history: 2019-07-30 MAS  Created from Comanche 55.
017793,000018:                                                                                                  ##              2021-05-30 ABS  ZEROERROR -> ZEROEROR
017794,000019: 

Page 414

017796,000021:                                                                                                  #  GENERATION OF STEERING COMMANDS FOR DIGITAL AUTOPILOT FREE FALL MANEUVERS
017797,000022: 
017798,000023:                                                                                                  #  NEW COMMANDS WILL BE GENERATED EVERY ONE SECOND DURING THE MANEUVER
017799,000024: 
017800,000025: 15,2000                                           BANK     15                                    
017801,000026: 
017802,000027: 22,2000                                           SETLOC   KALCMON1                              
017803,000028: 22,2000                                           BANK                                           
017804,000029: 
017805,000030: 22,3026  E6,1661                                  EBANK=   BCDU                                  
017806,000031: 
017807,000032: 22,3026                                           COUNT    22/KALC                               
017808,000033: 
017809,000034: 22,3026           41332        NEWDELHI           CS       HOLDFLAG                              #  SEE IF MANEUVER HAS BEEN INTERRUPTED
017810,000035: 22,3027           00006                           EXTEND                                         #  BY ASTRONAUT
017811,000036: 22,3030           62726                           BZMF     NOGO       -2                         #  IF SO, TERMINATE KALCMANU
017812,000037: 22,3031           06006        NEWANGL            TC       INTPRET                               
017813,000038: 22,3032           75160                           AXC,1    AXC,2                                 
017814,000039: 22,3033           03320                                    MIS                                   #  COMPUTE THE NEW MATRIX FROM S/C TO
017815,000040: 22,3034           03425                                    DEL                                   #  STABLE MEMBER AXES
017816,000041: 22,3035           77624                           CALL                                           
017817,000042: 22,3036           44304                                    MXM3                                  
017818,000043: 22,3037           45575                           VLOAD    STADR                                 
017819,000044: 22,3040           50442                           STOVL    MIS        +12D                       #  CALCULATE NEW DESIRED CDU ANGLES
017820,000045: 22,3041           77626                           STADR                                          
017821,000046: 22,3042           50450                           STOVL    MIS        +6D                        
017822,000047: 22,3043           77626                           STADR                                          
017823,000048: 22,3044           74456                           STORE    MIS                                   
017824,000049: 22,3045           45160                           AXC,1    CALL                                  
017825,000050: 22,3046           03320                                    MIS                                   
017826,000051: 22,3047           44655                                    DCMTOCDU                              #  PICK UP THE NEW CDU ANGLES FROM MATRIX
017827,000052: 22,3050           77634                           RTB                                            
017828,000053: 22,3051           45552                                    V1STO2S                               
017829,000054: 22,3052           03267                           STORE    NCDU                                  #  NEW CDU ANGLES
017830,000055: 22,3053           77414                           BONCLR   EXIT                                  
017831,000056: 22,3054           01215                                    CALCMAN2                              
017832,000057: 22,3055           40065                                    MANUSTAT                              #  TO START MANEUVER
017833,000058: 22,3056           35016                           CAF      TWO                                   #           +0 OTHERWISE
017834,000059: 22,3057           55664        INCRDCDU           TS       KSPNDX                                
017835,000060: 22,3060           60000                           DOUBLE                                         
017836,000061: 22,3061           55665                           TS       KDPNDX                                
017837,000062: 22,3062           51664                           INDEX    KSPNDX                                
017838,000063: 22,3063           31666                           CA       NCDU                                  #  NEW DESIRED CDU ANGLES
017839,000064: 22,3064           00006                           EXTEND                                         
017840,000065: 22,3065           51664                           INDEX    KSPNDX                                
017841,000066: 22,3066           21661                           MSU      BCDU                                  #  INITIAL S/C ANGLE OR PREVIOUS DESIRED
017842,000067: 22,3067           00006                           EXTEND                                         #  CDU ANGLES
017843,000068: 22,3070           73002                           MP       QUADROT                               
017844,000069: 22,3071           51665                           INDEX    KDPNDX                                
017845,000070: 22,3072           53576                           DXCH     DELCDUX                               #  ANGLE INCREMENTS TO BE ADDED TO

Page 415

017847,000072: 22,3073           51664                           INDEX    KSPNDX                                #  DCDU EVERY TENTH SEC
017848,000073: 22,3074           31666                           CA       NCDU                                  #  BY LEM DAP
017849,000074: 22,3075           51664                           INDEX    KSPNDX                                
017850,000075: 22,3076           57661                           XCH      BCDU                                  
017851,000076: 22,3077           51665                           INDEX    KDPNDX                                
017852,000077: 22,3100           55646                           TS       CDUXD                                 
017853,000078: 22,3101           11664                           CCS      KSPNDX                                
017854,000079: 22,3102           13057                           TCF      INCRDCDU                              #  LOOP FOR THREE AXES
017855,000080: 
017856,000081: 22,3103           00003                           RELINT                                         
017857,000082:                                                                                                  #  COMPARE PRESENT TIME WITH TIME TO TERMINATE MANEUVER
017858,000083: 
017859,000084: 22,3104           03115        TMANUCHK           TC       TIMECHK                               
017860,000085: 22,3105           04701                           TC       POSTJUMP                              
017861,000086: 22,3106           40131                           CADR     CONTMANU                              
017862,000087: 
017863,000088: 22,3107           35017                           CAF      ONE                                   
017864,000089: 22,3110           05245        MANUSTAL           TC       WAITLIST                              
017865,000090: 22,3111  E6,1661                                  EBANK=   BCDU                                  
017866,000091: 22,3111           02000 42066                     2CADR    MANUSTOP                              
017867,000092: 
017868,000093: 22,3113           00003                           RELINT                                         
017869,000094: 22,3114           15217                           TCF      ENDOFJOB                              
017870,000095: 
017871,000096: 
017872,000097: 22,3115           00006        TIMECHK            EXTEND                                         
017873,000098: 22,3116           40025                           DCS      TIME2                                 
017874,000099: 22,3117           53673                           DXCH     TTEMP                                 
017875,000100: 22,3120           00006                           EXTEND                                         
017876,000101: 22,3121           31717                           DCA      TM                                    
017877,000102: 22,3122           21673                           DAS      TTEMP                                 
017878,000103: 22,3123           11672                           CCS      TTEMP                                 
017879,000104: 22,3124           00002                           TC       Q                                     
017880,000105: 22,3125           13127                           TCF      +2                                    
017881,000106: 22,3126           13137                           TCF      2NDRETRN                              
017882,000107: 22,3127           11673                           CCS      TTEMP      +1                         
017883,000108: 22,3130           00002                           TC       Q                                     
017884,000109: 22,3131           13133                           TCF      MANUOFF                               
017885,000110: 22,3132           40000                           COM                                            
017886,000111: 22,3133           65041        MANUOFF            AD       1SEC                                  
017887,000112: 22,3134           00006                           EXTEND                                         
017888,000113: 22,3135           63137                           BZMF     2NDRETRN                              
017889,000114: 22,3136           24002                           INCR     Q                                     
017890,000115: 22,3137           24002        2NDRETRN           INCR     Q                                     
017891,000116: 22,3140           24002                           INCR     Q                                     
017892,000117: 22,3141           00002                           TC       Q                                     
017893,000118: 
017894,000119: 20,2000                                           SETLOC   MANUSTUF                              
017895,000120: 20,2000                                           BANK                                           

Page 416

017897,000122: 20,2065           77776        MANUSTAT           EXIT                                           #  INITIALIZATION ROUTINE
017898,000123: 20,2066           00006                           EXTEND                                         #  FOR AUTOMATIC MANEUVERS
017899,000124: 20,2067           30025                           DCA      TIME2                                 
017900,000125: 20,2070           21717                           DAS      TM                                    #  TM+T0    MANEUVER COMPLETION TIME
017901,000126: 20,2071           45041                           CS       1SEC                                  
017902,000127: 20,2072           54001                           TS       L                                     
017903,000128: 20,2073           45021                           CS       ZERO                                  
017904,000129: 20,2074           21717                           DAS      TM                                    #  (TM+T0)-1
017905,000130: 20,2075           00004                           INHINT                                         
017906,000131: 20,2076           45017                           CS       ONE                                   #  ENABLE AUTOPILOT TO PERFORM
017907,000132: 20,2077           55332                           TS       HOLDFLAG                              #  AUTOMATIC MANEUVERS
017908,000133: 20,2100           41130                           CS       RATEINDX                              #  SEE IF MANEUVERING AT HIGH RATE
017909,000134: 20,2101           66211                           AD       SIX                                   
017910,000135: 20,2102           00006                           EXTEND                                         
017911,000136: 20,2103           62105                           BZMF     HIGHGAIN                              
017912,000137: 20,2104           12110                           TCF      +4                                    
017913,000138: 20,2105           41501        HIGHGAIN           CS       RCSFLAGS                              #  IF SO, SET HIGH RATE FLAG (BIT 15 OF
017914,000139: 20,2106           75001                           MASK     BIT15                                 #  RCSFLAGS)
017915,000140: 20,2107           27501                           ADS      RCSFLAGS                              
017916,000141: 20,2110           53711                           DXCH     BRATE                                 #  X-AXIS MANEUVER RATE
017917,000142: 20,2111           53526                           DXCH     WBODY                                 
017918,000143: 20,2112           53713                           DXCH     BRATE      +2                         #  Y-AXIS MANEUVER RATE
017919,000144: 20,2113           53530                           DXCH     WBODY1                                
017920,000145: 20,2114           53715                           DXCH     BRATE      +4                         #  Z-AXIS MANEUVER RATE
017921,000146: 20,2115           53532                           DXCH     WBODY2                                
017922,000147: 20,2116           31675                           CA       BIASTEMP   +1                         #  INSERT ATTITUDE ERROR BIASES
017923,000148: 20,2117           55564                           TS       BIAS                                  #  INTO AUTOPILOT
017924,000149: 20,2120           31677                           CA       BIASTEMP   +3                         
017925,000150: 20,2121           55565                           TS       BIAS1                                 
017926,000151: 20,2122           31701                           CA       BIASTEMP   +5                         
017927,000152: 20,2123           55566                           TS       BIAS2                                 
017928,000153: 20,2124           30025                           CA       TIME1                                 
017929,000154: 20,2125           65041                           AD       1SEC                                  
017930,000155: 20,2126           57671                           XCH      NEXTIME                               
017931,000156: 20,2127           04701                           TC       POSTJUMP                              
017932,000157: 20,2130           45056                           CADR     INCRDCDU   -1                         
017933,000158: 
017934,000159: 20,2131           00004        CONTMANU           INHINT                                         #  CONTINUE WITH UPDATE PROCESS
017935,000160: 20,2132           40025                           CS       TIME1                                 
017936,000161: 20,2133           61671                           AD       NEXTIME                               
017937,000162: 20,2134           10000                           CCS      A                                     
017938,000163: 20,2135           65017                           AD       ONE                                   
017939,000164: 20,2136           12141                           TCF      MANUCALL                              
017940,000165: 20,2137           65001                           AD       NEGMAX                                
017941,000166: 20,2140           40000                           COM                                            
017942,000167: 20,2141           05245        MANUCALL           TC       WAITLIST                              
017943,000168: 20,2142  E6,1661                                  EBANK=   BCDU                                  
017944,000169: 20,2142           02150 40066                     2CADR    UPDTCALL                              
017945,000170: 
017946,000171: 20,2144           00003                           RELINT                                         

Page 417

017948,000173: 20,2145           35041                           CAF      1SEC                                  #  INCREMENT TIME FOR NEXT UPDATE
017949,000174: 20,2146           27671                           ADS      NEXTIME                               
017950,000175: 20,2147           15217                           TCF      ENDOFJOB                              
017951,000176: 
017952,000177: 
017953,000178: 20,2150           37663        UPDTCALL           CAF      PRIO26                                #  CALL FOR UPDATE
017954,000179: 20,2151           05147                           TC       FINDVAC                               #  OF STEERING COMMANDS
017955,000180: 20,2152  E6,1661                                  EBANK=   BCDU                                  
017956,000181: 20,2152           03026 44066                     2CADR    NEWDELHI                              
017957,000182: 
017958,000183: 20,2154           05324                           TC       TASKOVER                              
017959,000184: 

Page 418

017961,000186:                                                                                                  #  ROUTINE FOR TERMINATING AUTOMATIC MANEUVERS
017962,000187: 
017963,000188: 21,2000                                           SETLOC   KALCMON3                              
017964,000189: 21,2000                                           BANK                                           
017965,000190: 
017966,000191: 21,2000           04537        MANUSTOP           TC       STOPYZ                                
017967,000192: 21,2001           04740                           TC       IBNKCALL                              
017968,000193: 21,2002           45144                           CADR     LOADYZ                                
017969,000194: 
017970,000195: 21,2003           31155        ENDROLL            CA       CPHI                                  
017971,000196: 21,2004           55646                           TS       CDUXD                                 #  SET CDUXD TO THE COMMANDED OUTER GIMBAL
017972,000197: 21,2005           04526                           TC       STOPRATE                              
017973,000198: 21,2006           31327        ENDMANU            CA       ATTPRIO                               #  RESTORE USERS PRIORITY
017974,000199: 21,2007           54063                           TS       NEWPRIO                               
017975,000200: 
017976,000201: 21,2010           35021                           CA       ZERO                                  #  ZERO ATTCADR
017977,000202: 21,2011           53326                           DXCH     ATTCADR                               
017978,000203: 
017979,000204: 21,2012           05160                           TC       SPVAC                                 #  RETURN TO USER OF GOMANUR
017980,000205: 
017981,000206: 21,2013           05324                           TC       TASKOVER                              
017982,000207: 
017983,000208:    4000                                           SETLOC   STOPRAT                               
017984,000209:    4000                                           BANK                                           
017985,000210:    4526           35021        STOPRATE           CAF      ZERO                                  
017986,000211:    4527           55575                           TS       DELCDUX                               
017987,000212:    4530           55576                           TS       DELCDUX    +1                         #  ZERO ROLL INCREMENTAL ANGLES
017988,000213:    4531           55525                           TS       WBODY                                 #  RATE
017989,000214:    4532           55526                           TS       WBODY      +1                         
017990,000215:    4533           55564                           TS       BIAS                                  #  BIAS
017991,000216: 
017992,000217:    4534           45001                           CS       BIT15                                 #  MAKE SURE HIGH RATE FLAG (BIT 15 OF
017993,000218:    4535           71501                           MASK     RCSFLAGS                              #  RCSFLAGS) IS RESET.
017994,000219:    4536           55501                           TS       RCSFLAGS                              
017995,000220: 
017996,000221:    4537           35021        STOPYZ             CAF      ZERO                                  
017997,000222:    4540           55577                           TS       DELCDUY                               #  ZERO PITCH, YAW
017998,000223:    4541           55600                           TS       DELCDUY    +1                         #  INCREMENTAL ANGLES
017999,000224:    4542           55601                           TS       DELCDUZ                               
018000,000225:    4543           55602                           TS       DELCDUZ    +1                         
018001,000226:    4544           55527                           TS       WBODY1                                #  RATES
018002,000227:    4545           55530                           TS       WBODY1     +1                         
018003,000228:    4546           55531                           TS       WBODY2                                
018004,000229:    4547           55532                           TS       WBODY2     +1                         
018005,000230:    4550           55565                           TS       BIAS1                                 #  BIASES
018006,000231:    4551           55566                           TS       BIAS2                                 
018007,000232:    4552           00002                           TC       Q                                     
018008,000233: 
018009,000234: 20,2000                                           SETLOC   MANUSTUF                              
018010,000235: 20,2000                                           BANK                                           
018011,000236: 

Page 419

018013,000238: 20,2155           30032        ZEROEROR           CA       CDUX                                  #  PICK UP CDU ANGLES AND STORE IN
018014,000239: 20,2156           55646                           TS       CDUXD                                 #  CDU DESIRED
018015,000240: 20,2157           30033                           CA       CDUY                                  
018016,000241: 20,2160           55650                           TS       CDUYD                                 
018017,000242: 20,2161           30034                           CA       CDUZ                                  
018018,000243: 20,2162           55652                           TS       CDUZD                                 
018019,000244: 20,2163           00002                           TC       Q                                     
018020,000245: 
018021,000246: 22,2000                                           SETLOC   KALCMON1                              
018022,000247: 22,2000                                           BANK                                           
018023,000248: 
018024,000249: 22,3142           31155        LOADCDUD           CA       CPHI                                  #  STORE TERMINAL ANGLES INTO
018025,000250: 22,3143           55646                           TS       CDUXD                                 #  COMMAND ANGLES
018026,000251: 22,3144           31156        LOADYZ             CA       CTHETA                                
018027,000252: 22,3145           55650                           TS       CDUYD                                 
018028,000253: 22,3146           31157                           CA       CPSI                                  
018029,000254: 22,3147           55652                           TS       CDUZD                                 
018030,000255: 22,3150           00002                           TC       Q                                     

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