Source Code

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

The starting point was the source code of Comanche 51 (separately previously reconstructed from an Apollo-era listing of Comanche 55, flown on Apollo 11). Comanche 51 source code was then modified by undoing changes known to have been made between revisions 44 and 51. The now-reconstructed Comanche 44 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 printout, although the source code would likely have different page numbers in a contemporary Comanche 44 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 51. Here's a guide to the Apollo documentation referenced in those annotations:
In most cases, only the titles (rather than the full texts) of PCRs are known. In addition to the explanatory annotations, there is also a step-by-step commentary about the reconstruction process.

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.

058185,000002:                                                                                                  ## Copyright:   Public domain.
058186,000003:                                                                                                  ## Filename:    INFLIGHT_ALIGNMENT_ROUTINES.agc
058187,000004:                                                                                                  ## Purpose:     A section of Comanche revision 044.
058188,000005:                                                                                                  ##              It is part of the reconstructed source code for the
058189,000006:                                                                                                  ##              original release of the flight software for the Command
058190,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
058191,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
058192,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
058193,000010:                                                                                                  ##              exactly match those specified for Comanche 44 in NASA drawing
058194,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
058195,000012:                                                                                                  ##              reconstruction is correct.
058196,000013:                                                                                                  ## Assembler:   yaYUL
058197,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
058198,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
058199,000016:                                                                                                  ## Mod history: 2020-12-03 MAS  Created from Comanche 51.
058200,000017: 

Page 1355

058202,000019: 22,3510                                           BANK     22                                    
058203,000020: 23,2000                                           SETLOC   INFLIGHT                              
058204,000021: 23,2000                                           BANK                                           
058205,000022: 
058206,000023: 23,3205  E5,1671                                  EBANK=   XSM                                   
058207,000024: 
058208,000025:                                                                                                  #  CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
058209,000026: 
058210,000027:                                                                                                  #  THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES.  THE THREE
058211,000028:                                                                                                  #  HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
058212,000029: 
058213,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,
058214,000031:                                                                                                  #  MGC, AND OGC RESPECTIVELY.
058215,000032: 
058216,000033: 23,3205                                           COUNT    23/INFLT                              
058217,000034: 
058218,000035: 23,3205           71220        CALCGTA            ITA      DLOAD                                 #  PUSHDOWN 00-03, 16D-27D, 34D-37D
058219,000036: 23,3206           00051                                    S2                                    #  XDC = (XD1 XD2 XD3)
058220,000037: 23,3207           02714                                    XDC                                   #  YDC = (YD1 YD2 YD3)
058221,000038: 23,3210           65325                           PDDL     PDDL                                  #  ZDC = (ZD1 ZD2 ZD3)
058222,000039: 23,3211           15335                                    HI6ZEROS                              
058223,000040: 23,3212           02720                                    XDC        +4                         
058224,000041: 23,3213           55476                           DCOMP    VDEF                                  
058225,000042: 23,3214           77656                           UNIT                                           
058226,000043: 23,3215           14027                           STODL    ZPRIME                                #  ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
058227,000044: 23,3216           00027                                    ZPRIME                                
058228,000045: 
058229,000046: 23,3217           77742                           SR1                                            
058230,000047: 23,3220           14023                           STODL    SINTH                                 #  SIN(IGC) = ZP1
058231,000048: 23,3221           00033                                    ZPRIME     +4                         
058232,000049: 23,3222           77742                           SR1                                            
058233,000050: 23,3223           34021                           STCALL   COSTH                                 #  COS(IGC) = ZP3
058234,000051: 23,3224           47256                                    ARCTRIG                               
058235,000052: 
058236,000053: 23,3225           16762                           STODL    IGC                                   #  Y GYRO TORQUING ANGLE   FRACTION OF REV.
058237,000054: 23,3226           02716                                    XDC        +2                         
058238,000055: 23,3227           77742                           SR1                                            
058239,000056: 23,3230           14023                           STODL    SINTH                                 #  SIN(MGC) = XD2
058240,000057: 23,3231           00027                                    ZPRIME                                
058241,000058: 
058242,000059: 23,3232           65205                           DMP      PDDL                                  
058243,000060: 23,3233           02720                                    XDC        +4                         #  PD00 = (ZP1)(XD3)
058244,000061: 23,3234           00033                                    ZPRIME     +4                         
058245,000062: 
058246,000063: 23,3235           45205                           DMP      DSU                                   
058247,000064: 23,3236           02714                                    XDC                                   #  MPAC = (ZP3)(XD1)
058248,000065: 23,3237           77626                           STADR                                          
058249,000066: 23,3240           43756                           STCALL   COSTH                                 #  COS(MGC) = MPAC - PD00
058250,000067: 23,3241           47256                                    ARCTRIG                               

Page 1356

