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.

057611,000002:                                                                                                  ## Copyright:   Public domain.
057612,000003:                                                                                                  ## Filename:    INFLIGHT_ALIGNMENT_ROUTINES.agc
057613,000004:                                                                                                  ## Purpose:     A section of Manche45 revision 2.
057614,000005:                                                                                                  ##              It is part of the reconstructed source code for the
057615,000006:                                                                                                  ##              final, flown release of the flight software for the Command
057616,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
057617,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
057618,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
057619,000010:                                                                                                  ##              exactly match those specified for Manche 45/2 in NASA drawing
057620,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
057621,000012:                                                                                                  ##              reconstruction is correct.
057622,000013:                                                                                                  ## Assembler:   yaYUL
057623,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
057624,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
057625,000016:                                                                                                  ## Mod history: 2020-12-24 MAS  Created from Comanche 45.
057626,000017: 

Page 1355

057628,000019: 22,3510                                           BANK     22                                    
057629,000020: 23,2000                                           SETLOC   INFLIGHT                              
057630,000021: 23,2000                                           BANK                                           
057631,000022: 
057632,000023: 23,3205  E5,1671                                  EBANK=   XSM                                   
057633,000024: 
057634,000025:                                                                                                  #  CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
057635,000026: 
057636,000027:                                                                                                  #  THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES.  THE THREE
057637,000028:                                                                                                  #  HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
057638,000029: 
057639,000030:                                                                                                  #  THE OUTPUTS ARE THE THREE GYRO TORQUING ANGLES TO BE APPLIED TO THE Y, Z, AND X GYROS AND ARE STORED DP AT IGC,
057640,000031:                                                                                                  #  MGC, AND OGC RESPECTIVELY.
057641,000032: 
057642,000033: 23,3205                                           COUNT    23/INFLT                              
057643,000034: 
057644,000035: 23,3205           71220        CALCGTA            ITA      DLOAD                                 #  PUSHDOWN 00-03, 16D-27D, 34D-37D
057645,000036: 23,3206           00051                                    S2                                    #  XDC = (XD1 XD2 XD3)
057646,000037: 23,3207           02714                                    XDC                                   #  YDC = (YD1 YD2 YD3)
057647,000038: 23,3210           65325                           PDDL     PDDL                                  #  ZDC = (ZD1 ZD2 ZD3)
057648,000039: 23,3211           15335                                    HI6ZEROS                              
057649,000040: 23,3212           02720                                    XDC        +4                         
057650,000041: 23,3213           55476                           DCOMP    VDEF                                  
057651,000042: 23,3214           77656                           UNIT                                           
057652,000043: 23,3215           14027                           STODL    ZPRIME                                #  ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
057653,000044: 23,3216           00027                                    ZPRIME                                
057654,000045: 
057655,000046: 23,3217           77742                           SR1                                            
057656,000047: 23,3220           14023                           STODL    SINTH                                 #  SIN(IGC) = ZP1
057657,000048: 23,3221           00033                                    ZPRIME     +4                         
057658,000049: 23,3222           77742                           SR1                                            
057659,000050: 23,3223           34021                           STCALL   COSTH                                 #  COS(IGC) = ZP3
057660,000051: 23,3224           47256                                    ARCTRIG                               
057661,000052: 
057662,000053: 23,3225           16762                           STODL    IGC                                   #  Y GYRO TORQUING ANGLE   FRACTION OF REV.
057663,000054: 23,3226           02716                                    XDC        +2                         
057664,000055: 23,3227           77742                           SR1                                            
057665,000056: 23,3230           14023                           STODL    SINTH                                 #  SIN(MGC) = XD2
057666,000057: 23,3231           00027                                    ZPRIME                                
057667,000058: 
057668,000059: 23,3232           65205                           DMP      PDDL                                  
057669,000060: 23,3233           02720                                    XDC        +4                         #  PD00 = (ZP1)(XD3)
057670,000061: 23,3234           00033                                    ZPRIME     +4                         
057671,000062: 
057672,000063: 23,3235           45205                           DMP      DSU                                   
057673,000064: 23,3236           02714                                    XDC                                   #  MPAC = (ZP3)(XD1)
057674,000065: 23,3237           77626                           STADR                                          
057675,000066: 23,3240           43756                           STCALL   COSTH                                 #  COS(MGC) = MPAC - PD00
057676,000067: 23,3241           47256                                    ARCTRIG                               

Page 1356

057678,000069: 23,3242           26764                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
057679,000070: 23,3243           00027                                    ZPRIME                                
057680,000071: 23,3244           77641                           DOT                                            
057681,000072: 23,3245           02730                                    ZDC                                   
057682,000073: 23,3246           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
057683,000074: 23,3247           00027                                    ZPRIME                                
057684,000075: 23,3250           77641                           DOT                                            
057685,000076: 23,3251           02722                                    YDC                                   
057686,000077: 23,3252           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
057687,000078: 23,3253           47256                                    ARCTRIG                               
057688,000079: 
057689,000080: 23,3254           36760                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
057690,000081: 23,3255           00051                                    S2                                    
057691,000082: 

