Source Code

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

The starting point was the source code of Comanche 44 (itself previously accurately reconstructed). Comanche 44 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 44 and 45. The now-reconstructed Comanche 45 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:
There is also a detailed commentary about the reconstruction process.

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.

038499,000002:                                                                                                  ## Copyright:   Public domain.
038500,000003:                                                                                                  ## Filename:    CM_BODY_ATTITUDE.agc
038501,000004:                                                                                                  ## Purpose:     A section of Comanche revision 045.
038502,000005:                                                                                                  ##              It is part of the reconstructed source code for the
038503,000006:                                                                                                  ##              second release of the flight software for the Command
038504,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
038505,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
038506,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
038507,000010:                                                                                                  ##              exactly match those specified for Comanche 45 in NASA drawing
038508,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
038509,000012:                                                                                                  ##              reconstruction is correct.
038510,000013:                                                                                                  ## Assembler:   yaYUL
038511,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
038512,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
038513,000016:                                                                                                  ## Mod history: 2020-12-06 MAS  Created from Comanche 44.
038514,000017: 

Page 883

038516,000019: 35,3504                                           BANK     35                                    
038517,000020: 
038518,000021: 37,2000                                           SETLOC   BODYATT                               
038519,000022: 37,2000                                           BANK                                           
038520,000023: 
038521,000024: 37,3467                                           COUNT    37/CMBAT                              
038522,000025: 
038523,000026:                                                                                                  #  PDL 12D - 15D SAFE.
038524,000027: 
038525,000028:                                                                                                  #  VALUES OF GIMBAL AND BODY ANGLES VALID AT PIP TIME ARE SAVED DURING  READACCS.
038526,000029: 
038527,000030: 37,3467  E7,1451                                  EBANK=   RTINIT                                #  LET INTERPRETER SET EB
038528,000031: 
038529,000032: 37,3467           06006        CM/POSE            TC       INTPRET                               #  COME HERE VIA AVEGEXIT.
038530,000033: 
038531,000034: 37,3470           77201                           SETPD    VLOAD                                 
038532,000035: 37,3471           00001                                    0                                     
038533,000036: 37,3472           01177                                    VN                                    #  KVSCALE = (12800/ .3048) /2VS
038534,000037: 37,3473           63361                           VXSC     PDVL                                  
038535,000038: 37,3474           37766                                    -KVSCALE                              #  KVSCALE = .81491944
038536,000039: 37,3475           01714                                    UNITW                                 #  FULL UNIT VECTOR
038537,000040: 37,3476           74235                           VXV      VXSC                                  #  VREL = V - WE*R
038538,000041: 37,3477           01760                                    UNITR                                 
038539,000042: 37,3500           15245                                    KWE                                   
038540,000043: 37,3501           45455                           VAD      STADR                                 
038541,000044: 37,3502           74251                           STORE    -VREL                                 #  SAVE FOR ENTRY GUIDANCE.      REF COORDS
038542,000045: 
038543,000046: 37,3503           72056                           UNIT     LXA,1                                 
038544,000047: 37,3504           00044                                    36D                                   #  ABVAL( -VREL) TO X1
038545,000048: 37,3505           03542                           STORE    UXA/2                                 #  -UVREL                        REF COORDS
038546,000049: 
038547,000050: 37,3506           57435                           VXV      VCOMP                                 
038548,000051: 37,3507           01760                                    UNITR                                 #  .5 UNIT                       REF COORDS
038549,000052: 37,3510           66256                           UNIT     SSP                                   #  THE FOLLOWING IS TO PROVIDE A STABLE
038550,000053: 37,3511           00051                                    S1                                    #  UN FOR THE END OF THE TERMINAL PHASE.
038551,000054: 37,3512           00476        SPVQUIT            DEC      .019405                               #  1000/ 2 VS
038552,000055: 37,3513           77300                           TIX,1    VLOAD                                 #  IF V-VQUIT POS, BRANCH.
038553,000056: 37,3514           77516                                    CM/POSE2                              #  SAVE UYA IN OLDUYA
038554,000057: 37,3515           03534                                    OLDUYA                                #  OTHERWISE CONTINUE TO USE OLDUYA.
038555,000058: 37,3516           03550        CM/POSE2           STORE    UYA/2                                 #                                REF COORDS
038556,000059: 
038557,000060: 37,3517           03534                           STORE    OLDUYA                                #  RESTORE, OR SAVE AS CASE MAY BE.
038558,000061: 
038559,000062: 37,3520           57435                           VXV      VCOMP                                 
038560,000063: 37,3521           03542                                    UXA/2                                 #  FINISH OBTAINING TRAJECTORY TRIAD.
038561,000064: 37,3522           77772                           VSL1                                           
038562,000065: 37,3523           03556                           STORE    UZA/2                                 #                                REF COORDS

