Source Code

These source-code files are part of a reconstructed copy of Comanche 51, the initial release (though not the final mission release) of the Apollo 11 Command Module (CM) Apollo Guidance Computer (AGC) software. The flown, final release was Comanche 55. The reconstruction is believed to be exactly accurate, but in the absence of an actual Apollo-era listing of Comanche 51, some explanation of the reconstruction process is needed to insure confidence in that accuracy.

The starting point was the source code of Comanche 55, whose original source code is available. Comanche 55 source code was then modified by undoing changes known to have been made between revisions 51 and 55. The most-significant steps involved reverting changes related to the R-2 lunar potential model, the details of which were known from the previous, separate, independent reconstruction of the Apollo 10 Lunar Module software Luminary 69/2. The now-reconstructed Comanche 51 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 match those on the Comanche 55 or Luminary 69 printouts, although the source code would likely have different page numbers in a contemporary Comanche 51 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 55. Here's a guide to some of the Apollo documentation relevant to those annotations:
Among documentation not actually referenced in the annotations, there is a short writeup about the reconstruction process in our software repository that may be helpful in understanding it from a different perspective. There's also a handy table that lists what the number of memory-words should be for each routine in Comanche 51, which could make a nice double-check; however, we've not performed that double-check ourselves.

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.

017689,000002:                                                                                                  ## Copyright:   Public domain.
017690,000003:                                                                                                  ## Filename:    GIMBAL_LOCK_AVOIDANCE.agc
017691,000004:                                                                                                  ## Purpose:     A section of Comanche revision 051.
017692,000005:                                                                                                  ##              It is part of the reconstructed source code for the
017693,000006:                                                                                                  ##              original release of the flight software for the Command
017694,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 11.
017695,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
017696,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
017697,000010:                                                                                                  ##              exactly match those specified for Comanche 51 in NASA drawing
017698,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
017699,000012:                                                                                                  ##              reconstruction is correct.
017700,000013:                                                                                                  ## Reference:   pp. 412-413
017701,000014:                                                                                                  ## Assembler:   yaYUL
017702,000015:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
017703,000016:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
017704,000017:                                                                                                  ## Mod history: 2019-07-30 MAS  Created from Comanche 55.
017705,000018: 

Page 412

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

Page 413

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