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.

052306,000002:                                                                                                  ## Copyright:   Public domain.
052307,000003:                                                                                                  ## Filename:    INFLIGHT_ALIGNMENT_ROUTINES.agc
052308,000004:                                                                                                  ## Purpose:     A section of Luminary 1C, revision 131.
052309,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
052310,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13.
052311,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
052312,000008:                                                                                                  ##              that the code format has been changed to conform to the
052313,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
052314,000010:                                                                                                  ##              original YUL assembler.
052315,000011:                                                                                                  ## Reference:   pp. 1241-1250
052316,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
052317,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
052318,000014:                                                                                                  ## Mod history: 06/03/03 RSB.   Began transcribing.
052319,000015:                                                                                                  ##              05/14/05 RSB.   Corrected website reference above.
052320,000016:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
052321,000017:                                                                                                  ##                              original hardcopy, as opposed to the PDF page
052322,000018:                                                                                                  ##                              numbers in 1701.pdf.
052323,000019:                                                                                                  ##              2017-02-27 RSB  Proofed comment text using octopus/ProoferComments.
052324,000020:                                                                                                  ##              2017-03-17 RSB  Comment-text fixes identified in diff'ing
052325,000021:                                                                                                  ##                              Luminary 99 vs Comanche 55.
052326,000022: 

Page 1241

052328,000024: 22,3773                                           BANK     22                                    
052329,000025: 23,2000                                           SETLOC   INFLIGHT                              
052330,000026: 23,2000                                           BANK                                           
052331,000027: 
052332,000028: 23,3251  E5,1642                                  EBANK=   XSM                                   
052333,000029: 
052334,000030:                                                                                                  #  CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
052335,000031: 
052336,000032:                                                                                                  #  THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES.  THE THREE
052337,000033:                                                                                                  #  HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
052338,000034: 
052339,000035:                                                                                                  #  THE OUTPUTS ARE THE THREE GYRO TORQUING ANGLES TO BE APPLIED TO THE Y, Z, AND X GYROS AND ARE STORED DP AT IGC,
052340,000036:                                                                                                  #  MGC, AND OGC RESPECTIVELY.
052341,000037: 
052342,000038: 23,3251                                           COUNT*   $$/INFLT                              
052343,000039: 23,3251           71220        CALCGTA            ITA      DLOAD                                 #  PUSHDOWN 00-03, 16D-27D, 34D-37D
052344,000040: 23,3252           00051                                    S2                                    #  XDC = (XD1 XD2 XD3)
052345,000041: 23,3253           02665                                    XDC                                   #  YDC = (YD1 YD2 YD3)
052346,000042: 23,3254           65325                           PDDL     PDDL                                  #  ZDC = (ZD1 ZD2 ZD3)
052347,000043: 23,3255           06524                                    HI6ZEROS                              
052348,000044: 23,3256           02671                                    XDC        +4                         
052349,000045: 23,3257           55476                           DCOMP    VDEF                                  
052350,000046: 23,3260           77656                           UNIT                                           
052351,000047: 23,3261           14027                           STODL    ZPRIME                                #  ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
052352,000048: 23,3262           00027                                    ZPRIME                                
052353,000049: 
052354,000050: 23,3263           77742                           SR1                                            
052355,000051: 23,3264           14023                           STODL    SINTH                                 #  SIN(IGC) = ZP1
052356,000052: 23,3265           00033                                    ZPRIME     +4                         
052357,000053: 23,3266           77742                           SR1                                            
052358,000054: 23,3267           34021                           STCALL   COSTH                                 #  COS(IGC) = ZP3
052359,000055: 23,3270           47322                                    ARCTRIG                               
052360,000056: 
052361,000057: 23,3271           16742                           STODL    IGC                                   #  Y GYRO TORQUING ANGLE   FRACTION OF REV.
052362,000058: 23,3272           02667                                    XDC        +2                         
052363,000059: 23,3273           77742                           SR1                                            
052364,000060: 23,3274           14023                           STODL    SINTH                                 #  SIN(MGC) = XD2
052365,000061: 23,3275           00027                                    ZPRIME                                
052366,000062: 
052367,000063: 23,3276           65205                           DMP      PDDL                                  
052368,000064: 23,3277           02671                                    XDC        +4                         #  PD00 = (ZP1)(XD3)
052369,000065: 23,3300           00033                                    ZPRIME     +4                         
052370,000066: 
052371,000067: 23,3301           45205                           DMP      DSU                                   
052372,000068: 23,3302           02665                                    XDC                                   #  MPAC = (ZP3)(XD1)
052373,000069: 23,3303           77626                           STADR                                          
052374,000070: 23,3304           43756                           STCALL   COSTH                                 #  COS(MGC) = MPAC - PD00
052375,000071: 23,3305           47322                                    ARCTRIG                               

