Source Code

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

The starting point was the source code of Comanche 45 (itself previously accurately reconstructed). Comanche 45 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 45 and 45/2. The now-reconstructed Comanche 45/2 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 tend to match those in the Comanche 55, the most-similar revision of Comanche for which we have access to an actual non-reconstructed hardcopy; the source code would likely have different page numbers in a contemporary Comanche 45 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 44. Here's a guide to the Apollo documentation referenced in 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.

038446,000002:                                                                                                  ## Copyright:   Public domain.
038447,000003:                                                                                                  ## Filename:    CM_BODY_ATTITUDE.agc
038448,000004:                                                                                                  ## Purpose:     A section of Manche45 revision 2.
038449,000005:                                                                                                  ##              It is part of the reconstructed source code for the
038450,000006:                                                                                                  ##              final, flown release of the flight software for the Command
038451,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
038452,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
038453,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
038454,000010:                                                                                                  ##              exactly match those specified for Manche 45/2 in NASA drawing
038455,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
038456,000012:                                                                                                  ##              reconstruction is correct.
038457,000013:                                                                                                  ## Assembler:   yaYUL
038458,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
038459,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
038460,000016:                                                                                                  ## Mod history: 2020-12-24 MAS  Created from Comanche 45.
038461,000017: 

Page 883

038463,000019: 35,3504                                           BANK     35                                    
038464,000020: 
038465,000021: 37,2000                                           SETLOC   BODYATT                               
038466,000022: 37,2000                                           BANK                                           
038467,000023: 
038468,000024: 37,3467                                           COUNT    37/CMBAT                              
038469,000025: 
038470,000026:                                                                                                  #  PDL 12D - 15D SAFE.
038471,000027: 
038472,000028:                                                                                                  #  VALUES OF GIMBAL AND BODY ANGLES VALID AT PIP TIME ARE SAVED DURING  READACCS.
038473,000029: 
038474,000030: 37,3467  E7,1451                                  EBANK=   RTINIT                                #  LET INTERPRETER SET EB
038475,000031: 
038476,000032: 37,3467           06006        CM/POSE            TC       INTPRET                               #  COME HERE VIA AVEGEXIT.
038477,000033: 
038478,000034: 37,3470           77201                           SETPD    VLOAD                                 
038479,000035: 37,3471           00001                                    0                                     
038480,000036: 37,3472           01177                                    VN                                    #  KVSCALE = (12800/ .3048) /2VS
038481,000037: 37,3473           63361                           VXSC     PDVL                                  
038482,000038: 37,3474           37766                                    -KVSCALE                              #  KVSCALE = .81491944
038483,000039: 37,3475           01714                                    UNITW                                 #  FULL UNIT VECTOR
038484,000040: 37,3476           74235                           VXV      VXSC                                  #  VREL = V - WE*R
038485,000041: 37,3477           01760                                    UNITR                                 
038486,000042: 37,3500           15245                                    KWE                                   
038487,000043: 37,3501           45455                           VAD      STADR                                 
038488,000044: 37,3502           74251                           STORE    -VREL                                 #  SAVE FOR ENTRY GUIDANCE.      REF COORDS
038489,000045: 
038490,000046: 37,3503           72056                           UNIT     LXA,1                                 
038491,000047: 37,3504           00044                                    36D                                   #  ABVAL( -VREL) TO X1
038492,000048: 37,3505           03542                           STORE    UXA/2                                 #  -UVREL                        REF COORDS
038493,000049: 
038494,000050: 37,3506           57435                           VXV      VCOMP                                 
038495,000051: 37,3507           01760                                    UNITR                                 #  .5 UNIT                       REF COORDS
038496,000052: 37,3510           66256                           UNIT     SSP                                   #  THE FOLLOWING IS TO PROVIDE A STABLE
038497,000053: 37,3511           00051                                    S1                                    #  UN FOR THE END OF THE TERMINAL PHASE.
038498,000054: 37,3512           00476        SPVQUIT            DEC      .019405                               #  1000/ 2 VS
038499,000055: 37,3513           77300                           TIX,1    VLOAD                                 #  IF V-VQUIT POS, BRANCH.
038500,000056: 37,3514           77516                                    CM/POSE2                              #  SAVE UYA IN OLDUYA
038501,000057: 37,3515           03534                                    OLDUYA                                #  OTHERWISE CONTINUE TO USE OLDUYA.
038502,000058: 37,3516           03550        CM/POSE2           STORE    UYA/2                                 #                                REF COORDS
038503,000059: 
038504,000060: 37,3517           03534                           STORE    OLDUYA                                #  RESTORE, OR SAVE AS CASE MAY BE.
038505,000061: 
038506,000062: 37,3520           57435                           VXV      VCOMP                                 
038507,000063: 37,3521           03542                                    UXA/2                                 #  FINISH OBTAINING TRAJECTORY TRIAD.
038508,000064: 37,3522           77772                           VSL1                                           
038509,000065: 37,3523           03556                           STORE    UZA/2                                 #                                REF COORDS

