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. |
038491,000002: ## Copyright: Public domain.
038492,000003: ## Filename: CM_BODY_ATTITUDE.agc
038493,000004: ## Purpose: A section of Comanche revision 051.
038494,000005: ## It is part of the reconstructed source code for the
038495,000006: ## original release of the flight software for the Command
038496,000007: ## Module's (CM) Apollo Guidance Computer (AGC) for Apollo 11.
038497,000008: ## The code has been recreated from a copy of Comanche 055. It
038498,000009: ## has been adapted such that the resulting bugger words
038499,000010: ## exactly match those specified for Comanche 51 in NASA drawing
038500,000011: ## 2021153D, which gives relatively high confidence that the
038501,000012: ## reconstruction is correct.
038502,000013: ## Reference: pp. 883-889
038503,000014: ## Assembler: yaYUL
038504,000015: ## Contact: Ron Burkey <info@sandroid.org>.
038505,000016: ## Website: www.ibiblio.org/apollo/index.html
038506,000017: ## Mod history: 2019-07-30 MAS Created from Comanche 55.
038507,000018:
Page 883 |
038509,000020: 35,3477 BANK 35
038510,000021:
038511,000022: 37,2000 SETLOC BODYATT
038512,000023: 37,2000 BANK
038513,000024:
038514,000025: 37,3470 COUNT 37/CMBAT
038515,000026:
038516,000027: # PDL 12D - 15D SAFE.
038517,000028:
038518,000029: # VALUES OF GIMBAL AND BODY ANGLES VALID AT PIP TIME ARE SAVED DURING READACCS.
038519,000030:
038520,000031: 37,3470 E7,1451 EBANK= RTINIT # LET INTERPRETER SET EB
038521,000032:
038522,000033: 37,3470 06006 CM/POSE TC INTPRET # COME HERE VIA AVEGEXIT.
038523,000034:
038524,000035: 37,3471 77201 SETPD VLOAD
038525,000036: 37,3472 00001 0
038526,000037: 37,3473 01177 VN # KVSCALE = (12800/ .3048) /2VS
038527,000038: 37,3474 63361 VXSC PDVL
038528,000039: 37,3475 37767 -KVSCALE # KVSCALE = .81491944
038529,000040: 37,3476 01714 UNITW # FULL UNIT VECTOR
038530,000041: 37,3477 74235 VXV VXSC # VREL = V - WE*R
038531,000042: 37,3500 01760 UNITR
038532,000043: 37,3501 15245 KWE
038533,000044: 37,3502 45455 VAD STADR
038534,000045: 37,3503 74251 STORE -VREL # SAVE FOR ENTRY GUIDANCE. REF COORDS
038535,000046:
038536,000047: 37,3504 72056 UNIT LXA,1
038537,000048: 37,3505 00044 36D # ABVAL( -VREL) TO X1
038538,000049: 37,3506 03542 STORE UXA/2 # -UVREL REF COORDS
038539,000050:
038540,000051: 37,3507 57435 VXV VCOMP
038541,000052: 37,3510 01760 UNITR # .5 UNIT REF COORDS
038542,000053: 37,3511 66256 UNIT SSP # THE FOLLOWING IS TO PROVIDE A STABLE
038543,000054: 37,3512 00051 S1 # UN FOR THE END OF THE TERMINAL PHASE.
038544,000055: 37,3513 00476 SPVQUIT DEC .019405 # 1000/ 2 VS
038545,000056: 37,3514 77300 TIX,1 VLOAD # IF V-VQUIT POS, BRANCH.
038546,000057: 37,3515 77517 CM/POSE2 # SAVE UYA IN OLDUYA
038547,000058: 37,3516 03534 OLDUYA # OTHERWISE CONTINUE TO USE OLDUYA.
038548,000059: 37,3517 03550 CM/POSE2 STORE UYA/2 # REF COORDS
038549,000060:
038550,000061: 37,3520 03534 STORE OLDUYA # RESTORE, OR SAVE AS CASE MAY BE.
038551,000062:
038552,000063: 37,3521 57435 VXV VCOMP
038553,000064: 37,3522 03542 UXA/2 # FINISH OBTAINING TRAJECTORY TRIAD.
038554,000065: 37,3523 77772 VSL1
038555,000066: 37,3524 03556 STORE UZA/2 # REF COORDS
Page 884 |
038557,000068: 37,3525 77751 TLOAD # PICK UP CDUX, CDUY, CDUZ CORRESPONDING
038558,000069: 37,3526 03270 AOG/PIP # TO PIPUP TIME IN 2S,C AND SAVE.
038559,000070: 37,3527 14031 CM/TRIO STODL 24D
038560,000071: 37,3530 00032 25D # AIG/PIP
038561,000072:
038562,000073: 37,3531 41434 RTB PUSH # TO PDL0
038563,000074: 37,3532 45513 CDULOGIC
038564,000075: 37,3533 77746 COS
038565,000076: 37,3534 17564 STODL UBX/2 # CI /2
038566,000077: # AIG/PIP FROM PDL 0
038567,000078: 37,3535 57556 SIN DCOMP
038568,000079: 37,3536 17570 STODL UBX/2 +4 # -SI /2
038569,000080: 37,3537 00033 26D # AMG/PIP
038570,000081: 37,3540 41434 RTB PUSH # TO PDL 0
038571,000082: 37,3541 45513 CDULOGIC
038572,000083: 37,3542 65356 SIN PDDL # XCH PDL 0. SAVE SM /2
038573,000084: 37,3543 65346 COS PDDL # CM /2 TO PDL 2
038574,000085: 37,3544 00001 0 # SM /2
038575,000086: 37,3545 74276 DCOMP VXSC
038576,000087: 37,3546 03564 UBX/2
038577,000088: 37,3547 77772 VSL1 # NOISE WONT OVFL.
038578,000089: 37,3550 17572 STODL UBY/2 # =(-SMCI, NOISE, SMSI)/2
038579,000090: 37,3551 00003 2 # CM /2 REPLACES NOISE
038580,000091: 37,3552 17574 STODL UBY/2 +2 # UBY/2=(-SMCI, CM, SMSI)/2
038581,000092: 37,3553 00031 24D # AOG/PIP
038582,000093: 37,3554 41434 RTB PUSH # TO PDL 4
038583,000094: 37,3555 45513 CDULOGIC
038584,000095: 37,3556 65356 SIN PDDL # XCH PDL 4. SAVE SO /2
038585,000096: 37,3557 74346 COS VXSC # CO /2
038586,000097: 37,3560 03572 UBY/2
038587,000098: 37,3561 17572 STODL UBY/2 # UBY/2=(-COSMCI, COCM, COSMSI)/4
038588,000099: 37,3562 00005 4D # SO /2
038589,000100: 37,3563 57405 DMP DCOMP
038590,000101: 37,3564 03570 UBX/2 +4 # -SI /2
038591,000102: 37,3565 77615 DAD
038592,000103: 37,3566 03572 UBY/2 # INCREMENT BY (SOSI /4)
038593,000104: 37,3567 17572 STODL UBY/2
038594,000105: # SO /2 FROM PDL 4
038595,000106: 37,3570 43205 DMP DAD
038596,000107: 37,3571 03564 UBX/2 # CI /2
038597,000108: 37,3572 03576 UBY/2 +4
038598,000109: 37,3573 27576 STOVL UBY/2 +4 # YB/4 PLATFORM COORDS
038599,000110:
038600,000111: # YB = (-COSMCI + SOSI , COCM , COSMSI + SOCI )
038601,000112:
038602,000113: 37,3574 03572 UBY/2
038603,000114: 37,3575 72505 VXM VSL2
038604,000115: 37,3576 01736 REFSMMAT # .5 UNIT
038605,000116: 37,3577 17572 STODL UBY/2 # YB/2 DONE REF COORDS
Page 885 |
038607,000118: # CM /2 FROM PDL 2
038608,000119: 37,3600 76561 VXSC VSL1
038609,000120: 37,3601 03564 UBX/2
038610,000121: 37,3602 17564 STODL UBX/2 # =( CMCI, NOISE, -CMSI)/2
038611,000122: 37,3603 77626 STADR # SM /2 FROM PDL 0
038612,000123: 37,3604 50211 STOVL UBX/2 +2 # SM /2 REPLACES NOISE
038613,000124: 37,3605 03564 UBX/2 # XB/2 PLATFORM COORDS
038614,000125:
038615,000126: # XB = ( CMCI , SM , -CMSI )
038616,000127:
038617,000128: 37,3606 76505 VXM VSL1
038618,000129: 37,3607 01736 REFSMMAT # .5 UNIT
038619,000130: 37,3610 03564 STORE UBX/2 # XB/2 DONE REF COORDS
038620,000131:
038621,000132: 37,3611 76435 VXV VSL1
038622,000133: 37,3612 03572 UBY/2
038623,000134: 37,3613 27600 STOVL UBZ/2 # ZB/2 DONE REF COORDS
038624,000135:
038625,000136: # EQUIVALENT TO
038626,000137: # ZB = ( SOSMCI + COSI , -SOCM , -SOSMSI + COCI )
038627,000138:
038628,000139: 37,3614 03542 UXA/2 # -UVREL/2 = -UVA/2
038629,000140: 37,3615 53435 VXV UNIT # GET UNIT(-UVREL*UBY)/2 = UL/2
038630,000141: 37,3616 03572 UBY/2 # YB/2
038631,000142: 37,3617 50206 PUSH DOT # UL/2 TO PDL 0,5
038632,000143: 37,3620 03556 UZA/2 # UNA/2
038633,000144: 37,3621 24021 STOVL COSTH # COS(ROLL)/4
038634,000145: 37,3622 00001 0 # UL/2
038635,000146:
038636,000147: 37,3623 77641 DOT
038637,000148: 37,3624 03550 UYA/2
038638,000149: 37,3625 34023 STCALL SINTH # -SIN(ROLL)/4
038639,000150: 37,3626 47256 ARCTRIG
038640,000151: 37,3627 24007 STOVL 6D # -(ROLL/180) /2
038641,000152: 37,3630 03572 UBY/2
038642,000153: 37,3631 72441 DOT SL1 # -UVA.UBY = -SIN(BETA)
038643,000154: 37,3632 03542 UXA/2 # -UVREL/2
038644,000155: 37,3633 77736 ARCSIN
038645,000156: 37,3634 24010 STOVL 7D # -(BETA/180) /2
038646,000157: 37,3635 03564 UBX/2 # XB/2
038647,000158: 37,3636 77641 DOT # UL.UBX = -SIN(ALFA)
038648,000159: 37,3637 00001 0 # UL/2
038649,000160: 37,3640 24023 STOVL SINTH # -SIN(ALFA)/4
038650,000161: 37,3641 77641 DOT # UL/2 FROM PDL 0
038651,000162: 37,3642 03600 UBZ/2
038652,000163: 37,3643 34021 STCALL COSTH # COS(ALFA)/4
038653,000164: 37,3644 47256 ARCTRIG
038654,000165: 37,3645 24011 STOVL 8D # -(ALFA/180) /2
038655,000166: 37,3646 01760 UNITR # UR/2 REF COORDS
038656,000167: 37,3647 72441 DOT SL1
Page 886 |
038658,000169: 37,3650 03556 UZA/2 # MORE ACCURATE AT LARGE ARG.
038659,000170: 37,3651 77726 ARCCOS
038660,000171: 37,3652 00013 STORE 10D # (-GAMA/180)/2
038661,000172:
038662,000173: 37,3653 77551 TLOAD EXIT # ANGLES IN MPAC IN THE ORDER
038663,000174: # -( (ROLL, BETA, ALFA) /180)/2
038664,000175: 37,3654 00007 6D # THESE VALUES CORRECT AT PIPUP TIME.
038665,000176:
038666,000177: # SPACER
Page 887 |
038668,000179: # BASIC SUBROUTINE TO UPDATE ATTITUDE ANGLES
038669,000180:
038670,000181: 37,3655 E6,1661 EBANK= AOG
038671,000182:
038672,000183: 37,3655 35057 CM/ATUP CA EBAOG
038673,000184: 37,3656 54003 TS EBANK
038674,000185: 37,3657 50120 CMTR1 INDEX FIXLOC
038675,000186: 37,3660 40012 CS 10D # (GAMA/180)/2
038676,000187: 37,3661 57722 XCH GAMA
038677,000188: 37,3662 54001 TS L
038678,000189:
038679,000190: 37,3663 00004 INHINT
038680,000191: # MUST REMAIN INHINTED UNTIL UPDATE OF BODY
038681,000192: # ANGLES, SO THAT GAMDIFSW IS VALID FIRST PASS
038682,000193: # INDICATOR.
038683,000194:
038684,000195: 37,3664 40102 CS CM/FLAGS
038685,000196: 37,3665 75005 MASK BIT11 # GAMDIFSW=94D BIT11 INITLY=0
038686,000197: 37,3666 00006 EXTEND # DONT CALC GAMA DOT UNTIL HAVE FORMD
038687,000198: # ONE DIFFERENCE.
038688,000199: 37,3667 13672 BZF DOGAMDOT # IS OK, GO ON.
038689,000200: 37,3670 26102 ADS CM/FLAGS # KNOW BIT IS 0
038690,000201: 37,3671 03705 TC NOGAMDOT # SET GAMDOT = 0
038691,000202:
038692,000203: 37,3672 40001 DOGAMDOT CS L
038693,000204: 37,3673 61722 AD GAMA # DEL GAMA/360= T GAMDOT/360
038694,000205: 37,3674 00006 EXTEND
038695,000206: 37,3675 73770 MP TCDU # TCDU = .1 SEC, T = 2 SEC.
038696,000207: 37,3676 55723 TS GAMDOT # GAMA DOT TCDU / 180
038697,000208:
038698,000209: 37,3677 00006 EXTEND # IGNORE GAMDOT IF LEQ .5 DEG/SEC
038699,000210: 37,3700 63702 BZMF +2
038700,000211: 37,3701 40000 COM
038701,000212: 37,3702 65022 AD FIVE
038702,000213: 37,3703 00006 EXTEND
038703,000214: 37,3704 63707 BZMF +3 # SET GAMDOT=+0 AS TAG IF TOO SMALL.
038704,000215:
038705,000216: 37,3705 35021 NOGAMDOT CA ZERO # COME HERE INHINTED.
038706,000217: 37,3706 55723 TS GAMDOT
038707,000218: # FOR NOW LEAVE IN 2S,C
038708,000219: # UPDATE ANGLES BY CORRECTING EUILER ANG
038709,000220: # FOR ACCRUED INCREMENT SINCE PIPUP
038710,000221: # R = R EUIL + R(NOW) - R(PIPUP)
038711,000222: 37,3707 40154 CS MPAC # GET (R EUL/180) /2
038712,000223: 37,3710 60000 DOUBLE # POSSIBLE OVERFLOW
038713,000224: 37,3711 03760 TC CORANGOV # CORRECT FOR OVFL IF ANY
038714,000225: 37,3712 00006 EXTEND
038715,000226: 37,3713 61672 SU ROLL/PIP # GET INCR SINCE PIPUP
038716,000227: 37,3714 61664 AD ROLL/180 # ONLY SINGLE OVFL POSSIBLE.
038717,000228: 37,3715 03760 TC CORANGOV # CORRECT FOR OVFL IF ANY
Page 888 |
038719,000230: 37,3716 55770 TS TEMPROLL
038720,000231:
038721,000232: 37,3717 40156 CS MPAC +2 # GET (ALFA EUL/180) /2
038722,000233: 37,3720 60000 DOUBLE # SAME AS FOR ROLL. NEEDED FOR EXT ATM DAP
038723,000234: 37,3721 03760 TC CORANGOV # CORRECT FOR OVFL IF ANY
038724,000235: 37,3722 00006 EXTEND
038725,000236: 37,3723 61673 SU ALFA/PIP
038726,000237: 37,3724 61665 AD ALFA/180
038727,000238: 37,3725 03760 TC CORANGOV # CORRECT FOR OVFL IF ANY
038728,000239: 37,3726 55771 TS TEMPALFA
038729,000240:
038730,000241: 37,3727 40155 CS MPAC +1 # GET (BETA EUL/180) /2
038731,000242: 37,3730 60000 CMTR2 DOUBLE
038732,000243: 37,3731 00006 EXTEND
038733,000244: 37,3732 61674 SU BETA/PIP
038734,000245: 37,3733 61666 AD BETA/180
038735,000246: 37,3734 57772 XCH TEMPBETA # OVFL NOT EXPECTED.
038736,000247:
038737,000248: 37,3735 35051 CA EBANK3
038738,000249: 37,3736 54003 TS EBANK
038739,000250:
038740,000251: 37,3737 E3,1446 EBANK= PHSNAME5
038741,000252: 37,3737 00006 EXTEND
038742,000253: 37,3740 33772 DCA REPOSADR # THIS ASSUMES THAT THE TC PHASCHNG
038743,000254: 37,3741 53447 DXCH PHSNAME5 # IS NOT CHANGED IN OCT 10035
038744,000255: # SERVICER.
038745,000256:
038746,000257: 37,3742 35057 CA EBAOG
038747,000258: 37,3743 54003 TS EBANK
038748,000259:
038749,000260: 37,3744 E6,1661 EBANK= AOG
038750,000261: 37,3744 00006 REDOPOSE EXTEND # RE-STARTS COME HERE
038751,000262: 37,3745 31771 DCA TEMPROLL
038752,000263: 37,3746 53665 DXCH ROLL/180
038753,000264: 37,3747 31772 CA TEMPBETA
038754,000265: 37,3750 55666 TS BETA/180
038755,000266:
038756,000267: 37,3751 00003 RELINT
038757,000268:
038758,000269: 37,3752 06006 TC INTPRET # CANT TC DANZIG AFTER PHASCHNG.
038759,000270: 37,3753 51575 CM/POSE3 VLOAD ABVAL # RETURN FROM CM/ATUP. (RESTART)
038760,000271: 37,3754 01177 VN # 2(-7) M/CS
038761,000272: 37,3755 03723 STORE VMAGI # FOR DISPLAY ON CALL.
038762,000273:
038763,000274: 37,3756 77650 GOTO
038764,000275: 37,3757 03324 POSEXIT # ENDEXIT, STARTENT, OR SCALEPOP.
038765,000276:
038766,000277: 37,3760 54001 CORANGOV TS L
038767,000278: 37,3761 00002 TC Q
038768,000279: 37,3762 50000 INDEX A
Page 889 |
038770,000281: 37,3763 35000 CA LIMITS
038771,000282: 37,3764 26001 ADS L
038772,000283: 37,3765 00002 TC Q # COSTS 2 MCT TO USE. SEE ANGOVCOR.
038773,000284:
038774,000285: 37,3766 45730 53410 -KVSCALE 2DEC -.81491944 # -12800/(2 VS .3048)
038775,000286:
038776,000287: 37,3770 03146 TCDU DEC .1 # TCDU = .1 SEC.
038777,000288:
038778,000289: 37,3771 E6,1661 EBANK= AOG
038779,000290: 37,3771 03744 76066 REPOSADR 2CADR REDOPOSE
038780,000291:
End of include-file CM_BODY_ATTITUDE.agc. Parent file is MAIN.agc