Source Code
These source-code files are part of a reconstructed copy of Comanche 72/3 (AKA Manche72 revision 3),
the final, flown mission release of the Apollo Guidance Computer (AGC) Command Module (CM) software
for Apollo 13.
The starting point was the source code of Comanche 72 (itself previously reconstructed). Comanche 72 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 72 and 72/3. The resulting code assembles to have identical memory-bank checksums as those specified in NASA drawing 2021153G; this gives reasonably high confidence that the changes that have been made are correct. In places where ambiguity exists, this ambiguity is discussed in "## Reconstruction:" comments. Since no contemporary listings of Comanche 72/3 are available as source material, all comments and labels are approximate. They have been taken from other AGC programs where possible, or, in some places, written from scratch to match what we believe would have been in the original listing. |
037864,000002: ## Copyright: Public domain.
037865,000003: ## Filename: CM_BODY_ATTITUDE.agc
037866,000004: ## Purpose: A section of Manche72 revision 3.
037867,000005: ## It is part of the reconstructed source code for the final, flown
037868,000006: ## release of the software for the Command Module's (CM) Apollo
037869,000007: ## Guidance Computer (AGC) for Apollo 13. No original listings
037870,000008: ## of this program are available; instead, this file was recreated
037871,000009: ## from a reconstructed copy of Comanche 072. It has been adapted
037872,000010: ## such that the resulting bugger words exactly match those
037873,000011: ## specified for Manche72 revision 3 in NASA drawing 2021153G,
037874,000012: ## which gives relatively high confidence that the reconstruction
037875,000013: ## is correct.
037876,000014: ## Assembler: yaYUL
037877,000015: ## Contact: Ron Burkey <info@sandroid.org>.
037878,000016: ## Website: www.ibiblio.org/apollo/index.html
037879,000017: ## Mod history: 2024-05-19 MAS Created from Comanche 072.
037880,000018:
037881,000019: 35,3477 BANK 35
037882,000020:
037883,000021: 37,2000 SETLOC BODYATT
037884,000022: 37,2000 BANK
037885,000023:
037886,000024: 37,3473 COUNT 37/CMBAT
037887,000025:
037888,000026: # PDL 12D - 15D SAFE.
037889,000027:
037890,000028: # VALUES OF GIMBAL AND BODY ANGLES VALID AT PIP TIME ARE SAVED DURING READACCS.
037891,000029:
037892,000030: 37,3473 E7,1451 EBANK= RTINIT # LET INTERPRETER SET EB
037893,000031:
037894,000032: 37,3473 06006 CM/POSE TC INTPRET # COME HERE VIA AVEGEXIT.
037895,000033:
037896,000034: 37,3474 77201 SETPD VLOAD
037897,000035: 37,3475 00001 0
037898,000036: 37,3476 01177 VN # KVSCALE = (12800/ .3048) /2VS
037899,000037: 37,3477 63361 VXSC PDVL
037900,000038: 37,3500 37772 -KVSCALE # KVSCALE = .81491944
037901,000039: 37,3501 01714 UNITW # FULL UNIT VECTOR
037902,000040: 37,3502 74235 VXV VXSC # VREL = V - WE*R
037903,000041: 37,3503 01760 UNITR
037904,000042: 37,3504 15244 KWE
037905,000043: 37,3505 45455 VAD STADR
037906,000044: 37,3506 74251 STORE -VREL # SAVE FOR ENTRY GUIDANCE. REF COORDS
037907,000045:
037908,000046: 37,3507 72056 UNIT LXA,1
037909,000047: 37,3510 00044 36D # ABVAL( -VREL) TO X1
037910,000048: 37,3511 03542 STORE UXA/2 # -UVREL REF COORDS
037911,000049:
037912,000050: 37,3512 57435 VXV VCOMP
037913,000051: 37,3513 01760 UNITR # .5 UNIT REF COORDS
037914,000052: 37,3514 66256 UNIT SSP # THE FOLLOWING IS TO PROVIDE A STABLE
037915,000053: 37,3515 00051 S1 # UN FOR THE END OF THE TERMINAL PHASE.
037916,000054: 37,3516 00476 SPVQUIT DEC .019405 # 1000/ 2 VS
037917,000055: 37,3517 77300 TIX,1 VLOAD # IF V-VQUIT POS, BRANCH.
037918,000056: 37,3520 77522 CM/POSE2 # SAVE UYA IN OLDUYA
037919,000057: 37,3521 03534 OLDUYA # OTHERWISE CONTINUE TO USE OLDUYA.
037920,000058: 37,3522 03550 CM/POSE2 STORE UYA/2 # REF COORDS
037921,000059:
037922,000060: 37,3523 03534 STORE OLDUYA # RESTORE, OR SAVE AS CASE MAY BE.
037923,000061:
037924,000062: 37,3524 57435 VXV VCOMP
037925,000063: 37,3525 03542 UXA/2 # FINISH OBTAINING TRAJECTORY TRIAD.
037926,000064: 37,3526 77772 VSL1
037927,000065: 37,3527 03556 STORE UZA/2 # REF COORDS
037928,000066: 37,3530 77751 TLOAD # PICK UP CDUX, CDUY, CDUZ CORRESPONDING
037929,000067: 37,3531 03270 AOG/PIP # TO PIPUP TIME IN 2S,C AND SAVE.
037930,000068: 37,3532 14031 CM/TRIO STODL 24D
037931,000069: 37,3533 00032 25D # AIG/PIP
037932,000070:
037933,000071: 37,3534 41434 RTB PUSH # TO PDL0
037934,000072: 37,3535 45513 CDULOGIC
037935,000073: 37,3536 77746 COS
037936,000074: 37,3537 17564 STODL UBX/2 # CI /2
037937,000075: # AIG/PIP FROM PDL 0
037938,000076: 37,3540 57556 SIN DCOMP
037939,000077: 37,3541 17570 STODL UBX/2 +4 # -SI /2
037940,000078: 37,3542 00033 26D # AMG/PIP
037941,000079: 37,3543 41434 RTB PUSH # TO PDL 0
037942,000080: 37,3544 45513 CDULOGIC
037943,000081: 37,3545 65356 SIN PDDL # XCH PDL 0. SAVE SM /2
037944,000082: 37,3546 65346 COS PDDL # CM /2 TO PDL 2
037945,000083: 37,3547 00001 0 # SM /2
037946,000084: 37,3550 74276 DCOMP VXSC
037947,000085: 37,3551 03564 UBX/2
037948,000086: 37,3552 77772 VSL1 # NOISE WONT OVFL.
037949,000087: 37,3553 17572 STODL UBY/2 # =(-SMCI, NOISE, SMSI)/2
037950,000088: 37,3554 00003 2 # CM /2 REPLACES NOISE
037951,000089: 37,3555 17574 STODL UBY/2 +2 # UBY/2=(-SMCI, CM, SMSI)/2
037952,000090: 37,3556 00031 24D # AOG/PIP
037953,000091: 37,3557 41434 RTB PUSH # TO PDL 4
037954,000092: 37,3560 45513 CDULOGIC
037955,000093: 37,3561 65356 SIN PDDL # XCH PDL 4. SAVE SO /2
037956,000094: 37,3562 74346 COS VXSC # CO /2
037957,000095: 37,3563 03572 UBY/2
037958,000096: 37,3564 17572 STODL UBY/2 # UBY/2=(-COSMCI, COCM, COSMSI)/4
037959,000097: 37,3565 00005 4D # SO /2
037960,000098: 37,3566 57405 DMP DCOMP
037961,000099: 37,3567 03570 UBX/2 +4 # -SI /2
037962,000100: 37,3570 77615 DAD
037963,000101: 37,3571 03572 UBY/2 # INCREMENT BY (SOSI /4)
037964,000102: 37,3572 17572 STODL UBY/2
037965,000103: # SO /2 FROM PDL 4
037966,000104: 37,3573 43205 DMP DAD
037967,000105: 37,3574 03564 UBX/2 # CI /2
037968,000106: 37,3575 03576 UBY/2 +4
037969,000107: 37,3576 27576 STOVL UBY/2 +4 # YB/4 PLATFORM COORDS
037970,000108:
037971,000109: # YB = (-COSMCI + SOSI , COCM , COSMSI + SOCI )
037972,000110:
037973,000111: 37,3577 03572 UBY/2
037974,000112: 37,3600 72505 VXM VSL2
037975,000113: 37,3601 01736 REFSMMAT # .5 UNIT
037976,000114: 37,3602 17572 STODL UBY/2 # YB/2 DONE REF COORDS
037977,000115: # CM /2 FROM PDL 2
037978,000116: 37,3603 76561 VXSC VSL1
037979,000117: 37,3604 03564 UBX/2
037980,000118: 37,3605 17564 STODL UBX/2 # =( CMCI, NOISE, -CMSI)/2
037981,000119: 37,3606 77626 STADR # SM /2 FROM PDL 0
037982,000120: 37,3607 50211 STOVL UBX/2 +2 # SM /2 REPLACES NOISE
037983,000121: 37,3610 03564 UBX/2 # XB/2 PLATFORM COORDS
037984,000122:
037985,000123: # XB = ( CMCI , SM , -CMSI )
037986,000124:
037987,000125: 37,3611 76505 VXM VSL1
037988,000126: 37,3612 01736 REFSMMAT # .5 UNIT
037989,000127: 37,3613 03564 STORE UBX/2 # XB/2 DONE REF COORDS
037990,000128:
037991,000129: 37,3614 76435 VXV VSL1
037992,000130: 37,3615 03572 UBY/2
037993,000131: 37,3616 27600 STOVL UBZ/2 # ZB/2 DONE REF COORDS
037994,000132:
037995,000133: # EQUIVALENT TO
037996,000134: # ZB = ( SOSMCI + COSI , -SOCM , -SOSMSI + COCI )
037997,000135:
037998,000136: 37,3617 03542 UXA/2 # -UVREL/2 = -UVA/2
037999,000137: 37,3620 53435 VXV UNIT # GET UNIT(-UVREL*UBY)/2 = UL/2
038000,000138: 37,3621 03572 UBY/2 # YB/2
038001,000139: 37,3622 50206 PUSH DOT # UL/2 TO PDL 0,5
038002,000140: 37,3623 03556 UZA/2 # UNA/2
038003,000141: 37,3624 24021 STOVL COSTH # COS(ROLL)/4
038004,000142: 37,3625 00001 0 # UL/2
038005,000143:
038006,000144: 37,3626 77641 DOT
038007,000145: 37,3627 03550 UYA/2
038008,000146: 37,3630 34023 STCALL SINTH # -SIN(ROLL)/4
038009,000147: 37,3631 47260 ARCTRIG
038010,000148: 37,3632 24007 STOVL 6D # -(ROLL/180) /2
038011,000149: 37,3633 03572 UBY/2
038012,000150: 37,3634 72441 DOT SL1 # -UVA.UBY = -SIN(BETA)
038013,000151: 37,3635 03542 UXA/2 # -UVREL/2
038014,000152: 37,3636 77736 ARCSIN
038015,000153: 37,3637 24010 STOVL 7D # -(BETA/180) /2
038016,000154: 37,3640 03564 UBX/2 # XB/2
038017,000155: 37,3641 77641 DOT # UL.UBX = -SIN(ALFA)
038018,000156: 37,3642 00001 0 # UL/2
038019,000157: 37,3643 24023 STOVL SINTH # -SIN(ALFA)/4
038020,000158: 37,3644 77641 DOT # UL/2 FROM PDL 0
038021,000159: 37,3645 03600 UBZ/2
038022,000160: 37,3646 34021 STCALL COSTH # COS(ALFA)/4
038023,000161: 37,3647 47260 ARCTRIG
038024,000162: 37,3650 24011 STOVL 8D # -(ALFA/180) /2
038025,000163: 37,3651 01760 UNITR # UR/2 REF COORDS
038026,000164: 37,3652 72441 DOT SL1
038027,000165: 37,3653 03556 UZA/2 # MORE ACCURATE AT LARGE ARG.
038028,000166: 37,3654 77726 ARCCOS
038029,000167: 37,3655 00013 STORE 10D # (-GAMA/180)/2
038030,000168:
038031,000169: 37,3656 77551 TLOAD EXIT # ANGLES IN MPAC IN THE ORDER
038032,000170: # -( (ROLL, BETA, ALFA) /180)/2
038033,000171: 37,3657 00007 6D # THESE VALUES CORRECT AT PIPUP TIME.
038034,000172:
038035,000173: # SPACER
038036,000174: # BASIC SUBROUTINE TO UPDATE ATTITUDE ANGLES
038037,000175:
038038,000176: 37,3660 E6,1661 EBANK= AOG
038039,000177:
038040,000178: 37,3660 35073 CM/ATUP CA EBAOG
038041,000179: 37,3661 54003 TS EBANK
038042,000180: 37,3662 50120 CMTR1 INDEX FIXLOC
038043,000181: 37,3663 40012 CS 10D # (GAMA/180)/2
038044,000182: 37,3664 57722 XCH GAMA
038045,000183: 37,3665 54001 TS L
038046,000184:
038047,000185: 37,3666 00004 INHINT
038048,000186: # MUST REMAIN INHINTED UNTIL UPDATE OF BODY
038049,000187: # ANGLES, SO THAT GAMDIFSW IS VALID FIRST PASS
038050,000188: # INDICATOR.
038051,000189:
038052,000190: 37,3667 40102 CS CM/FLAGS
038053,000191: 37,3670 75021 MASK BIT11 # GAMDIFSW=94D BIT11 INITLY=0
038054,000192: 37,3671 00006 EXTEND # DONT CALC GAMA DOT UNTIL HAVE FORMD
038055,000193: # ONE DIFFERENCE.
038056,000194: 37,3672 13675 BZF DOGAMDOT # IS OK, GO ON.
038057,000195: 37,3673 26102 ADS CM/FLAGS # KNOW BIT IS 0
038058,000196: 37,3674 03710 TC NOGAMDOT # SET GAMDOT = 0
038059,000197:
038060,000198: 37,3675 40001 DOGAMDOT CS L
038061,000199: 37,3676 61722 AD GAMA # DEL GAMA/360= T GAMDOT/360
038062,000200: 37,3677 00006 EXTEND
038063,000201: 37,3700 73773 MP TCDU # TCDU = .1 SEC, T = 2 SEC.
038064,000202: 37,3701 55723 TS GAMDOT # GAMA DOT TCDU / 180
038065,000203:
038066,000204: 37,3702 00006 EXTEND # IGNORE GAMDOT IF LEQ .5 DEG/SEC
038067,000205: 37,3703 63705 BZMF +2
038068,000206: 37,3704 40000 COM
038069,000207: 37,3705 65036 AD FIVE
038070,000208: 37,3706 00006 EXTEND
038071,000209: 37,3707 63712 BZMF +3 # SET GAMDOT=+0 AS TAG IF TOO SMALL.
038072,000210:
038073,000211: 37,3710 35035 NOGAMDOT CA ZERO # COME HERE INHINTED.
038074,000212: 37,3711 55723 TS GAMDOT
038075,000213: # FOR NOW LEAVE IN 2S,C
038076,000214: # UPDATE ANGLES BY CORRECTING EUILER ANG
038077,000215: # FOR ACCRUED INCREMENT SINCE PIPUP
038078,000216: # R = R EUIL + R(NOW) - R(PIPUP)
038079,000217: 37,3712 40154 CS MPAC # GET (R EUL/180) /2
038080,000218: 37,3713 60000 DOUBLE # POSSIBLE OVERFLOW
038081,000219: 37,3714 03763 TC CORANGOV # CORRECT FOR OVFL IF ANY
038082,000220: 37,3715 00006 EXTEND
038083,000221: 37,3716 61672 SU ROLL/PIP # GET INCR SINCE PIPUP
038084,000222: 37,3717 61664 AD ROLL/180 # ONLY SINGLE OVFL POSSIBLE.
038085,000223: 37,3720 03763 TC CORANGOV # CORRECT FOR OVFL IF ANY
038086,000224: 37,3721 55770 TS TEMPROLL
038087,000225:
038088,000226: 37,3722 40156 CS MPAC +2 # GET (ALFA EUL/180) /2
038089,000227: 37,3723 60000 DOUBLE # SAME AS FOR ROLL. NEEDED FOR EXT ATM DAP
038090,000228: 37,3724 03763 TC CORANGOV # CORRECT FOR OVFL IF ANY
038091,000229: 37,3725 00006 EXTEND
038092,000230: 37,3726 61673 SU ALFA/PIP
038093,000231: 37,3727 61665 AD ALFA/180
038094,000232: 37,3730 03763 TC CORANGOV # CORRECT FOR OVFL IF ANY
038095,000233: 37,3731 55771 TS TEMPALFA
038096,000234:
038097,000235: 37,3732 40155 CS MPAC +1 # GET (BETA EUL/180) /2
038098,000236: 37,3733 60000 CMTR2 DOUBLE
038099,000237: 37,3734 00006 EXTEND
038100,000238: 37,3735 61674 SU BETA/PIP
038101,000239: 37,3736 61666 AD BETA/180
038102,000240: 37,3737 57772 XCH TEMPBETA # OVFL NOT EXPECTED.
038103,000241:
038104,000242: 37,3740 35065 CA EBANK3
038105,000243: 37,3741 54003 TS EBANK
038106,000244:
038107,000245: 37,3742 E3,1446 EBANK= PHSNAME5
038108,000246: 37,3742 00006 EXTEND
038109,000247: 37,3743 33775 DCA REPOSADR # THIS ASSUMES THAT THE TC PHASCHNG
038110,000248: 37,3744 53447 DXCH PHSNAME5 # IS NOT CHANGED IN OCT 10035
038111,000249: # SERVICER.
038112,000250:
038113,000251: 37,3745 35073 CA EBAOG
038114,000252: 37,3746 54003 TS EBANK
038115,000253:
038116,000254: 37,3747 E6,1661 EBANK= AOG
038117,000255: 37,3747 00006 REDOPOSE EXTEND # RE-STARTS COME HERE
038118,000256: 37,3750 31771 DCA TEMPROLL
038119,000257: 37,3751 53665 DXCH ROLL/180
038120,000258: 37,3752 31772 CA TEMPBETA
038121,000259: 37,3753 55666 TS BETA/180
038122,000260:
038123,000261: 37,3754 00003 RELINT
038124,000262:
038125,000263: 37,3755 06006 TC INTPRET # CANT TC DANZIG AFTER PHASCHNG.
038126,000264: 37,3756 51575 CM/POSE3 VLOAD ABVAL # RETURN FROM CM/ATUP. (RESTART)
038127,000265: 37,3757 01177 VN # 2(-7) M/CS
038128,000266: 37,3760 03723 STORE VMAGI # FOR DISPLAY ON CALL.
038129,000267:
038130,000268: 37,3761 77650 GOTO
038131,000269: 37,3762 03324 POSEXIT # ENDEXIT, STARTENT, OR SCALEPOP.
038132,000270:
038133,000271: 37,3763 54001 CORANGOV TS L
038134,000272: 37,3764 00002 TC Q
038135,000273: 37,3765 50000 INDEX A
038136,000274: 37,3766 35014 CA LIMITS
038137,000275: 37,3767 26001 ADS L
038138,000276: 37,3770 00002 TC Q # COSTS 2 MCT TO USE. SEE ANGOVCOR.
038139,000277:
038140,000278: 37,3771 45730 53410 -KVSCALE 2DEC -.81491944 # -12800/(2 VS .3048)
038141,000279:
038142,000280: 37,3773 03146 TCDU DEC .1 # TCDU = .1 SEC.
038143,000281:
038144,000282: 37,3774 E6,1661 EBANK= AOG
038145,000283: 37,3774 03747 76066 REPOSADR 2CADR REDOPOSE
038146,000284:
End of include-file CM_BODY_ATTITUDE.agc. Parent file is MAIN.agc