Page 884

038564,000067: 37,3524           77751                           TLOAD                                          #  PICK UP CDUX, CDUY, CDUZ CORRESPONDING
038565,000068: 37,3525           03270                                    AOG/PIP                               #  TO PIPUP TIME IN 2S,C AND SAVE.
038566,000069: 37,3526           14031        CM/TRIO            STODL    24D                                   
038567,000070: 37,3527           00032                                    25D                                   #  AIG/PIP
038568,000071: 
038569,000072: 37,3530           41434                           RTB      PUSH                                  #  TO PDL0
038570,000073: 37,3531           45513                                    CDULOGIC                              
038571,000074: 37,3532           77746                           COS                                            
038572,000075: 37,3533           17564                           STODL    UBX/2                                 #  CI /2
038573,000076:                                                                                                  #  AIG/PIP FROM PDL 0
038574,000077: 37,3534           57556                           SIN      DCOMP                                 
038575,000078: 37,3535           17570                           STODL    UBX/2      +4                         #  -SI /2
038576,000079: 37,3536           00033                                    26D                                   #  AMG/PIP
038577,000080: 37,3537           41434                           RTB      PUSH                                  #  TO PDL 0
038578,000081: 37,3540           45513                                    CDULOGIC                              
038579,000082: 37,3541           65356                           SIN      PDDL                                  #  XCH PDL 0.  SAVE SM /2
038580,000083: 37,3542           65346                           COS      PDDL                                  #  CM /2 TO PDL 2
038581,000084: 37,3543           00001                                    0                                     #  SM /2
038582,000085: 37,3544           74276                           DCOMP    VXSC                                  
038583,000086: 37,3545           03564                                    UBX/2                                 
038584,000087: 37,3546           77772                           VSL1                                           #  NOISE WONT OVFL.
038585,000088: 37,3547           17572                           STODL    UBY/2                                 #  =(-SMCI, NOISE, SMSI)/2
038586,000089: 37,3550           00003                                    2                                     #  CM /2 REPLACES NOISE
038587,000090: 37,3551           17574                           STODL    UBY/2      +2                         #  UBY/2=(-SMCI, CM, SMSI)/2
038588,000091: 37,3552           00031                                    24D                                   #  AOG/PIP
038589,000092: 37,3553           41434                           RTB      PUSH                                  #  TO PDL 4
038590,000093: 37,3554           45513                                    CDULOGIC                              
038591,000094: 37,3555           65356                           SIN      PDDL                                  #  XCH PDL 4.  SAVE SO /2
038592,000095: 37,3556           74346                           COS      VXSC                                  #  CO /2
038593,000096: 37,3557           03572                                    UBY/2                                 
038594,000097: 37,3560           17572                           STODL    UBY/2                                 #  UBY/2=(-COSMCI, COCM, COSMSI)/4
038595,000098: 37,3561           00005                                    4D                                    #  SO /2
038596,000099: 37,3562           57405                           DMP      DCOMP                                 
038597,000100: 37,3563           03570                                    UBX/2      +4                         #  -SI /2
038598,000101: 37,3564           77615                           DAD                                            
038599,000102: 37,3565           03572                                    UBY/2                                 #  INCREMENT BY (SOSI /4)
038600,000103: 37,3566           17572                           STODL    UBY/2                                 
038601,000104:                                                                                                  #  SO /2 FROM PDL 4
038602,000105: 37,3567           43205                           DMP      DAD                                   
038603,000106: 37,3570           03564                                    UBX/2                                 #  CI /2
038604,000107: 37,3571           03576                                    UBY/2      +4                         
038605,000108: 37,3572           27576                           STOVL    UBY/2      +4                         #  YB/4                          PLATFORM COORDS
038606,000109: 
038607,000110:                                                                                                  #  YB = (-COSMCI + SOSI , COCM , COSMSI + SOCI )
038608,000111: 
038609,000112: 37,3573           03572                                    UBY/2                                 
038610,000113: 37,3574           72505                           VXM      VSL2                                  
038611,000114: 37,3575           01736                                    REFSMMAT                              #  .5 UNIT
038612,000115: 37,3576           17572                           STODL    UBY/2                                 #  YB/2 DONE                     REF COORDS

Page 885

