Source Code

This source code is very close to the Apollo Guidance Computer software for the Apollo 13 Lunar module. This revision of the Luminary 131 program is from December of 1969, whereas there was a later revision in January of 1970, and still another revision in February, which is the code that flew on the mission. As far as this transcription is concerned, it was originally from a copy made in 1991 of a printout from the collection of AGC developer Don Eyles for collector David Craig. It was subsequently scanned by Gary Neff, reprocessed for online presentation at the now-discontinued History of Recent Science and Technology (HRST) website of MIT's Dibner Institute (the full-quality scans being discarded in the process), and finally transcribed by Ron Burkey for the Virtual AGC Project. Although a high-quality replacement scan for a completely illegible page was later provided by Gary Neff, the reduced legibility of the reprocessed HRST posting nevertheless caused many errors to be introduced into the transcription. Accordingly, a second scan of the same physical printout was made in 2017 for the Virtual AGC Project's collection at the Internet Archive, and used to correct the transcription errors. All of the scanned materials mentioned, as well as other Luminary 131 related material, are available online. Don Eyles apprently made additional hand-written notes in printout between 1991 and 2017, so the two scans are not identical in that respect. The page-headings in the printout read, in part:
	GAP:  ASSEMBLE REVISION 131 OF AGC PROGRAM LUMINARY BY NASA 2021112-091
	17:53 DEC. 19, 1969
Note that the date is the date the printout was made, not the date on which the program revision was released, although these happen to be very close together.

015183,000002:                                                                                                  ## Copyright:   Public domain.
015184,000003:                                                                                                  ## Filename:    GIMBAL_LOCK_AVOIDANCE.agc
015185,000004:                                                                                                  ## Purpose:     A section of Luminary 1C, revision 131.
015186,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
015187,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13.
015188,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
015189,000008:                                                                                                  ##              that the code format has been changed to conform to the
015190,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the 
015191,000010:                                                                                                  ##              original YUL assembler.
015192,000011:                                                                                                  ## Reference:   p. 366
015193,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
015194,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
015195,000014:                                                                                                  ## Mod history: 05/11/03 RSB.   Began transcribing.
015196,000015:                                                                                                  ##              05/14/05 RSB    Corrected website reference above.
015197,000016:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
015198,000017:                                                                                                  ##                              original harcopy, as opposed to the PDF page
015199,000018:                                                                                                  ##                              numbers in 1701.pdf.
015200,000019:                                                                                                  ##              2017-02-23 RSB  Proofed comment text using octopus/ProoferComments.
015201,000020:                                                                                                  ##              2017-08-22 RSB  Fixed comment-text typo identified in ZERLINA 56.
015202,000021: 

Page 366

015204,000023: 15,2050                                           BANK     15                                    
015205,000024: 
015206,000025: 22,2000                                           SETLOC   KALCMON1                              
015207,000026: 22,2000                                           BANK                                           
015208,000027: 
015209,000028:                                                                                                  #  DETECTING GIMBAL LOCK
015210,000029: 22,2744  22,2744               LOCSKIRT           EQUALS   NOGIMLOC                              
015211,000030: 
015212,000031: 22,2744           77614        NOGIMLOC           SET                                            
015213,000032: 22,2745           01074                                    CALCMAN3                              
015214,000033: 22,2746           70740        WCALC              LXC,1    DLOAD*                                
015215,000034: 22,2747           01322                                    RATEINDX                              #  CHOOSE THE DESIRED MANEUVER RATE
015216,000035: 22,2750           04772                                    ARATE,1                               #  FROM A LIST OF FOUR
015217,000036: 22,2751           45002                           SR4      CALL                                  #  COMPUTE THE INCREMENTAL ROTATION MATRIX
015218,000037: 22,2752           44527                                    DELCOMP                               #  DEL CORRESPONDING TO A 1 SEC ROTATION
015219,000038:                                                                                                  #  ABOUT COF
015220,000039: 22,2753           74343                           DLOAD*   VXSC                                  
015221,000040: 22,2754           04772                                    ARATE,1                               
015222,000041: 22,2755           03270                                    COF                                   
015223,000042: 22,2756           17325                           STODL    BRATE                                 #  COMPONENT MANEUVER RATES 45 DEG/SEC
015224,000043: 22,2757           03335                                    AM                                    
015225,000044: 22,2760           55605                           DMP      DDV*                                  
015226,000045: 22,2761           05002                                    ANGLTIME                              
015227,000046: 22,2762           04772                                    ARATE,1                               
015228,000047: 22,2763           77661                           SR                                             
015229,000048: 22,2764           20606                                    5                                     
015230,000049: 22,2765           03333                           STORE    TM                                    #  MANEUVER EXECUTION TIME SCALED AS T2
015231,000050: 22,2766           77614                           SETGO                                          
015232,000051: 22,2767           01035                                    CALCMAN2                              #  0(OFF) = CONTINUE MANEUVER
015233,000052: 22,2770           45010                                    NEWANGL    +1                         #  1(ON) = START MANEUVER
015234,000053: 
015235,000054:                                                                                                  #  THE FOUR SELECTABLE FREE FALL MANEUVER RATES SELECTED BY
015236,000055:                                                                                                  #  LOADING RATEINDX WITH 0, 2, 4, 6, RESPECTIVELY
015237,000056: 
015238,000057: 22,2771           00221 24255  ARATE              2DEC     .0088888888                            #  = 0.2 DEG/SEC                 $ 22.5 DEG/SEC
015239,000058: 22,2773           00554 02660                     2DEC     .0222222222                            #  = 0.5 DEG/SEC                 $ 22.5 DEG/SEC
015240,000059: 22,2775           02660 13301                     2DEC     .0888888888                            #  = 2.0 DEG/SEC                 $ 22.5 DEG/SEC
015241,000060: 22,2777           16161 30707                     2DEC     .4444444444                            #  = 10.0 DEG/SEC                $ 22.5 DEG/SEC
015242,000061: 
015243,000062: 22,3001           00003 04000  ANGLTIME           2DEC     .0001907349                            #  = 100B-19 FUDGE FACTOR TO CONVERT
015244,000063:                                                                                                  #  MANEUVER ANGLE TO MANEUVER TIME
015245,000064: 
015246,000065: 

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