Source Code

These source-code files are part of a reconstructed copy of Comanche 72, the first release of the Apollo Guidance Computer (AGC) Command Module (CM) software for Apollo 13.

They have been adapted from sources files created from a listing of Comanche 55. These source files were updated to match binary dumps of a set of Comanche 67 rope modules. They were then further modified by applying known changes between Comanche 67 and Comanche 72. A binary dump of module B2 of Comanche 72, part number 2010802-021, was also used to validate changes made to banks 05-13. 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 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.

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

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