038614,000117:                                                                                                  #  CM /2 FROM PDL 2
038615,000118: 37,3577           76561                           VXSC     VSL1                                  
038616,000119: 37,3600           03564                                    UBX/2                                 
038617,000120: 37,3601           17564                           STODL    UBX/2                                 #  =( CMCI, NOISE, -CMSI)/2
038618,000121: 37,3602           77626                           STADR                                          #  SM /2 FROM PDL 0
038619,000122: 37,3603           50211                           STOVL    UBX/2      +2                         #  SM /2 REPLACES NOISE
038620,000123: 37,3604           03564                                    UBX/2                                 #  XB/2                          PLATFORM COORDS
038621,000124: 
038622,000125:                                                                                                  #  XB = ( CMCI , SM , -CMSI )
038623,000126: 
038624,000127: 37,3605           76505                           VXM      VSL1                                  
038625,000128: 37,3606           01736                                    REFSMMAT                              #  .5 UNIT
038626,000129: 37,3607           03564                           STORE    UBX/2                                 #  XB/2 DONE                     REF COORDS
038627,000130: 
038628,000131: 37,3610           76435                           VXV      VSL1                                  
038629,000132: 37,3611           03572                                    UBY/2                                 
038630,000133: 37,3612           27600                           STOVL    UBZ/2                                 #  ZB/2 DONE                     REF COORDS
038631,000134: 
038632,000135:                                                                                                  #  EQUIVALENT TO
038633,000136:                                                                                                  #  ZB = ( SOSMCI + COSI , -SOCM , -SOSMSI + COCI )
038634,000137: 
038635,000138: 37,3613           03542                                    UXA/2                                 #  -UVREL/2 = -UVA/2
038636,000139: 37,3614           53435                           VXV      UNIT                                  #  GET UNIT(-UVREL*UBY)/2 = UL/2
038637,000140: 37,3615           03572                                    UBY/2                                 #  YB/2
038638,000141: 37,3616           50206                           PUSH     DOT                                   #  UL/2 TO PDL 0,5
038639,000142: 37,3617           03556                                    UZA/2                                 #  UNA/2
038640,000143: 37,3620           24021                           STOVL    COSTH                                 #  COS(ROLL)/4
038641,000144: 37,3621           00001                                    0                                     #  UL/2
038642,000145: 
038643,000146: 37,3622           77641                           DOT                                            
038644,000147: 37,3623           03550                                    UYA/2                                 
038645,000148: 37,3624           34023                           STCALL   SINTH                                 #  -SIN(ROLL)/4
038646,000149: 37,3625           47256                                    ARCTRIG                               
038647,000150: 37,3626           24007                           STOVL    6D                                    #  -(ROLL/180) /2
038648,000151: 37,3627           03572                                    UBY/2                                 
038649,000152: 37,3630           72441                           DOT      SL1                                   #  -UVA.UBY = -SIN(BETA)
038650,000153: 37,3631           03542                                    UXA/2                                 #  -UVREL/2
038651,000154: 37,3632           77736                           ARCSIN                                         
038652,000155: 37,3633           24010                           STOVL    7D                                    #  -(BETA/180) /2
038653,000156: 37,3634           03564                                    UBX/2                                 #  XB/2
038654,000157: 37,3635           77641                           DOT                                            #  UL.UBX = -SIN(ALFA)
038655,000158: 37,3636           00001                                    0                                     #  UL/2
038656,000159: 37,3637           24023                           STOVL    SINTH                                 #  -SIN(ALFA)/4
038657,000160: 37,3640           77641                           DOT                                            #  UL/2 FROM PDL 0
038658,000161: 37,3641           03600                                    UBZ/2                                 
038659,000162: 37,3642           34021                           STCALL   COSTH                                 #  COS(ALFA)/4
038660,000163: 37,3643           47256                                    ARCTRIG                               
038661,000164: 37,3644           24011                           STOVL    8D                                    #  -(ALFA/180) /2
038662,000165: 37,3645           01760                                    UNITR                                 #  UR/2                          REF COORDS
038663,000166: 37,3646           72441                           DOT      SL1                                   

Page 886

038665,000168: 37,3647           03556                                    UZA/2                                 #  MORE ACCURATE AT LARGE ARG.
038666,000169: 37,3650           77726                           ARCCOS                                         
038667,000170: 37,3651           00013                           STORE    10D                                   #  (-GAMA/180)/2
038668,000171: 
038669,000172: 37,3652           77551                           TLOAD    EXIT                                  #  ANGLES IN MPAC IN THE ORDER
038670,000173:                                                                                                  #  -( (ROLL, BETA, ALFA) /180)/2
038671,000174: 37,3653           00007                                    6D                                    #  THESE VALUES CORRECT AT PIPUP TIME.
038672,000175: 
038673,000176:                                                                                                  #  SPACER