058252,000069: 23,3242           26764                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
058253,000070: 23,3243           00027                                    ZPRIME                                
058254,000071: 23,3244           77641                           DOT                                            
058255,000072: 23,3245           02730                                    ZDC                                   
058256,000073: 23,3246           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
058257,000074: 23,3247           00027                                    ZPRIME                                
058258,000075: 23,3250           77641                           DOT                                            
058259,000076: 23,3251           02722                                    YDC                                   
058260,000077: 23,3252           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
058261,000078: 23,3253           47256                                    ARCTRIG                               
058262,000079: 
058263,000080: 23,3254           36760                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
058264,000081: 23,3255           00051                                    S2                                    
058265,000082: 

Page 1357

058267,000084:                                                                                                  #  ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
058268,000085: 
058269,000086:                                                                                                  #  THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
058270,000087: 
058271,000088:                                                                                                  #  THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA.  THE OUTPUT IS ALSO
058272,000089:                                                                                                  #  AVAILABLE AT MPAC.
058273,000090: 
058274,000091: 23,3256           51545        ARCTRIG            DLOAD    ABS                                   #  PUSHDOWN  16D-21D
058275,000092: 23,3257           00023                                    SINTH                                 
058276,000093: 23,3260           50025                           DSU      BMN                                   
058277,000094: 23,3261           07474                                    QTSN45                                #  ABS(SIN/4) - SIN(45)/4
058278,000095: 23,3262           47271                                    TRIG1                                 #  IF (-45,45) OR (135,-135)
058279,000096: 
058280,000097: 23,3263           72545                           DLOAD    SL1                                   #  (45,135) OR (-135,-45)
058281,000098: 23,3264           00021                                    COSTH                                 
058282,000099: 23,3265           75326                           ACOS     SIGN                                  
058283,000100: 23,3266           00023                                    SINTH                                 
058284,000101: 23,3267           00025                           STORE    THETA                                 #  X = ARCCOS(COS) WITH SIGN(SIN)
058285,000102: 23,3270           77616                           RVQ                                            
058286,000103: 
058287,000104: 23,3271           72545        TRIG1              DLOAD    SL1                                   #  (-45,45) OR (135,-135)
058288,000105: 23,3272           00023                                    SINTH                                 
058289,000106: 23,3273           77736                           ASIN                                           
058290,000107: 23,3274           14025                           STODL    THETA                                 #  X = ARCSIN(SIN) WITH SIGN(SIN)
058291,000108: 23,3275           00021                                    COSTH                                 
058292,000109: 23,3276           77640                           BMN                                            
058293,000110: 23,3277           47302                                    TRIG2                                 #  IF (135,-135)
058294,000111: 
058295,000112: 23,3300           43545                           DLOAD    RVQ                                   
058296,000113: 23,3301           00025                                    THETA                                 #  X = ARCSIN(SIN)   (-45,45)
058297,000114: 
058298,000115: 23,3302           75345        TRIG2              DLOAD    SIGN                                  #  (135,-135)
058299,000116: 23,3303           15333                                    HIDPHALF                              
058300,000117: 23,3304           00023                                    SINTH                                 
058301,000118: 23,3305           77625                           DSU                                            
058302,000119: 23,3306           00025                                    THETA                                 
058303,000120: 23,3307           00025                           STORE    THETA                                 #  X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
058304,000121: 23,3310           77616                           RVQ                                            #        (+) - (+) OR (-) - (-)
058305,000122: 

Page 1358

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

Page 1359