Page 1357

057693,000084:                                                                                                  #  ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
057694,000085: 
057695,000086:                                                                                                  #  THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
057696,000087: 
057697,000088:                                                                                                  #  THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA.  THE OUTPUT IS ALSO
057698,000089:                                                                                                  #  AVAILABLE AT MPAC.
057699,000090: 
057700,000091: 23,3256           51545        ARCTRIG            DLOAD    ABS                                   #  PUSHDOWN  16D-21D
057701,000092: 23,3257           00023                                    SINTH                                 
057702,000093: 23,3260           50025                           DSU      BMN                                   
057703,000094: 23,3261           07474                                    QTSN45                                #  ABS(SIN/4) - SIN(45)/4
057704,000095: 23,3262           47271                                    TRIG1                                 #  IF (-45,45) OR (135,-135)
057705,000096: 
057706,000097: 23,3263           72545                           DLOAD    SL1                                   #  (45,135) OR (-135,-45)
057707,000098: 23,3264           00021                                    COSTH                                 
057708,000099: 23,3265           75326                           ACOS     SIGN                                  
057709,000100: 23,3266           00023                                    SINTH                                 
057710,000101: 23,3267           00025                           STORE    THETA                                 #  X = ARCCOS(COS) WITH SIGN(SIN)
057711,000102: 23,3270           77616                           RVQ                                            
057712,000103: 
057713,000104: 23,3271           72545        TRIG1              DLOAD    SL1                                   #  (-45,45) OR (135,-135)
057714,000105: 23,3272           00023                                    SINTH                                 
057715,000106: 23,3273           77736                           ASIN                                           
057716,000107: 23,3274           14025                           STODL    THETA                                 #  X = ARCSIN(SIN) WITH SIGN(SIN)
057717,000108: 23,3275           00021                                    COSTH                                 
057718,000109: 23,3276           77640                           BMN                                            
057719,000110: 23,3277           47302                                    TRIG2                                 #  IF (135,-135)
057720,000111: 
057721,000112: 23,3300           43545                           DLOAD    RVQ                                   
057722,000113: 23,3301           00025                                    THETA                                 #  X = ARCSIN(SIN)   (-45,45)
057723,000114: 
057724,000115: 23,3302           75345        TRIG2              DLOAD    SIGN                                  #  (135,-135)
057725,000116: 23,3303           15333                                    HIDPHALF                              
057726,000117: 23,3304           00023                                    SINTH                                 
057727,000118: 23,3305           77625                           DSU                                            
057728,000119: 23,3306           00025                                    THETA                                 
057729,000120: 23,3307           00025                           STORE    THETA                                 #  X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
057730,000121: 23,3310           77616                           RVQ                                            #        (+) - (+) OR (-) - (-)
057731,000122: 

Page 1358

057733,000124:                                                                                                  #  SMNB, NBSM, AND AXISROT, WHICH USED TO APPEAR HERE, HAVE BEEN
057734,000125:                                                                                                  #  COMBINED IN A ROUTINE CALLED AX*SR*T, WHICH APPEARS AMONG THE POWERED
057735,000126:                                                                                                  #  FLIGHT SUBROUTINES.
057736,000127: 

Page 1359