Page 884

038511,000067: 37,3524           77751                           TLOAD                                          #  PICK UP CDUX, CDUY, CDUZ CORRESPONDING
038512,000068: 37,3525           03270                                    AOG/PIP                               #  TO PIPUP TIME IN 2S,C AND SAVE.
038513,000069: 37,3526           14031        CM/TRIO            STODL    24D                                   
038514,000070: 37,3527           00032                                    25D                                   #  AIG/PIP
038515,000071: 
038516,000072: 37,3530           41434                           RTB      PUSH                                  #  TO PDL0
038517,000073: 37,3531           45513                                    CDULOGIC                              
038518,000074: 37,3532           77746                           COS                                            
038519,000075: 37,3533           17564                           STODL    UBX/2                                 #  CI /2
038520,000076:                                                                                                  #  AIG/PIP FROM PDL 0
038521,000077: 37,3534           57556                           SIN      DCOMP                                 
038522,000078: 37,3535           17570                           STODL    UBX/2      +4                         #  -SI /2
038523,000079: 37,3536           00033                                    26D                                   #  AMG/PIP
038524,000080: 37,3537           41434                           RTB      PUSH                                  #  TO PDL 0
038525,000081: 37,3540           45513                                    CDULOGIC                              
038526,000082: 37,3541           65356                           SIN      PDDL                                  #  XCH PDL 0.  SAVE SM /2
038527,000083: 37,3542           65346                           COS      PDDL                                  #  CM /2 TO PDL 2
038528,000084: 37,3543           00001                                    0                                     #  SM /2
038529,000085: 37,3544           74276                           DCOMP    VXSC                                  
038530,000086: 37,3545           03564                                    UBX/2                                 
038531,000087: 37,3546           77772                           VSL1                                           #  NOISE WONT OVFL.
038532,000088: 37,3547           17572                           STODL    UBY/2                                 #  =(-SMCI, NOISE, SMSI)/2
038533,000089: 37,3550           00003                                    2                                     #  CM /2 REPLACES NOISE
038534,000090: 37,3551           17574                           STODL    UBY/2      +2                         #  UBY/2=(-SMCI, CM, SMSI)/2
038535,000091: 37,3552           00031                                    24D                                   #  AOG/PIP
038536,000092: 37,3553           41434                           RTB      PUSH                                  #  TO PDL 4
038537,000093: 37,3554           45513                                    CDULOGIC                              
038538,000094: 37,3555           65356                           SIN      PDDL                                  #  XCH PDL 4.  SAVE SO /2
038539,000095: 37,3556           74346                           COS      VXSC                                  #  CO /2
038540,000096: 37,3557           03572                                    UBY/2                                 
038541,000097: 37,3560           17572                           STODL    UBY/2                                 #  UBY/2=(-COSMCI, COCM, COSMSI)/4
038542,000098: 37,3561           00005                                    4D                                    #  SO /2
038543,000099: 37,3562           57405                           DMP      DCOMP                                 
038544,000100: 37,3563           03570                                    UBX/2      +4                         #  -SI /2
038545,000101: 37,3564           77615                           DAD                                            
038546,000102: 37,3565           03572                                    UBY/2                                 #  INCREMENT BY (SOSI /4)
038547,000103: 37,3566           17572                           STODL    UBY/2                                 
038548,000104:                                                                                                  #  SO /2 FROM PDL 4
038549,000105: 37,3567           43205                           DMP      DAD                                   
038550,000106: 37,3570           03564                                    UBX/2                                 #  CI /2
038551,000107: 37,3571           03576                                    UBY/2      +4                         
038552,000108: 37,3572           27576                           STOVL    UBY/2      +4                         #  YB/4                          PLATFORM COORDS
038553,000109: 
038554,000110:                                                                                                  #  YB = (-COSMCI + SOSI , COCM , COSMSI + SOCI )
038555,000111: 
038556,000112: 37,3573           03572                                    UBY/2                                 
038557,000113: 37,3574           72505                           VXM      VSL2                                  
038558,000114: 37,3575           01736                                    REFSMMAT                              #  .5 UNIT
038559,000115: 37,3576           17572                           STODL    UBY/2                                 #  YB/2 DONE                     REF COORDS