Page 1242

052377,000073: 23,3306           26744                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
052378,000074: 23,3307           00027                                    ZPRIME                                
052379,000075: 23,3310           77641                           DOT                                            
052380,000076: 23,3311           02701                                    ZDC                                   
052381,000077: 23,3312           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
052382,000078: 23,3313           00027                                    ZPRIME                                
052383,000079: 23,3314           77641                           DOT                                            
052384,000080: 23,3315           02673                                    YDC                                   
052385,000081: 23,3316           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
052386,000082: 23,3317           47322                                    ARCTRIG                               
052387,000083: 
052388,000084: 23,3320           36740                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
052389,000085: 23,3321           00051                                    S2                                    
052390,000086: 

Page 1243

052392,000088:                                                                                                  #  ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
052393,000089: 
052394,000090:                                                                                                  #  THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
052395,000091: 
052396,000092:                                                                                                  #  THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA.  THE OUTPUT IS ALSO
052397,000093:                                                                                                  #  AVAILABLE AT MPAC.
052398,000094: 
052399,000095: 23,3322           51545        ARCTRIG            DLOAD    ABS                                   #  PUSHDOWN  16D-21D
052400,000096: 23,3323           00023                                    SINTH                                 
052401,000097: 23,3324           50025                           DSU      BMN                                   
052402,000098: 23,3325           07536                                    QTSN45                                #  ABS(SIN/4) - SIN(45)/4
052403,000099: 23,3326           47335                                    TRIG1                                 #  IF (-45,45) OR (135,-135)
052404,000100: 
052405,000101: 23,3327           72545                           DLOAD    SL1                                   #  (45,135) OR (-135,-45)
052406,000102: 23,3330           00021                                    COSTH                                 
052407,000103: 23,3331           75326                           ACOS     SIGN                                  
052408,000104: 23,3332           00023                                    SINTH                                 
052409,000105: 23,3333           00025                           STORE    THETA                                 #  X = ARCCOS(COS) WITH SIGN(SIN)
052410,000106: 23,3334           77616                           RVQ                                            
052411,000107: 
052412,000108: 23,3335           72545        TRIG1              DLOAD    SL1                                   #  (-45,45) OR (135,-135)
052413,000109: 23,3336           00023                                    SINTH                                 
052414,000110: 23,3337           77736                           ASIN                                           
052415,000111: 23,3340           14025                           STODL    THETA                                 #  X = ARCSIN(SIN) WITH SIGN(SIN)
052416,000112: 23,3341           00021                                    COSTH                                 
052417,000113: 23,3342           77640                           BMN                                            
052418,000114: 23,3343           47346                                    TRIG2                                 #  IF (135,-135)
052419,000115: 
052420,000116: 23,3344           43545                           DLOAD    RVQ                                   
052421,000117: 23,3345           00025                                    THETA                                 #  X = ARCSIN(SIN)   (-45,45)
052422,000118: 
052423,000119: 23,3346           75345        TRIG2              DLOAD    SIGN                                  #  (135,-135)
052424,000120: 23,3347           06522                                    HIDPHALF                              
052425,000121: 23,3350           00023                                    SINTH                                 
052426,000122: 23,3351           77625                           DSU                                            
052427,000123: 23,3352           00025                                    THETA                                 
052428,000124: 23,3353           00025                           STORE    THETA                                 #  X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
052429,000125: 23,3354           77616                           RVQ                                            #        (+) - (+) OR (-) - (-)
052430,000126: 