057738,000129:                                                                                                  #  CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
057739,000130: 
057740,000131:                                                                                                  #  THE INPUTS ARE  1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM.  THE THREE HALF-UNIT
057741,000132:                                                                                                  #  VECTORS ARE STORED AT XNB, YNB, AND ZNB.  2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
057742,000133:                                                                                                  #  COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
057743,000134: 
057744,000135:                                                                                                  #  THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
057745,000136: 
057746,000137: 23,3311           77601        CALCGA             SETPD                                          #  PUSHDOWN 00-05, 16D-21D, 34D-37D
057747,000138: 23,3312           00001                                    0                                     
057748,000139: 23,3313           47375                           VLOAD    VXV                                   
057749,000140: 23,3314           02714                                    XNB                                   #  XNB = OGA (OUTER GIMBAL AXIS)
057750,000141: 23,3315           02700                                    YSM                                   #  YSM = IGA (INNER GIMBAL AXIS)
057751,000142: 23,3316           41456                           UNIT     PUSH                                  #  PD0 = UNIT(OGA X IGA) = MGA
057752,000143: 
057753,000144: 23,3317           44041                           DOT      ITA                                   
057754,000145: 23,3320           02730                                    ZNB                                   
057755,000146: 23,3321           00051                                    S2                                    
057756,000147: 23,3322           24021                           STOVL    COSTH                                 #  COS(OG) = MGA . ZNB
057757,000148: 23,3323           00001                                    0                                     
057758,000149: 23,3324           77641                           DOT                                            
057759,000150: 23,3325           02722                                    YNB                                   
057760,000151: 23,3326           34023                           STCALL   SINTH                                 #  SIN(OG) = MGA . YNB
057761,000152: 23,3327           47256                                    ARCTRIG                               
057762,000153: 23,3330           26760                           STOVL    OGC                                   
057763,000154: 23,3331           00001                                    0                                     
057764,000155: 
057765,000156: 23,3332           50235                           VXV      DOT                                   #  PROVISION FOR MG ANGLE OF 90 DEGREES
057766,000157: 23,3333           02714                                    XNB                                   
057767,000158: 23,3334           02700                                    YSM                                   
057768,000159: 23,3335           77752                           SL1                                            
057769,000160: 23,3336           24021                           STOVL    COSTH                                 #  COS(MG) = IGA . (MGA X OGA)
057770,000161: 23,3337           02700                                    YSM                                   
057771,000162: 23,3340           77641                           DOT                                            
057772,000163: 23,3341           02714                                    XNB                                   
057773,000164: 23,3342           34023                           STCALL   SINTH                                 #  SIN(MG) = IGA . OGA
057774,000165: 23,3343           47256                                    ARCTRIG                               
057775,000166: 23,3344           02764                           STORE    MGC                                   
057776,000167: 
057777,000168: 23,3345           45246                           ABS      DSU                                   
057778,000169: 23,3346           07476                                    .166...                               
057779,000170: 23,3347           77644                           BPL                                            
057780,000171: 23,3350           47371                                    GIMLOCK1                              #  IF ANGLE GREATER THAN 60 DEGREES
057781,000172: 
057782,000173: 23,3351           50375        CALCGA1            VLOAD    DOT                                   
057783,000174: 23,3352           02706                                    ZSM                                   
057784,000175: 23,3353           00001                                    0                                     
057785,000176: 23,3354           24021                           STOVL    COSTH                                 #  COS(IG) = ZSM . MGA
057786,000177: 23,3355           02672                                    XSM                                   

Page 1360

057788,000179: 23,3356           45441                           DOT      STADR                                 
057789,000180: 23,3357           43754                           STCALL   SINTH                                 #  SIN(IG) = XSM . MGA
057790,000181: 23,3360           47256                                    ARCTRIG                               
057791,000182: 
057792,000183: 23,3361           26762                           STOVL    IGC                                   
057793,000184: 23,3362           02760                                    OGC                                   
057794,000185: 23,3363           43034                           RTB      BONCLR                                
057795,000186: 23,3364           45552                                    V1STO2S                               
057796,000187: 23,3365           00200                                    CPHIFLAG                              
057797,000188: 23,3366           00051                                    S2                                    
057798,000189: 23,3367           35156                           STCALL   THETAD                                
057799,000190: 23,3370           00051                                    S2                                    
057800,000191: 
057801,000192: 23,3371           77776        GIMLOCK1           EXIT                                           
057802,000193: 23,3372           05650                           TC       ALARM                                 
057803,000194: 23,3373           00401                           OCT      00401                                 
057804,000195: 23,3374           05546                           TC       UPFLAG                                #  GIMBAL LOCK HAS OCCURED
057805,000196: 23,3375           00056                           ADRES    GLOKFAIL                              
057806,000197: 
057807,000198: 23,3376           06006                           TC       INTPRET                               
057808,000199: 23,3377           77650                           GOTO                                           
057809,000200: 23,3400           47351                                    CALCGA1                               
057810,000201: 

Page 1361