058312,000129:                                                                                                  #  CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
058313,000130: 
058314,000131:                                                                                                  #  THE INPUTS ARE  1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM.  THE THREE HALF-UNIT
058315,000132:                                                                                                  #  VECTORS ARE STORED AT XNB, YNB, AND ZNB.  2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
058316,000133:                                                                                                  #  COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
058317,000134: 
058318,000135:                                                                                                  #  THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
058319,000136: 
058320,000137: 23,3311           77601        CALCGA             SETPD                                          #  PUSHDOWN 00-05, 16D-21D, 34D-37D
058321,000138: 23,3312           00001                                    0                                     
058322,000139: 23,3313           47375                           VLOAD    VXV                                   
058323,000140: 23,3314           02714                                    XNB                                   #  XNB = OGA (OUTER GIMBAL AXIS)
058324,000141: 23,3315           02700                                    YSM                                   #  YSM = IGA (INNER GIMBAL AXIS)
058325,000142: 23,3316           41456                           UNIT     PUSH                                  #  PD0 = UNIT(OGA X IGA) = MGA
058326,000143: 
058327,000144: 23,3317           44041                           DOT      ITA                                   
058328,000145: 23,3320           02730                                    ZNB                                   
058329,000146: 23,3321           00051                                    S2                                    
058330,000147: 23,3322           24021                           STOVL    COSTH                                 #  COS(OG) = MGA . ZNB
058331,000148: 23,3323           00001                                    0                                     
058332,000149: 23,3324           77641                           DOT                                            
058333,000150: 23,3325           02722                                    YNB                                   
058334,000151: 23,3326           34023                           STCALL   SINTH                                 #  SIN(OG) = MGA . YNB
058335,000152: 23,3327           47256                                    ARCTRIG                               
058336,000153: 23,3330           26760                           STOVL    OGC                                   
058337,000154: 23,3331           00001                                    0                                     
058338,000155: 
058339,000156: 23,3332           50235                           VXV      DOT                                   #  PROVISION FOR MG ANGLE OF 90 DEGREES
058340,000157: 23,3333           02714                                    XNB                                   
058341,000158: 23,3334           02700                                    YSM                                   
058342,000159: 23,3335           77752                           SL1                                            
058343,000160: 23,3336           24021                           STOVL    COSTH                                 #  COS(MG) = IGA . (MGA X OGA)
058344,000161: 23,3337           02700                                    YSM                                   
058345,000162: 23,3340           77641                           DOT                                            
058346,000163: 23,3341           02714                                    XNB                                   
058347,000164: 23,3342           34023                           STCALL   SINTH                                 #  SIN(MG) = IGA . OGA
058348,000165: 23,3343           47256                                    ARCTRIG                               
058349,000166: 23,3344           02764                           STORE    MGC                                   
058350,000167: 
058351,000168: 23,3345           45246                           ABS      DSU                                   
058352,000169: 23,3346           07476                                    .166...                               
058353,000170: 23,3347           77644                           BPL                                            
058354,000171: 23,3350           47371                                    GIMLOCK1                              #  IF ANGLE GREATER THAN 60 DEGREES
058355,000172: 
058356,000173: 23,3351           50375        CALCGA1            VLOAD    DOT                                   
058357,000174: 23,3352           02706                                    ZSM                                   
058358,000175: 23,3353           00001                                    0                                     
058359,000176: 23,3354           24021                           STOVL    COSTH                                 #  COS(IG) = ZSM . MGA
058360,000177: 23,3355           02672                                    XSM                                   

Page 1360

058362,000179: 23,3356           45441                           DOT      STADR                                 
058363,000180: 23,3357           43754                           STCALL   SINTH                                 #  SIN(IG) = XSM . MGA
058364,000181: 23,3360           47256                                    ARCTRIG                               
058365,000182: 
058366,000183: 23,3361           26762                           STOVL    IGC                                   
058367,000184: 23,3362           02760                                    OGC                                   
058368,000185: 23,3363           43034                           RTB      BONCLR                                
058369,000186: 23,3364           45552                                    V1STO2S                               
058370,000187: 23,3365           00200                                    CPHIFLAG                              
058371,000188: 23,3366           00051                                    S2                                    
058372,000189: 23,3367           35156                           STCALL   THETAD                                
058373,000190: 23,3370           00051                                    S2                                    
058374,000191: 
058375,000192: 23,3371           77776        GIMLOCK1           EXIT                                           
058376,000193: 23,3372           05650                           TC       ALARM                                 
058377,000194: 23,3373           00401                           OCT      00401                                 
058378,000195: 23,3374           05546                           TC       UPFLAG                                #  GIMBAL LOCK HAS OCCURED
058379,000196: 23,3375           00056                           ADRES    GLOKFAIL                              
058380,000197: 
058381,000198: 23,3376           06006                           TC       INTPRET                               
058382,000199: 23,3377           77650                           GOTO                                           
058383,000200: 23,3400           47351                                    CALCGA1                               
058384,000201: 

Page 1361