Page 1244

052432,000128:                                                                                                  #  SMNB, NBSM, AND AXISROT, WHICH USED TO APPEAR HERE, HAVE BEEN
052433,000129:                                                                                                  #  COMBINED IN A ROUTINE CALLED AX*SR*T, WHICH APPEARS AMONG THE POWERED
052434,000130:                                                                                                  #  FLIGHT SUBROUTINES.
052435,000131: 

Page 1245

052437,000133:                                                                                                  #  CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
052438,000134: 
052439,000135:                                                                                                  #  THE INPUTS ARE  1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM.  THE THREE HALF-UNIT
052440,000136:                                                                                                  #  VECTORS ARE STORED AT XNB, YNB, AND ZNB.  2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
052441,000137:                                                                                                  #  COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
052442,000138: 
052443,000139:                                                                                                  #  THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
052444,000140: 
052445,000141: 23,3355           77601        CALCGA             SETPD                                          #  PUSHDOWN 00-05, 16D-21D, 34D-37D
052446,000142: 23,3356           00001                                    0                                     
052447,000143: 23,3357           47375                           VLOAD    VXV                                   
052448,000144: 23,3360           02665                                    XNB                                   #  XNB = OGA (OUTER GIMBAL AXIS)
052449,000145: 23,3361           02651                                    YSM                                   #  YSM = IGA (INNER GIMBAL AXIS)
052450,000146: 23,3362           41456                           UNIT     PUSH                                  #  PD0 = UNIT(OGA X IGA) = MGA
052451,000147: 
052452,000148: 23,3363           44041                           DOT      ITA                                   
052453,000149: 23,3364           02701                                    ZNB                                   
052454,000150: 23,3365           00051                                    S2                                    
052455,000151: 23,3366           24021                           STOVL    COSTH                                 #  COS(OG) = MGA . ZNB
052456,000152: 23,3367           00001                                    0                                     
052457,000153: 23,3370           77641                           DOT                                            
052458,000154: 23,3371           02673                                    YNB                                   
052459,000155: 23,3372           34023                           STCALL   SINTH                                 #  SIN(OG) = MGA . YNB
052460,000156: 23,3373           47322                                    ARCTRIG                               
052461,000157: 23,3374           26740                           STOVL    OGC                                   
052462,000158: 23,3375           00001                                    0                                     
052463,000159: 
052464,000160: 23,3376           50235                           VXV      DOT                                   #  PROVISION FOR MG ANGLE OF 90 DEGREES
052465,000161: 23,3377           02665                                    XNB                                   
052466,000162: 23,3400           02651                                    YSM                                   
052467,000163: 23,3401           77752                           SL1                                            
052468,000164: 23,3402           24021                           STOVL    COSTH                                 #  COS(MG) = IGA . (MGA X OGA)
052469,000165: 23,3403           02651                                    YSM                                   
052470,000166: 23,3404           77641                           DOT                                            
052471,000167: 23,3405           02665                                    XNB                                   
052472,000168: 23,3406           34023                           STCALL   SINTH                                 #  SIN(MG) = IGA . OGA
052473,000169: 23,3407           47322                                    ARCTRIG                               
052474,000170: 23,3410           02744                           STORE    MGC                                   
052475,000171: 
052476,000172: 23,3411           45246                           ABS      DSU                                   
052477,000173: 23,3412           07540                                    .166...                               
052478,000174: 23,3413           77644                           BPL                                            
052479,000175: 23,3414           47433                                    GIMLOCK1                              #  IF ANGLE GREATER THAN 60 DEGREES
052480,000176: 
052481,000177: 23,3415           50375        CALCGA1            VLOAD    DOT                                   
052482,000178: 23,3416           02657                                    ZSM                                   
052483,000179: 23,3417           00001                                    0                                     
052484,000180: 23,3420           24021                           STOVL    COSTH                                 #  COS(IG) = ZSM . MGA
052485,000181: 23,3421           02643                                    XSM                                   