057812,000203:                                                                                                  #  AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
057813,000204: 
057814,000205:                                                                                                  #  THE INPUTS ARE  1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD.  2) THE STAR2 VECTOR
057815,000206:                                                                                                  #  REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6.  3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
057816,000207:                                                                                                  #  AT LOCATION 6 OF THE VAC AREA.  4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
057817,000208:                                                                                                  #  THE VAC AREA.
057818,000209: 
057819,000210:                                                                                                  #  THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B.  THE THREE HALF-UNIT VECTORS ARE STORED
057820,000211:                                                                                                  #  AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
057821,000212: 
057822,000213: 23,3401           66370        AXISGEN            AXT,1    SSP                                   #  PUSHDOWN 00-30D, 34D-37D
057823,000214: 23,3402           02743                                    STARAD     +6                         
057824,000215: 23,3403           00051                                    S1                                    
057825,000216: 23,3404           02727                                    STARAD     -6                         
057826,000217: 
057827,000218: 23,3405           77601                           SETPD                                          
057828,000219: 23,3406           00001                                    0                                     
057829,000220: 23,3407           46773        AXISGEN1           VLOAD*   VXV*                                  #  06D   UA = S1
057830,000221: 23,3410           02752                                    STARAD     +12D,1                     #        STARAD +00D     UB = S1
057831,000222: 23,3411           02760                                    STARAD     +18D,1                     
057832,000223: 23,3412           77656                           UNIT                                           #  12D   VA = UNIT(S1 X S2)
057833,000224: 23,3413           06760                           STORE    STARAD     +18D,1                     #        STARAD +06D     VB = UNIT(S1 X S2)
057834,000225: 23,3414           77773                           VLOAD*                                         
057835,000226: 23,3415           02752                                    STARAD     +12D,1                     
057836,000227: 
057837,000228: 23,3416           76433                           VXV*     VSL1                                  
057838,000229: 23,3417           02760                                    STARAD     +18D,1                     #  18D   WA = UA X VA
057839,000230: 23,3420           06766                           STORE    STARAD     +24D,1                     #        STARAD +12D     WB = UB X VB
057840,000231: 
057841,000232: 23,3421           77700                           TIX,1                                          
057842,000233: 23,3422           47407                                    AXISGEN1                              
057843,000234: 
057844,000235: 23,3423           66160                           AXC,1    SXA,1                                 
057845,000236: 23,3424           00006                                    6                                     
057846,000237: 23,3425           00036                                    30D                                   
057847,000238: 
057848,000239: 23,3426           66370                           AXT,1    SSP                                   
057849,000240: 23,3427           00022                                    18D                                   
057850,000241: 23,3430           00051                                    S1                                    
057851,000242: 23,3431           00006                                    6                                     
057852,000243: 
057853,000244: 23,3432           66374                           AXT,2    SSP                                   
057854,000245: 23,3433           00006                                    6                                     
057855,000246: 23,3434           00052                                    S2                                    
057856,000247: 23,3435           00002                                    2                                     
057857,000248: 
057858,000249: 23,3436           76720        AXISGEN2           XCHX,1   VLOAD*                                
057859,000250: 23,3437           00036                                    30D                                   #  X1=-6 X2=+6   X1=-6 X2=+4     X1=-6 X2=+2
057860,000251: 23,3440           00001                                    0,1                                   
057861,000252: 

Page 1362

057863,000254: 23,3441           62757                           VXSC*    PDVL*                                 #  J=(UA)(UB1)   J=(UA)(UB2)     J=(UA)(UB3)
057864,000255: 23,3442           75033                                    STARAD     +6,2                       
057865,000256: 23,3443           00007                                    6,1                                   
057866,000257: 23,3444           77757                           VXSC*                                          
057867,000258: 23,3445           75025                                    STARAD     +12D,2                     
057868,000259: 23,3446           30031                           STOVL*   24D                                   #  K=(VA)(VB1)   J=(VA)(VB2)     J=(VA)(VB3)
057869,000260: 23,3447           00015                                    12D,1                                 
057870,000261: 
057871,000262: 23,3450           53357                           VXSC*    VAD                                   
057872,000263: 23,3451           75017                                    STARAD     +18D,2                     #  L=(WA)(WB1)   J=(WA)(WB2)     J=(WA)(WB3)
057873,000264: 23,3452           76455                           VAD      VSL1                                  
057874,000265: 23,3453           00031                                    24D                                   
057875,000266: 23,3454           53520                           XCHX,1   UNIT                                  
057876,000267: 23,3455           00036                                    30D                                   
057877,000268: 23,3456           06736                           STORE    XDC        +18D,1                     #  XDC = L+J+K   YDC = L+J+K     ZDC = L+J+K
057878,000269: 
057879,000270: 23,3457           77700                           TIX,1                                          
057880,000271: 23,3460           47461                                    AXISGEN3                              
057881,000272: 
057882,000273: 23,3461           77704        AXISGEN3           TIX,2                                          
057883,000274: 23,3462           47436                                    AXISGEN2                              
057884,000275: 
057885,000276: 23,3463           77775                           VLOAD                                          
057886,000277: 23,3464           02714                                    XDC                                   
057887,000278: 23,3465           26736                           STOVL    STARAD                                
057888,000279: 23,3466           02722                                    YDC                                   
057889,000280: 23,3467           26744                           STOVL    STARAD     +6                         
057890,000281: 23,3470           02730                                    ZDC                                   
057891,000282: 23,3471           02752                           STORE    STARAD     +12D                       
057892,000283: 
057893,000284: 23,3472           77616                           RVQ                                            
057894,000285: 

Page 1363

057896,000287: 23,3473           05520 26075  QTSN45             2DEC     .1768                                 
057897,000288: 23,3475           05252 25253  .166...            2DEC     .1666666667                            
057898,000289: 

Page 1364 This page is empty.

057901,000292: 
057902,000293: 
057903,000294: 

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