058386,000203:                                                                                                  #  AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
058387,000204: 
058388,000205:                                                                                                  #  THE INPUTS ARE  1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD.  2) THE STAR2 VECTOR
058389,000206:                                                                                                  #  REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6.  3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
058390,000207:                                                                                                  #  AT LOCATION 6 OF THE VAC AREA.  4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
058391,000208:                                                                                                  #  THE VAC AREA.
058392,000209: 
058393,000210:                                                                                                  #  THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B.  THE THREE HALF-UNIT VECTORS ARE STORED
058394,000211:                                                                                                  #  AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
058395,000212: 
058396,000213: 23,3401           66370        AXISGEN            AXT,1    SSP                                   #  PUSHDOWN 00-30D, 34D-37D
058397,000214: 23,3402           02743                                    STARAD     +6                         
058398,000215: 23,3403           00051                                    S1                                    
058399,000216: 23,3404           02727                                    STARAD     -6                         
058400,000217: 
058401,000218: 23,3405           77601                           SETPD                                          
058402,000219: 23,3406           00001                                    0                                     
058403,000220: 23,3407           46773        AXISGEN1           VLOAD*   VXV*                                  #  06D   UA = S1
058404,000221: 23,3410           02752                                    STARAD     +12D,1                     #        STARAD +00D     UB = S1
058405,000222: 23,3411           02760                                    STARAD     +18D,1                     
058406,000223: 23,3412           77656                           UNIT                                           #  12D   VA = UNIT(S1 X S2)
058407,000224: 23,3413           06760                           STORE    STARAD     +18D,1                     #        STARAD +06D     VB = UNIT(S1 X S2)
058408,000225: 23,3414           77773                           VLOAD*                                         
058409,000226: 23,3415           02752                                    STARAD     +12D,1                     
058410,000227: 
058411,000228: 23,3416           76433                           VXV*     VSL1                                  
058412,000229: 23,3417           02760                                    STARAD     +18D,1                     #  18D   WA = UA X VA
058413,000230: 23,3420           06766                           STORE    STARAD     +24D,1                     #        STARAD +12D     WB = UB X VB
058414,000231: 
058415,000232: 23,3421           77700                           TIX,1                                          
058416,000233: 23,3422           47407                                    AXISGEN1                              
058417,000234: 
058418,000235: 23,3423           66160                           AXC,1    SXA,1                                 
058419,000236: 23,3424           00006                                    6                                     
058420,000237: 23,3425           00036                                    30D                                   
058421,000238: 
058422,000239: 23,3426           66370                           AXT,1    SSP                                   
058423,000240: 23,3427           00022                                    18D                                   
058424,000241: 23,3430           00051                                    S1                                    
058425,000242: 23,3431           00006                                    6                                     
058426,000243: 
058427,000244: 23,3432           66374                           AXT,2    SSP                                   
058428,000245: 23,3433           00006                                    6                                     
058429,000246: 23,3434           00052                                    S2                                    
058430,000247: 23,3435           00002                                    2                                     
058431,000248: 
058432,000249: 23,3436           76720        AXISGEN2           XCHX,1   VLOAD*                                
058433,000250: 23,3437           00036                                    30D                                   #  X1=-6 X2=+6   X1=-6 X2=+4     X1=-6 X2=+2
058434,000251: 23,3440           00001                                    0,1                                   
058435,000252: 

Page 1362

058437,000254: 23,3441           62757                           VXSC*    PDVL*                                 #  J=(UA)(UB1)   J=(UA)(UB2)     J=(UA)(UB3)
058438,000255: 23,3442           75033                                    STARAD     +6,2                       
058439,000256: 23,3443           00007                                    6,1                                   
058440,000257: 23,3444           77757                           VXSC*                                          
058441,000258: 23,3445           75025                                    STARAD     +12D,2                     
058442,000259: 23,3446           30031                           STOVL*   24D                                   #  K=(VA)(VB1)   J=(VA)(VB2)     J=(VA)(VB3)
058443,000260: 23,3447           00015                                    12D,1                                 
058444,000261: 
058445,000262: 23,3450           53357                           VXSC*    VAD                                   
058446,000263: 23,3451           75017                                    STARAD     +18D,2                     #  L=(WA)(WB1)   J=(WA)(WB2)     J=(WA)(WB3)
058447,000264: 23,3452           76455                           VAD      VSL1                                  
058448,000265: 23,3453           00031                                    24D                                   
058449,000266: 23,3454           53520                           XCHX,1   UNIT                                  
058450,000267: 23,3455           00036                                    30D                                   
058451,000268: 23,3456           06736                           STORE    XDC        +18D,1                     #  XDC = L+J+K   YDC = L+J+K     ZDC = L+J+K
058452,000269: 
058453,000270: 23,3457           77700                           TIX,1                                          
058454,000271: 23,3460           47461                                    AXISGEN3                              
058455,000272: 
058456,000273: 23,3461           77704        AXISGEN3           TIX,2                                          
058457,000274: 23,3462           47436                                    AXISGEN2                              
058458,000275: 
058459,000276: 23,3463           77775                           VLOAD                                          
058460,000277: 23,3464           02714                                    XDC                                   
058461,000278: 23,3465           26736                           STOVL    STARAD                                
058462,000279: 23,3466           02722                                    YDC                                   
058463,000280: 23,3467           26744                           STOVL    STARAD     +6                         
058464,000281: 23,3470           02730                                    ZDC                                   
058465,000282: 23,3471           02752                           STORE    STARAD     +12D                       
058466,000283: 
058467,000284: 23,3472           77616                           RVQ                                            
058468,000285: 

Page 1363

058470,000287: 23,3473           05520 26075  QTSN45             2DEC     .1768                                 
058471,000288: 23,3475           05252 25253  .166...            2DEC     .1666666667                            
058472,000289: 

Page 1364 This page is empty.

058475,000292: 
058476,000293: 
058477,000294: 

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