Page 1246

052487,000183: 23,3422           45441                           DOT      STADR                                 
052488,000184: 23,3423           43754                           STCALL   SINTH                                 #  SIN(IG) = XSM . MGA
052489,000185: 23,3424           47322                                    ARCTRIG                               
052490,000186: 
052491,000187: 23,3425           26742                           STOVL    IGC                                   
052492,000188: 23,3426           02740                                    OGC                                   
052493,000189: 23,3427           77634                           RTB                                            
052494,000190: 23,3430           21621                                    V1STO2S                               
052495,000191: 23,3431           34322                           STCALL   THETAD                                
052496,000192: 23,3432           00051                                    S2                                    
052497,000193: 
052498,000194: 23,3433           77776        GIMLOCK1           EXIT                                           
052499,000195: 23,3434           05567                           TC       ALARM                                 
052500,000196: 23,3435           00401                           OCT      00401                                 
052501,000197: 23,3436           05504                           TC       UPFLAG                                #  GIMBAL LOCK HAS OCCURED
052502,000198: 23,3437           00056                           ADRES    GLOKFAIL                              
052503,000199: 
052504,000200: 23,3440           06042                           TC       INTPRET                               
052505,000201: 23,3441           77650                           GOTO                                           
052506,000202: 23,3442           47415                                    CALCGA1                               
052507,000203: 

Page 1247

052509,000205:                                                                                                  #  AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
052510,000206: 
052511,000207:                                                                                                  #  THE INPUTS ARE  1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD.  2) THE STAR2 VECTOR
052512,000208:                                                                                                  #  REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6.  3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
052513,000209:                                                                                                  #  AT LOCATION 6 OF THE VAC AREA.  4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
052514,000210:                                                                                                  #  THE VAC AREA.
052515,000211: 
052516,000212:                                                                                                  #  THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B.  THE THREE HALF-UNIT VECTORS ARE STORED
052517,000213:                                                                                                  #  AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
052518,000214: 
052519,000215: 23,3443           66370        AXISGEN            AXT,1    SSP                                   #  PUSHDOWN 00-30D, 34D-37D
052520,000216: 23,3444           02714                                    STARAD     +6                         
052521,000217: 23,3445           00051                                    S1                                    
052522,000218: 23,3446           02700                                    STARAD     -6                         
052523,000219: 
052524,000220: 23,3447           77601                           SETPD                                          
052525,000221: 23,3450           00001                                    0                                     
052526,000222: 23,3451           46773        AXISGEN1           VLOAD*   VXV*                                  #  06D   UA = S1
052527,000223: 23,3452           02723                                    STARAD     +12D,1                     #        STARAD +00D     UB = S1
052528,000224: 23,3453           02731                                    STARAD     +18D,1                     
052529,000225: 23,3454           77656                           UNIT                                           #  12D   VA = UNIT(S1 X S2)
052530,000226: 23,3455           06731                           STORE    STARAD     +18D,1                     #        STARAD +06D     VB = UNIT(S1 X S2)
052531,000227: 23,3456           77773                           VLOAD*                                         
052532,000228: 23,3457           02723                                    STARAD     +12D,1                     
052533,000229: 
052534,000230: 23,3460           76433                           VXV*     VSL1                                  
052535,000231: 23,3461           02731                                    STARAD     +18D,1                     #  18D   WA = UA X VA
052536,000232: 23,3462           06737                           STORE    STARAD     +24D,1                     #        STARAD +12D     WB = UB X VB
052537,000233: 
052538,000234: 23,3463           77700                           TIX,1                                          
052539,000235: 23,3464           47451                                    AXISGEN1                              
052540,000236: 
052541,000237: 23,3465           66160                           AXC,1    SXA,1                                 
052542,000238: 23,3466           00006                                    6                                     
052543,000239: 23,3467           00036                                    30D                                   
052544,000240: 
052545,000241: 23,3470           66370                           AXT,1    SSP                                   
052546,000242: 23,3471           00022                                    18D                                   
052547,000243: 23,3472           00051                                    S1                                    
052548,000244: 23,3473           00006                                    6                                     
052549,000245: 
052550,000246: 23,3474           66374                           AXT,2    SSP                                   
052551,000247: 23,3475           00006                                    6                                     
052552,000248: 23,3476           00052                                    S2                                    
052553,000249: 23,3477           00002                                    2                                     
052554,000250: 
052555,000251: 23,3500           76720        AXISGEN2           XCHX,1   VLOAD*                                
052556,000252: 23,3501           00036                                    30D                                   #  X1=-6 X2=+6   X1=-6 X2=+4     X1=-6 X2=+2
052557,000253: 23,3502           00001                                    0,1                                   
052558,000254: 