Page 885

038561,000117:                                                                                                  #  CM /2 FROM PDL 2
038562,000118: 37,3577           76561                           VXSC     VSL1                                  
038563,000119: 37,3600           03564                                    UBX/2                                 
038564,000120: 37,3601           17564                           STODL    UBX/2                                 #  =( CMCI, NOISE, -CMSI)/2
038565,000121: 37,3602           77626                           STADR                                          #  SM /2 FROM PDL 0
038566,000122: 37,3603           50211                           STOVL    UBX/2      +2                         #  SM /2 REPLACES NOISE
038567,000123: 37,3604           03564                                    UBX/2                                 #  XB/2                          PLATFORM COORDS
038568,000124: 
038569,000125:                                                                                                  #  XB = ( CMCI , SM , -CMSI )
038570,000126: 
038571,000127: 37,3605           76505                           VXM      VSL1                                  
038572,000128: 37,3606           01736                                    REFSMMAT                              #  .5 UNIT
038573,000129: 37,3607           03564                           STORE    UBX/2                                 #  XB/2 DONE                     REF COORDS
038574,000130: 
038575,000131: 37,3610           76435                           VXV      VSL1                                  
038576,000132: 37,3611           03572                                    UBY/2                                 
038577,000133: 37,3612           27600                           STOVL    UBZ/2                                 #  ZB/2 DONE                     REF COORDS
038578,000134: 
038579,000135:                                                                                                  #  EQUIVALENT TO
038580,000136:                                                                                                  #  ZB = ( SOSMCI + COSI , -SOCM , -SOSMSI + COCI )
038581,000137: 
038582,000138: 37,3613           03542                                    UXA/2                                 #  -UVREL/2 = -UVA/2
038583,000139: 37,3614           53435                           VXV      UNIT                                  #  GET UNIT(-UVREL*UBY)/2 = UL/2
038584,000140: 37,3615           03572                                    UBY/2                                 #  YB/2
038585,000141: 37,3616           50206                           PUSH     DOT                                   #  UL/2 TO PDL 0,5
038586,000142: 37,3617           03556                                    UZA/2                                 #  UNA/2
038587,000143: 37,3620           24021                           STOVL    COSTH                                 #  COS(ROLL)/4
038588,000144: 37,3621           00001                                    0                                     #  UL/2
038589,000145: 
038590,000146: 37,3622           77641                           DOT                                            
038591,000147: 37,3623           03550                                    UYA/2                                 
038592,000148: 37,3624           34023                           STCALL   SINTH                                 #  -SIN(ROLL)/4
038593,000149: 37,3625           47256                                    ARCTRIG                               
038594,000150: 37,3626           24007                           STOVL    6D                                    #  -(ROLL/180) /2
038595,000151: 37,3627           03572                                    UBY/2                                 
038596,000152: 37,3630           72441                           DOT      SL1                                   #  -UVA.UBY = -SIN(BETA)
038597,000153: 37,3631           03542                                    UXA/2                                 #  -UVREL/2
038598,000154: 37,3632           77736                           ARCSIN                                         
038599,000155: 37,3633           24010                           STOVL    7D                                    #  -(BETA/180) /2
038600,000156: 37,3634           03564                                    UBX/2                                 #  XB/2
038601,000157: 37,3635           77641                           DOT                                            #  UL.UBX = -SIN(ALFA)
038602,000158: 37,3636           00001                                    0                                     #  UL/2
038603,000159: 37,3637           24023                           STOVL    SINTH                                 #  -SIN(ALFA)/4
038604,000160: 37,3640           77641                           DOT                                            #  UL/2 FROM PDL 0
038605,000161: 37,3641           03600                                    UBZ/2                                 
038606,000162: 37,3642           34021                           STCALL   COSTH                                 #  COS(ALFA)/4
038607,000163: 37,3643           47256                                    ARCTRIG                               
038608,000164: 37,3644           24011                           STOVL    8D                                    #  -(ALFA/180) /2
038609,000165: 37,3645           01760                                    UNITR                                 #  UR/2                          REF COORDS
038610,000166: 37,3646           72441                           DOT      SL1                                   

Page 886

038612,000168: 37,3647           03556                                    UZA/2                                 #  MORE ACCURATE AT LARGE ARG.
038613,000169: 37,3650           77726                           ARCCOS                                         
038614,000170: 37,3651           00013                           STORE    10D                                   #  (-GAMA/180)/2
038615,000171: 
038616,000172: 37,3652           77551                           TLOAD    EXIT                                  #  ANGLES IN MPAC IN THE ORDER
038617,000173:                                                                                                  #  -( (ROLL, BETA, ALFA) /180)/2
038618,000174: 37,3653           00007                                    6D                                    #  THESE VALUES CORRECT AT PIPUP TIME.
038619,000175: 
038620,000176:                                                                                                  #  SPACER

