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.

017671,000002:                                                                                                  ## Copyright:   Public domain.
017672,000003:                                                                                                  ## Filename:    GIMBAL_LOCK_AVOIDANCE.agc
017673,000004:                                                                                                  ## Purpose:     A section of Comanche revision 045.
017674,000005:                                                                                                  ##              It is part of the reconstructed source code for the
017675,000006:                                                                                                  ##              second release of the flight software for the Command
017676,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
017677,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
017678,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
017679,000010:                                                                                                  ##              exactly match those specified for Comanche 45 in NASA drawing
017680,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
017681,000012:                                                                                                  ##              reconstruction is correct.
017682,000013:                                                                                                  ## Assembler:   yaYUL
017683,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
017684,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
017685,000016:                                                                                                  ## Mod history: 2020-12-06 MAS  Created from Comanche 44.
017686,000017: 

Page 412

017688,000019: 15,2000                                           BANK     15                                    
017689,000020: 22,2000                                           SETLOC   KALCMON1                              
017690,000021: 22,2000                                           BANK                                           
017691,000022: 
017692,000023: 22,2737  E6,1661                                  EBANK=   BCDU                                  
017693,000024: 
017694,000025:                                                                                                  #  DETECTING GIMBAL LOCK
017695,000026: 22,2737  22,2737               LOCSKIRT           EQUALS   WCALC                                 
017696,000027: 22,2737           70740        WCALC              LXC,1    DLOAD*                                
017697,000028: 22,2740           01130                                    RATEINDX                              
017698,000029: 22,2741           04771                                    ARATE,1                               
017699,000030: 22,2742           45002                           SR4      CALL                                  #  COMPUTE THE INCREMENTAL ROTATION MATRIX
017700,000031: 22,2743           44530                                    DELCOMP                               #  DEL CORRESPONDING TO A 1 SEC ROTATION
017701,000032:                                                                                                  #  ABOUT COF
017702,000033: 22,2744           74343                           DLOAD*   VXSC                                  
017703,000034: 22,2745           04771                                    ARATE,1                               
017704,000035: 22,2746           03343                                    COF                                   
017705,000036: 22,2747           77721                           MXV                                            
017706,000037: 22,2750           05003                                    QUADROT                               
017707,000038: 22,2751           17311                           STODL    BRATE                                 
017708,000039: 22,2752           03365                                    AM                                    
017709,000040: 22,2753           55605                           DMP      DDV*                                  
017710,000041: 22,2754           05001                                    ANGLTIME                              
017711,000042: 22,2755           04771                                    ARATE,1                               
017712,000043: 22,2756           77661                           SR                                             
017713,000044: 22,2757           20606                                    5                                     
017714,000045: 22,2760           27317                           STOVL    TM                                    
017715,000046: 22,2761           03311                                    BRATE                                 
017716,000047: 22,2762           77761                           VXSC                                           
017717,000048: 22,2763           05025                                    BIASCALE                              
017718,000049: 22,2764           03275                           STORE    BIASTEMP                              #  ATTITUDE ERROR BIAS TO PREVENT OVERSHOOT
017719,000050:                                                                                                  #  IN SYSTEM
017720,000051: 22,2765           77614                           SETGO                                          #  STATE SWITCH CALCMAN2 (43D)
017721,000052: 22,2766           01035                                    CALCMAN2                              #  0(OFF) = BYPASS STARTING PROCEDURE
017722,000053: 22,2767           45032                                    NEWANGL    +1                         #  1(ON) = START MANEUVER
017723,000054: 
017724,000055: 
017725,000056: 22,2770           00044 15053  ARATE              2DEC     .0022222222                            #  = .05 DEG/SEC
017726,000057: 
017727,000058: 22,2772           00221 24255                     2DEC     .0088888889                            #  = .2 DEG/SEC
017728,000059: 
017729,000060: 22,2774           00554 02660                     2DEC     .0222222222                            #  = .5 DEG/SEC
017730,000061: 
017731,000062: 22,2776           05540 26603                     2DEC     .1777777777                            #  = 4 DEG/SEC           $ 22.5 DEG/SEC
017732,000063: 
017733,000064: 22,3000           00003 04000  ANGLTIME           2DEC     .000190735                            #  = 100B - 19
017734,000065: 
017735,000066:                                                                                                  #  MANEUVER ANGLE TO MANEUVER TIME
017736,000067: 22,3002           03146 14632  QUADROT            2DEC     .1                                    #  ROTATION MATRIX FROM S/C AXES TO CONTROL
017737,000068: 

Page 413

017739,000070: 22,3004           00000 00000                     2DEC     0          B-28                       #  AXES (X ROT = -7.25 DEG)
017740,000071: 
017741,000072: 22,3006           00000 00000                     2DEC     0          B-28                       
017742,000073: 
017743,000074: 22,3010           00000 00000                     2DEC     0          B-28                       
017744,000075: 
017745,000076: 22,3012           03131 11275                     2DEC     .099200                               #  =(.1)COS7.25
017746,000077: 
017747,000078: 22,3014           77461 47370                     2DEC     -.012620                              #  =-(.1)SIN7.25
017748,000079: 
017749,000080: 22,3016           00000 00000                     2DEC     0          B-28                       
017750,000081: 
017751,000082: 22,3020           00316 30407                     2DEC     .012620                               #  (.1)SIN7.25
017752,000083: 
017753,000084: 22,3022           03131 11275                     2DEC     .099200                               #  (.1)COS7.25
017754,000085: 
017755,000086: 22,3024           00004 05253  BIASCALE           2DEC     .0002543132                            #  = (450/180)(1/0.6)(1/16384)

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