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:
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. |
057722,000002: ## Copyright: Public domain.
057723,000003: ## Filename: INFLIGHT_ALIGNMENT_ROUTINES.agc
057724,000004: ## Purpose: A section of Comanche revision 051.
057725,000005: ## It is part of the reconstructed source code for the
057726,000006: ## original release of the flight software for the Command
057727,000007: ## Module's (CM) Apollo Guidance Computer (AGC) for Apollo 11.
057728,000008: ## The code has been recreated from a copy of Comanche 055. It
057729,000009: ## has been adapted such that the resulting bugger words
057730,000010: ## exactly match those specified for Comanche 51 in NASA drawing
057731,000011: ## 2021153D, which gives relatively high confidence that the
057732,000012: ## reconstruction is correct.
057733,000013: ## Reference: pp. 1355-1364
057734,000014: ## Assembler: yaYUL
057735,000015: ## Contact: Ron Burkey <info@sandroid.org>.
057736,000016: ## Website: www.ibiblio.org/apollo/index.html
057737,000017: ## Mod history: 2019-07-30 MAS Created from Comanche 55.
057738,000018:
Page 1355 |
057740,000020: 22,3510 BANK 22
057741,000021: 23,2000 SETLOC INFLIGHT
057742,000022: 23,2000 BANK
057743,000023:
057744,000024: 23,3205 E5,1671 EBANK= XSM
057745,000025:
057746,000026: # CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
057747,000027:
057748,000028: # THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES. THE THREE
057749,000029: # HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
057750,000030:
057751,000031: # THE OUTPUTS ARE THE THREE GYRO TORQUING ANGLES TO BE APPLIED TO THE Y, Z, AND X GYROS AND ARE STORED DP AT IGC,
057752,000032: # MGC, AND OGC RESPECTIVELY.
057753,000033:
057754,000034: 23,3205 COUNT 23/INFLT
057755,000035:
057756,000036: 23,3205 71220 CALCGTA ITA DLOAD # PUSHDOWN 00-03, 16D-27D, 34D-37D
057757,000037: 23,3206 00051 S2 # XDC = (XD1 XD2 XD3)
057758,000038: 23,3207 02714 XDC # YDC = (YD1 YD2 YD3)
057759,000039: 23,3210 65325 PDDL PDDL # ZDC = (ZD1 ZD2 ZD3)
057760,000040: 23,3211 15335 HI6ZEROS
057761,000041: 23,3212 02720 XDC +4
057762,000042: 23,3213 55476 DCOMP VDEF
057763,000043: 23,3214 77656 UNIT
057764,000044: 23,3215 14027 STODL ZPRIME # ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
057765,000045: 23,3216 00027 ZPRIME
057766,000046:
057767,000047: 23,3217 77742 SR1
057768,000048: 23,3220 14023 STODL SINTH # SIN(IGC) = ZP1
057769,000049: 23,3221 00033 ZPRIME +4
057770,000050: 23,3222 77742 SR1
057771,000051: 23,3223 34021 STCALL COSTH # COS(IGC) = ZP3
057772,000052: 23,3224 47256 ARCTRIG
057773,000053:
057774,000054: 23,3225 16762 STODL IGC # Y GYRO TORQUING ANGLE FRACTION OF REV.
057775,000055: 23,3226 02716 XDC +2
057776,000056: 23,3227 77742 SR1
057777,000057: 23,3230 14023 STODL SINTH # SIN(MGC) = XD2
057778,000058: 23,3231 00027 ZPRIME
057779,000059:
057780,000060: 23,3232 65205 DMP PDDL
057781,000061: 23,3233 02720 XDC +4 # PD00 = (ZP1)(XD3)
057782,000062: 23,3234 00033 ZPRIME +4
057783,000063:
057784,000064: 23,3235 45205 DMP DSU
057785,000065: 23,3236 02714 XDC # MPAC = (ZP3)(XD1)
057786,000066: 23,3237 77626 STADR
057787,000067: 23,3240 43756 STCALL COSTH # COS(MGC) = MPAC - PD00
057788,000068: 23,3241 47256 ARCTRIG
Page 1356 |
057790,000070: 23,3242 26764 STOVL MGC # Z GYRO TORQUING ANGLE FRACTION OF REV.
057791,000071: 23,3243 00027 ZPRIME
057792,000072: 23,3244 77641 DOT
057793,000073: 23,3245 02730 ZDC
057794,000074: 23,3246 24021 STOVL COSTH # COS(OGC) = ZP . ZDC
057795,000075: 23,3247 00027 ZPRIME
057796,000076: 23,3250 77641 DOT
057797,000077: 23,3251 02722 YDC
057798,000078: 23,3252 34023 STCALL SINTH # SIN(OGC) = ZP . YDC
057799,000079: 23,3253 47256 ARCTRIG
057800,000080:
057801,000081: 23,3254 36760 STCALL OGC # X GYRO TORQUING ANGLE FRACTION OF REV.
057802,000082: 23,3255 00051 S2
057803,000083:
Page 1357 |
057805,000085: # ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
057806,000086:
057807,000087: # THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
057808,000088:
057809,000089: # THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA. THE OUTPUT IS ALSO
057810,000090: # AVAILABLE AT MPAC.
057811,000091:
057812,000092: 23,3256 51545 ARCTRIG DLOAD ABS # PUSHDOWN 16D-21D
057813,000093: 23,3257 00023 SINTH
057814,000094: 23,3260 50025 DSU BMN
057815,000095: 23,3261 07474 QTSN45 # ABS(SIN/4) - SIN(45)/4
057816,000096: 23,3262 47271 TRIG1 # IF (-45,45) OR (135,-135)
057817,000097:
057818,000098: 23,3263 72545 DLOAD SL1 # (45,135) OR (-135,-45)
057819,000099: 23,3264 00021 COSTH
057820,000100: 23,3265 75326 ACOS SIGN
057821,000101: 23,3266 00023 SINTH
057822,000102: 23,3267 00025 STORE THETA # X = ARCCOS(COS) WITH SIGN(SIN)
057823,000103: 23,3270 77616 RVQ
057824,000104:
057825,000105: 23,3271 72545 TRIG1 DLOAD SL1 # (-45,45) OR (135,-135)
057826,000106: 23,3272 00023 SINTH
057827,000107: 23,3273 77736 ASIN
057828,000108: 23,3274 14025 STODL THETA # X = ARCSIN(SIN) WITH SIGN(SIN)
057829,000109: 23,3275 00021 COSTH
057830,000110: 23,3276 77640 BMN
057831,000111: 23,3277 47302 TRIG2 # IF (135,-135)
057832,000112:
057833,000113: 23,3300 43545 DLOAD RVQ
057834,000114: 23,3301 00025 THETA # X = ARCSIN(SIN) (-45,45)
057835,000115:
057836,000116: 23,3302 75345 TRIG2 DLOAD SIGN # (135,-135)
057837,000117: 23,3303 15333 HIDPHALF
057838,000118: 23,3304 00023 SINTH
057839,000119: 23,3305 77625 DSU
057840,000120: 23,3306 00025 THETA
057841,000121: 23,3307 00025 STORE THETA # X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
057842,000122: 23,3310 77616 RVQ # (+) - (+) OR (-) - (-)
057843,000123:
Page 1358 |
057845,000125: # SMNB, NBSM, AND AXISROT, WHICH USED TO APPEAR HERE, HAVE BEEN
057846,000126: # COMBINED IN A ROUTINE CALLED AX*SR*T, WHICH APPEARS AMONG THE POWERED
057847,000127: # FLIGHT SUBROUTINES.
057848,000128:
Page 1359 |
057850,000130: # CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
057851,000131:
057852,000132: # THE INPUTS ARE 1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM. THE THREE HALF-UNIT
057853,000133: # VECTORS ARE STORED AT XNB, YNB, AND ZNB. 2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
057854,000134: # COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
057855,000135:
057856,000136: # THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
057857,000137:
057858,000138: 23,3311 77601 CALCGA SETPD # PUSHDOWN 00-05, 16D-21D, 34D-37D
057859,000139: 23,3312 00001 0
057860,000140: 23,3313 47375 VLOAD VXV
057861,000141: 23,3314 02714 XNB # XNB = OGA (OUTER GIMBAL AXIS)
057862,000142: 23,3315 02700 YSM # YSM = IGA (INNER GIMBAL AXIS)
057863,000143: 23,3316 41456 UNIT PUSH # PD0 = UNIT(OGA X IGA) = MGA
057864,000144:
057865,000145: 23,3317 44041 DOT ITA
057866,000146: 23,3320 02730 ZNB
057867,000147: 23,3321 00051 S2
057868,000148: 23,3322 24021 STOVL COSTH # COS(OG) = MGA . ZNB
057869,000149: 23,3323 00001 0
057870,000150: 23,3324 77641 DOT
057871,000151: 23,3325 02722 YNB
057872,000152: 23,3326 34023 STCALL SINTH # SIN(OG) = MGA . YNB
057873,000153: 23,3327 47256 ARCTRIG
057874,000154: 23,3330 26760 STOVL OGC
057875,000155: 23,3331 00001 0
057876,000156:
057877,000157: 23,3332 50235 VXV DOT # PROVISION FOR MG ANGLE OF 90 DEGREES
057878,000158: 23,3333 02714 XNB
057879,000159: 23,3334 02700 YSM
057880,000160: 23,3335 77752 SL1
057881,000161: 23,3336 24021 STOVL COSTH # COS(MG) = IGA . (MGA X OGA)
057882,000162: 23,3337 02700 YSM
057883,000163: 23,3340 77641 DOT
057884,000164: 23,3341 02714 XNB
057885,000165: 23,3342 34023 STCALL SINTH # SIN(MG) = IGA . OGA
057886,000166: 23,3343 47256 ARCTRIG
057887,000167: 23,3344 02764 STORE MGC
057888,000168:
057889,000169: 23,3345 45246 ABS DSU
057890,000170: 23,3346 07476 .166...
057891,000171: 23,3347 77644 BPL
057892,000172: 23,3350 47371 GIMLOCK1 # IF ANGLE GREATER THAN 60 DEGREES
057893,000173:
057894,000174: 23,3351 50375 CALCGA1 VLOAD DOT
057895,000175: 23,3352 02706 ZSM
057896,000176: 23,3353 00001 0
057897,000177: 23,3354 24021 STOVL COSTH # COS(IG) = ZSM . MGA
057898,000178: 23,3355 02672 XSM
Page 1360 |
057900,000180: 23,3356 45441 DOT STADR
057901,000181: 23,3357 43754 STCALL SINTH # SIN(IG) = XSM . MGA
057902,000182: 23,3360 47256 ARCTRIG
057903,000183:
057904,000184: 23,3361 26762 STOVL IGC
057905,000185: 23,3362 02760 OGC
057906,000186: 23,3363 43034 RTB BONCLR
057907,000187: 23,3364 45552 V1STO2S
057908,000188: 23,3365 00200 CPHIFLAG
057909,000189: 23,3366 00051 S2
057910,000190: 23,3367 35156 STCALL THETAD
057911,000191: 23,3370 00051 S2
057912,000192:
057913,000193: 23,3371 77776 GIMLOCK1 EXIT
057914,000194: 23,3372 05650 TC ALARM
057915,000195: 23,3373 00401 OCT 00401
057916,000196: 23,3374 05546 TC UPFLAG # GIMBAL LOCK HAS OCCURED
057917,000197: 23,3375 00056 ADRES GLOKFAIL
057918,000198:
057919,000199: 23,3376 06006 TC INTPRET
057920,000200: 23,3377 77650 GOTO
057921,000201: 23,3400 47351 CALCGA1
057922,000202:
Page 1361 |
057924,000204: # AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
057925,000205:
057926,000206: # THE INPUTS ARE 1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD. 2) THE STAR2 VECTOR
057927,000207: # REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6. 3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
057928,000208: # AT LOCATION 6 OF THE VAC AREA. 4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
057929,000209: # THE VAC AREA.
057930,000210:
057931,000211: # THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B. THE THREE HALF-UNIT VECTORS ARE STORED
057932,000212: # AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
057933,000213:
057934,000214: 23,3401 66370 AXISGEN AXT,1 SSP # PUSHDOWN 00-30D, 34D-37D
057935,000215: 23,3402 02743 STARAD +6
057936,000216: 23,3403 00051 S1
057937,000217: 23,3404 02727 STARAD -6
057938,000218:
057939,000219: 23,3405 77601 SETPD
057940,000220: 23,3406 00001 0
057941,000221: 23,3407 46773 AXISGEN1 VLOAD* VXV* # 06D UA = S1
057942,000222: 23,3410 02752 STARAD +12D,1 # STARAD +00D UB = S1
057943,000223: 23,3411 02760 STARAD +18D,1
057944,000224: 23,3412 77656 UNIT # 12D VA = UNIT(S1 X S2)
057945,000225: 23,3413 06760 STORE STARAD +18D,1 # STARAD +06D VB = UNIT(S1 X S2)
057946,000226: 23,3414 77773 VLOAD*
057947,000227: 23,3415 02752 STARAD +12D,1
057948,000228:
057949,000229: 23,3416 76433 VXV* VSL1
057950,000230: 23,3417 02760 STARAD +18D,1 # 18D WA = UA X VA
057951,000231: 23,3420 06766 STORE STARAD +24D,1 # STARAD +12D WB = UB X VB
057952,000232:
057953,000233: 23,3421 77700 TIX,1
057954,000234: 23,3422 47407 AXISGEN1
057955,000235:
057956,000236: 23,3423 66160 AXC,1 SXA,1
057957,000237: 23,3424 00006 6
057958,000238: 23,3425 00036 30D
057959,000239:
057960,000240: 23,3426 66370 AXT,1 SSP
057961,000241: 23,3427 00022 18D
057962,000242: 23,3430 00051 S1
057963,000243: 23,3431 00006 6
057964,000244:
057965,000245: 23,3432 66374 AXT,2 SSP
057966,000246: 23,3433 00006 6
057967,000247: 23,3434 00052 S2
057968,000248: 23,3435 00002 2
057969,000249:
057970,000250: 23,3436 76720 AXISGEN2 XCHX,1 VLOAD*
057971,000251: 23,3437 00036 30D # X1=-6 X2=+6 X1=-6 X2=+4 X1=-6 X2=+2
057972,000252: 23,3440 00001 0,1
057973,000253:
Page 1362 |
057975,000255: 23,3441 62757 VXSC* PDVL* # J=(UA)(UB1) J=(UA)(UB2) J=(UA)(UB3)
057976,000256: 23,3442 75033 STARAD +6,2
057977,000257: 23,3443 00007 6,1
057978,000258: 23,3444 77757 VXSC*
057979,000259: 23,3445 75025 STARAD +12D,2
057980,000260: 23,3446 30031 STOVL* 24D # K=(VA)(VB1) J=(VA)(VB2) J=(VA)(VB3)
057981,000261: 23,3447 00015 12D,1
057982,000262:
057983,000263: 23,3450 53357 VXSC* VAD
057984,000264: 23,3451 75017 STARAD +18D,2 # L=(WA)(WB1) J=(WA)(WB2) J=(WA)(WB3)
057985,000265: 23,3452 76455 VAD VSL1
057986,000266: 23,3453 00031 24D
057987,000267: 23,3454 53520 XCHX,1 UNIT
057988,000268: 23,3455 00036 30D
057989,000269: 23,3456 06736 STORE XDC +18D,1 # XDC = L+J+K YDC = L+J+K ZDC = L+J+K
057990,000270:
057991,000271: 23,3457 77700 TIX,1
057992,000272: 23,3460 47461 AXISGEN3
057993,000273:
057994,000274: 23,3461 77704 AXISGEN3 TIX,2
057995,000275: 23,3462 47436 AXISGEN2
057996,000276:
057997,000277: 23,3463 77775 VLOAD
057998,000278: 23,3464 02714 XDC
057999,000279: 23,3465 26736 STOVL STARAD
058000,000280: 23,3466 02722 YDC
058001,000281: 23,3467 26744 STOVL STARAD +6
058002,000282: 23,3470 02730 ZDC
058003,000283: 23,3471 02752 STORE STARAD +12D
058004,000284:
058005,000285: 23,3472 77616 RVQ
058006,000286:
Page 1363 |
058008,000288: 23,3473 05520 26075 QTSN45 2DEC .1768
058009,000289: 23,3475 05252 25253 .166... 2DEC .1666666667
058010,000290:
Page 1364 This page is empty. |
058013,000293:
058014,000294:
058015,000295:
End of include-file INFLIGHT_ALIGNMENT_ROUTINES.agc. Parent file is MAIN.agc