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.

017685,000002:                                                                                                  ## Copyright:   Public domain.
017686,000003:                                                                                                  ## Filename:    GIMBAL_LOCK_AVOIDANCE.agc
017687,000004:                                                                                                  ## Purpose:     A section of Manche45 revision 2.
017688,000005:                                                                                                  ##              It is part of the reconstructed source code for the
017689,000006:                                                                                                  ##              final, flown release of the flight software for the Command
017690,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
017691,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
017692,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
017693,000010:                                                                                                  ##              exactly match those specified for Manche 45/2 in NASA drawing
017694,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
017695,000012:                                                                                                  ##              reconstruction is correct.
017696,000013:                                                                                                  ## Assembler:   yaYUL
017697,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
017698,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
017699,000016:                                                                                                  ## Mod history: 2020-12-24 MAS  Created from Comanche 45.
017700,000017: 

Page 412

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

Page 413

017753,000070: 22,3004           00000 00000                     2DEC     0          B-28                       #  AXES (X ROT = -7.25 DEG)
017754,000071: 
017755,000072: 22,3006           00000 00000                     2DEC     0          B-28                       
017756,000073: 
017757,000074: 22,3010           00000 00000                     2DEC     0          B-28                       
017758,000075: 
017759,000076: 22,3012           03131 11275                     2DEC     .099200                               #  =(.1)COS7.25
017760,000077: 
017761,000078: 22,3014           77461 47370                     2DEC     -.012620                              #  =-(.1)SIN7.25
017762,000079: 
017763,000080: 22,3016           00000 00000                     2DEC     0          B-28                       
017764,000081: 
017765,000082: 22,3020           00316 30407                     2DEC     .012620                               #  (.1)SIN7.25
017766,000083: 
017767,000084: 22,3022           03131 11275                     2DEC     .099200                               #  (.1)COS7.25
017768,000085: 
017769,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