Page 1248

052560,000256: 23,3503           62757                           VXSC*    PDVL*                                 #  J=(UA)(UB1)   J=(UA)(UB2)     J=(UA)(UB3)
052561,000257: 23,3504           75062                                    STARAD     +6,2                       
052562,000258: 23,3505           00007                                    6,1                                   
052563,000259: 23,3506           77757                           VXSC*                                          
052564,000260: 23,3507           75054                                    STARAD     +12D,2                     
052565,000261: 23,3510           30031                           STOVL*   24D                                   #  K=(VA)(VB1)   J=(VA)(VB2)     J=(VA)(VB3)
052566,000262: 23,3511           00015                                    12D,1                                 
052567,000263: 
052568,000264: 23,3512           53357                           VXSC*    VAD                                   
052569,000265: 23,3513           75046                                    STARAD     +18D,2                     #  L=(WA)(WB1)   J=(WA)(WB2)     J=(WA)(WB3)
052570,000266: 23,3514           76455                           VAD      VSL1                                  
052571,000267: 23,3515           00031                                    24D                                   
052572,000268: 23,3516           53520                           XCHX,1   UNIT                                  
052573,000269: 23,3517           00036                                    30D                                   
052574,000270: 23,3520           06707                           STORE    XDC        +18D,1                     #  XDC = L+J+K   YDC = L+J+K     ZDC = L+J+K
052575,000271: 
052576,000272: 23,3521           77700                           TIX,1                                          
052577,000273: 23,3522           47523                                    AXISGEN3                              
052578,000274: 
052579,000275: 23,3523           77704        AXISGEN3           TIX,2                                          
052580,000276: 23,3524           47500                                    AXISGEN2                              
052581,000277: 
052582,000278: 23,3525           77775                           VLOAD                                          
052583,000279: 23,3526           02665                                    XDC                                   
052584,000280: 23,3527           26707                           STOVL    STARAD                                
052585,000281: 23,3530           02673                                    YDC                                   
052586,000282: 23,3531           26715                           STOVL    STARAD     +6                         
052587,000283: 23,3532           02701                                    ZDC                                   
052588,000284: 23,3533           02723                           STORE    STARAD     +12D                       
052589,000285: 
052590,000286: 23,3534           77616                           RVQ                                            
052591,000287: 

Page 1249

052593,000289: 23,3535           05520 26075  QTSN45             2DEC     .1768                                 
052594,000290: 23,3537           05252 25253  .166...            2DEC     .1666666667                            
052595,000291: 

Page 1250 There is no source code on this page of the original assembly listing.


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