Page 887

038675,000178:                                                                                                  #  BASIC SUBROUTINE TO UPDATE ATTITUDE ANGLES
038676,000179: 
038677,000180: 37,3654  E6,1661                                  EBANK=   AOG                                   
038678,000181: 
038679,000182: 37,3654           35057        CM/ATUP            CA       EBAOG                                 
038680,000183: 37,3655           54003                           TS       EBANK                                 
038681,000184: 37,3656           50120        CMTR1              INDEX    FIXLOC                                
038682,000185: 37,3657           40012                           CS       10D                                   #  (GAMA/180)/2
038683,000186: 37,3660           57722                           XCH      GAMA                                  
038684,000187: 37,3661           54001                           TS       L                                     
038685,000188: 
038686,000189: 37,3662           00004                           INHINT                                         
038687,000190:                                                                                                  #  MUST REMAIN INHINTED UNTIL UPDATE OF BODY
038688,000191:                                                                                                  #  ANGLES, SO THAT GAMDIFSW IS VALID FIRST PASS
038689,000192:                                                                                                  #  INDICATOR.
038690,000193: 
038691,000194: 37,3663           40102                           CS       CM/FLAGS                              
038692,000195: 37,3664           75005                           MASK     BIT11                                 #  GAMDIFSW=94D BIT11    INITLY=0
038693,000196: 37,3665           00006                           EXTEND                                         #  DONT CALC GAMA DOT UNTIL HAVE FORMD
038694,000197:                                                                                                  #  ONE DIFFERENCE.
038695,000198: 37,3666           13671                           BZF      DOGAMDOT                              #  IS OK, GO ON.
038696,000199: 37,3667           26102                           ADS      CM/FLAGS                              #  KNOW BIT IS 0
038697,000200: 37,3670           03704                           TC       NOGAMDOT                              #  SET GAMDOT = 0
038698,000201: 
038699,000202: 37,3671           40001        DOGAMDOT           CS       L                                     
038700,000203: 37,3672           61722                           AD       GAMA                                  #  DEL GAMA/360= T GAMDOT/360
038701,000204: 37,3673           00006                           EXTEND                                         
038702,000205: 37,3674           73767                           MP       TCDU                                  #  TCDU = .1 SEC, T = 2 SEC.
038703,000206: 37,3675           55723                           TS       GAMDOT                                #  GAMA DOT TCDU / 180
038704,000207: 
038705,000208: 37,3676           00006                           EXTEND                                         #  IGNORE GAMDOT IF LEQ .5 DEG/SEC
038706,000209: 37,3677           63701                           BZMF     +2                                    
038707,000210: 37,3700           40000                           COM                                            
038708,000211: 37,3701           65022                           AD       FIVE                                  
038709,000212: 37,3702           00006                           EXTEND                                         
038710,000213: 37,3703           63706                           BZMF     +3                                    #  SET GAMDOT=+0 AS TAG IF TOO SMALL.
038711,000214: 
038712,000215: 37,3704           35021        NOGAMDOT           CA       ZERO                                  #  COME HERE INHINTED.
038713,000216: 37,3705           55723                           TS       GAMDOT                                
038714,000217:                                                                                                  #  FOR NOW LEAVE IN 2S,C
038715,000218:                                                                                                  #  UPDATE ANGLES BY CORRECTING EUILER ANG
038716,000219:                                                                                                  #  FOR ACCRUED INCREMENT SINCE PIPUP
038717,000220:                                                                                                  #  R = R EUIL + R(NOW) - R(PIPUP)
038718,000221: 37,3706           40154                           CS       MPAC                                  #  GET (R EUL/180) /2
038719,000222: 37,3707           60000                           DOUBLE                                         #  POSSIBLE OVERFLOW
038720,000223: 37,3710           03757                           TC       CORANGOV                              #  CORRECT FOR OVFL IF ANY
038721,000224: 37,3711           00006                           EXTEND                                         
038722,000225: 37,3712           61672                           SU       ROLL/PIP                              #  GET INCR SINCE PIPUP
038723,000226: 37,3713           61664                           AD       ROLL/180                              #  ONLY SINGLE OVFL POSSIBLE.
038724,000227: 37,3714           03757                           TC       CORANGOV                              #  CORRECT FOR OVFL IF ANY

Page 888