Page 887

038622,000178:                                                                                                  #  BASIC SUBROUTINE TO UPDATE ATTITUDE ANGLES
038623,000179: 
038624,000180: 37,3654  E6,1661                                  EBANK=   AOG                                   
038625,000181: 
038626,000182: 37,3654           35057        CM/ATUP            CA       EBAOG                                 
038627,000183: 37,3655           54003                           TS       EBANK                                 
038628,000184: 37,3656           50120        CMTR1              INDEX    FIXLOC                                
038629,000185: 37,3657           40012                           CS       10D                                   #  (GAMA/180)/2
038630,000186: 37,3660           57722                           XCH      GAMA                                  
038631,000187: 37,3661           54001                           TS       L                                     
038632,000188: 
038633,000189: 37,3662           00004                           INHINT                                         
038634,000190:                                                                                                  #  MUST REMAIN INHINTED UNTIL UPDATE OF BODY
038635,000191:                                                                                                  #  ANGLES, SO THAT GAMDIFSW IS VALID FIRST PASS
038636,000192:                                                                                                  #  INDICATOR.
038637,000193: 
038638,000194: 37,3663           40102                           CS       CM/FLAGS                              
038639,000195: 37,3664           75005                           MASK     BIT11                                 #  GAMDIFSW=94D BIT11    INITLY=0
038640,000196: 37,3665           00006                           EXTEND                                         #  DONT CALC GAMA DOT UNTIL HAVE FORMD
038641,000197:                                                                                                  #  ONE DIFFERENCE.
038642,000198: 37,3666           13671                           BZF      DOGAMDOT                              #  IS OK, GO ON.
038643,000199: 37,3667           26102                           ADS      CM/FLAGS                              #  KNOW BIT IS 0
038644,000200: 37,3670           03704                           TC       NOGAMDOT                              #  SET GAMDOT = 0
038645,000201: 
038646,000202: 37,3671           40001        DOGAMDOT           CS       L                                     
038647,000203: 37,3672           61722                           AD       GAMA                                  #  DEL GAMA/360= T GAMDOT/360
038648,000204: 37,3673           00006                           EXTEND                                         
038649,000205: 37,3674           73767                           MP       TCDU                                  #  TCDU = .1 SEC, T = 2 SEC.
038650,000206: 37,3675           55723                           TS       GAMDOT                                #  GAMA DOT TCDU / 180
038651,000207: 
038652,000208: 37,3676           00006                           EXTEND                                         #  IGNORE GAMDOT IF LEQ .5 DEG/SEC
038653,000209: 37,3677           63701                           BZMF     +2                                    
038654,000210: 37,3700           40000                           COM                                            
038655,000211: 37,3701           65022                           AD       FIVE                                  
038656,000212: 37,3702           00006                           EXTEND                                         
038657,000213: 37,3703           63706                           BZMF     +3                                    #  SET GAMDOT=+0 AS TAG IF TOO SMALL.
038658,000214: 
038659,000215: 37,3704           35021        NOGAMDOT           CA       ZERO                                  #  COME HERE INHINTED.
038660,000216: 37,3705           55723                           TS       GAMDOT                                
038661,000217:                                                                                                  #  FOR NOW LEAVE IN 2S,C
038662,000218:                                                                                                  #  UPDATE ANGLES BY CORRECTING EUILER ANG
038663,000219:                                                                                                  #  FOR ACCRUED INCREMENT SINCE PIPUP
038664,000220:                                                                                                  #  R = R EUIL + R(NOW) - R(PIPUP)
038665,000221: 37,3706           40154                           CS       MPAC                                  #  GET (R EUL/180) /2
038666,000222: 37,3707           60000                           DOUBLE                                         #  POSSIBLE OVERFLOW
038667,000223: 37,3710           03757                           TC       CORANGOV                              #  CORRECT FOR OVFL IF ANY
038668,000224: 37,3711           00006                           EXTEND                                         
038669,000225: 37,3712           61672                           SU       ROLL/PIP                              #  GET INCR SINCE PIPUP
038670,000226: 37,3713           61664                           AD       ROLL/180                              #  ONLY SINGLE OVFL POSSIBLE.
038671,000227: 37,3714           03757                           TC       CORANGOV                              #  CORRECT FOR OVFL IF ANY