038726,000229: 37,3715           55770                           TS       TEMPROLL                              
038727,000230: 
038728,000231: 37,3716           40156                           CS       MPAC       +2                         #  GET (ALFA EUL/180) /2
038729,000232: 37,3717           60000                           DOUBLE                                         #  SAME AS FOR ROLL.  NEEDED FOR EXT ATM DAP
038730,000233: 37,3720           03757                           TC       CORANGOV                              #  CORRECT FOR OVFL IF ANY
038731,000234: 37,3721           00006                           EXTEND                                         
038732,000235: 37,3722           61673                           SU       ALFA/PIP                              
038733,000236: 37,3723           61665                           AD       ALFA/180                              
038734,000237: 37,3724           03757                           TC       CORANGOV                              #  CORRECT FOR OVFL IF ANY
038735,000238: 37,3725           55771                           TS       TEMPALFA                              
038736,000239: 
038737,000240: 37,3726           40155                           CS       MPAC       +1                         #  GET (BETA EUL/180) /2
038738,000241: 37,3727           60000        CMTR2              DOUBLE                                         
038739,000242: 37,3730           00006                           EXTEND                                         
038740,000243: 37,3731           61674                           SU       BETA/PIP                              
038741,000244: 37,3732           61666                           AD       BETA/180                              
038742,000245: 37,3733           57772                           XCH      TEMPBETA                              #  OVFL NOT EXPECTED.
038743,000246: 
038744,000247: 37,3734           35051                           CA       EBANK3                                
038745,000248: 37,3735           54003                           TS       EBANK                                 
038746,000249: 
038747,000250: 37,3736  E3,1446                                  EBANK=   PHSNAME5                              
038748,000251: 37,3736           00006                           EXTEND                                         
038749,000252: 37,3737           33771                           DCA      REPOSADR                              #  THIS ASSUMES THAT THE         TC  PHASCHNG
038750,000253: 37,3740           53447                           DXCH     PHSNAME5                              #  IS NOT CHANGED IN             OCT 10035
038751,000254:                                                                                                  #  SERVICER.
038752,000255: 
038753,000256: 37,3741           35057                           CA       EBAOG                                 
038754,000257: 37,3742           54003                           TS       EBANK                                 
038755,000258: 
038756,000259: 37,3743  E6,1661                                  EBANK=   AOG                                   
038757,000260: 37,3743           00006        REDOPOSE           EXTEND                                         #  RE-STARTS COME HERE
038758,000261: 37,3744           31771                           DCA      TEMPROLL                              
038759,000262: 37,3745           53665                           DXCH     ROLL/180                              
038760,000263: 37,3746           31772                           CA       TEMPBETA                              
038761,000264: 37,3747           55666                           TS       BETA/180                              
038762,000265: 
038763,000266: 37,3750           00003                           RELINT                                         
038764,000267: 
038765,000268: 37,3751           06006                           TC       INTPRET                               #  CANT TC DANZIG AFTER PHASCHNG.
038766,000269: 37,3752           51575        CM/POSE3           VLOAD    ABVAL                                 #  RETURN FROM CM/ATUP.  (RESTART)
038767,000270: 37,3753           01177                                    VN                                    #  2(-7) M/CS
038768,000271: 37,3754           03723                           STORE    VMAGI                                 #  FOR DISPLAY ON CALL.
038769,000272: 
038770,000273: 37,3755           77650                           GOTO                                           
038771,000274: 37,3756           03324                                    POSEXIT                               #  ENDEXIT, STARTENT, OR SCALEPOP.
038772,000275: 
038773,000276: 37,3757           54001        CORANGOV           TS       L                                     
038774,000277: 37,3760           00002                           TC       Q                                     
038775,000278: 37,3761           50000                           INDEX    A                                     

Page 889

038777,000280: 37,3762           35000                           CA       LIMITS                                
038778,000281: 37,3763           26001                           ADS      L                                     
038779,000282: 37,3764           00002                           TC       Q                                     #  COSTS 2 MCT TO USE.  SEE ANGOVCOR.
038780,000283: 
038781,000284: 37,3765           45730 53410  -KVSCALE           2DEC     -.81491944                            #  -12800/(2 VS .3048)
038782,000285: 
038783,000286: 37,3767           03146        TCDU               DEC      .1                                    #  TCDU = .1 SEC.
038784,000287: 
038785,000288: 37,3770  E6,1661                                  EBANK=   AOG                                   
038786,000289: 37,3770           03743 76066  REPOSADR           2CADR    REDOPOSE                              
038787,000290: 

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