Page 888

038673,000229: 37,3715           55770                           TS       TEMPROLL                              
038674,000230: 
038675,000231: 37,3716           40156                           CS       MPAC       +2                         #  GET (ALFA EUL/180) /2
038676,000232: 37,3717           60000                           DOUBLE                                         #  SAME AS FOR ROLL.  NEEDED FOR EXT ATM DAP
038677,000233: 37,3720           03757                           TC       CORANGOV                              #  CORRECT FOR OVFL IF ANY
038678,000234: 37,3721           00006                           EXTEND                                         
038679,000235: 37,3722           61673                           SU       ALFA/PIP                              
038680,000236: 37,3723           61665                           AD       ALFA/180                              
038681,000237: 37,3724           03757                           TC       CORANGOV                              #  CORRECT FOR OVFL IF ANY
038682,000238: 37,3725           55771                           TS       TEMPALFA                              
038683,000239: 
038684,000240: 37,3726           40155                           CS       MPAC       +1                         #  GET (BETA EUL/180) /2
038685,000241: 37,3727           60000        CMTR2              DOUBLE                                         
038686,000242: 37,3730           00006                           EXTEND                                         
038687,000243: 37,3731           61674                           SU       BETA/PIP                              
038688,000244: 37,3732           61666                           AD       BETA/180                              
038689,000245: 37,3733           57772                           XCH      TEMPBETA                              #  OVFL NOT EXPECTED.
038690,000246: 
038691,000247: 37,3734           35051                           CA       EBANK3                                
038692,000248: 37,3735           54003                           TS       EBANK                                 
038693,000249: 
038694,000250: 37,3736  E3,1446                                  EBANK=   PHSNAME5                              
038695,000251: 37,3736           00006                           EXTEND                                         
038696,000252: 37,3737           33771                           DCA      REPOSADR                              #  THIS ASSUMES THAT THE         TC  PHASCHNG
038697,000253: 37,3740           53447                           DXCH     PHSNAME5                              #  IS NOT CHANGED IN             OCT 10035
038698,000254:                                                                                                  #  SERVICER.
038699,000255: 
038700,000256: 37,3741           35057                           CA       EBAOG                                 
038701,000257: 37,3742           54003                           TS       EBANK                                 
038702,000258: 
038703,000259: 37,3743  E6,1661                                  EBANK=   AOG                                   
038704,000260: 37,3743           00006        REDOPOSE           EXTEND                                         #  RE-STARTS COME HERE
038705,000261: 37,3744           31771                           DCA      TEMPROLL                              
038706,000262: 37,3745           53665                           DXCH     ROLL/180                              
038707,000263: 37,3746           31772                           CA       TEMPBETA                              
038708,000264: 37,3747           55666                           TS       BETA/180                              
038709,000265: 
038710,000266: 37,3750           00003                           RELINT                                         
038711,000267: 
038712,000268: 37,3751           06006                           TC       INTPRET                               #  CANT TC DANZIG AFTER PHASCHNG.
038713,000269: 37,3752           51575        CM/POSE3           VLOAD    ABVAL                                 #  RETURN FROM CM/ATUP.  (RESTART)
038714,000270: 37,3753           01177                                    VN                                    #  2(-7) M/CS
038715,000271: 37,3754           03723                           STORE    VMAGI                                 #  FOR DISPLAY ON CALL.
038716,000272: 
038717,000273: 37,3755           77650                           GOTO                                           
038718,000274: 37,3756           03324                                    POSEXIT                               #  ENDEXIT, STARTENT, OR SCALEPOP.
038719,000275: 
038720,000276: 37,3757           54001        CORANGOV           TS       L                                     
038721,000277: 37,3760           00002                           TC       Q                                     
038722,000278: 37,3761           50000                           INDEX    A                                     

Page 889

038724,000280: 37,3762           35000                           CA       LIMITS                                
038725,000281: 37,3763           26001                           ADS      L                                     
038726,000282: 37,3764           00002                           TC       Q                                     #  COSTS 2 MCT TO USE.  SEE ANGOVCOR.
038727,000283: 
038728,000284: 37,3765           45730 53410  -KVSCALE           2DEC     -.81491944                            #  -12800/(2 VS .3048)
038729,000285: 
038730,000286: 37,3767           03146        TCDU               DEC      .1                                    #  TCDU = .1 SEC.
038731,000287: 
038732,000288: 37,3770  E6,1661                                  EBANK=   AOG                                   
038733,000289: 37,3770           03743 76066  REPOSADR           2CADR    REDOPOSE                              
038734,000290: 

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