Source Code

These source-code files are part of a reconstructed copy of Luminary 97, the second release of the Apollo 11 Lunar Module (LM) Apollo Guidance Computer (AGC) software. It was created to fix two incorrect ephemeris constants in Luminary 96, as described by anomaly report LNY-59.

The reconstruction began with source code of Luminary 99 revision 1 previously transcribed from a digitized copy of that program. The code was then updated by undoing changes described in original Luminary memos 83 and 85, using asterisks indicating changed lines in the listing as a guide. The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021152D. Note that page numbers in the reconstructed code match those on the Luminary 099 revision 001 printout, although the added code would likely have changed page numbers for a real Luminary 97 listing.

Comments from 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.

052642,000002:                                                                                                  ## Copyright:   Public domain.
052643,000003:                                                                                                  ## Filename:    INFLIGHT_ALIGNMENT_ROUTINES.agc
052644,000004:                                                                                                  ## Purpose:     A section of Luminary revision 97.
052645,000005:                                                                                                  ##              It is part of the reconstructed source code for the
052646,000006:                                                                                                  ##              second release of the flight software for the Lunar 
052647,000007:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 11.
052648,000008:                                                                                                  ##              It was created to fix two incorrect ephemeris constants in
052649,000009:                                                                                                  ##              Luminary 96, as described by anomaly report LNY-59.
052650,000010:                                                                                                  ##              The code has been recreated from a copy of Luminary 99
052651,000011:                                                                                                  ##              revision 001, using asterisks indicating changed lines in
052652,000012:                                                                                                  ##              the listing and Luminary Memos #83 and #85, which list 
052653,000013:                                                                                                  ##              changes between Luminary 97 and 98, and 98 and 99. The
052654,000014:                                                                                                  ##              code has been adapted such that the resulting bugger words
052655,000015:                                                                                                  ##              exactly match those specified for Luminary 97 in NASA drawing
052656,000016:                                                                                                  ##              2021152D, which gives relatively high confidence that the
052657,000017:                                                                                                  ##              reconstruction is correct.
052658,000018:                                                                                                  ## Reference:   pp. 1249-1258
052659,000019:                                                                                                  ## Assembler:   yaYUL
052660,000020:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
052661,000021:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
052662,000022:                                                                                                  ## Mod history: 2019-07-28 MAS  Created from Luminary 99.
052663,000023: 

Page 1249

052665,000025: 22,3773                                           BANK     22                                    
052666,000026: 23,2000                                           SETLOC   INFLIGHT                              
052667,000027: 23,2000                                           BANK                                           
052668,000028: 
052669,000029: 23,3247  E5,1642                                  EBANK=   XSM                                   
052670,000030: 
052671,000031:                                                                                                  #  CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
052672,000032: 
052673,000033:                                                                                                  #  THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES.  THE THREE
052674,000034:                                                                                                  #  HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
052675,000035: 
052676,000036:                                                                                                  #  THE OUTPUTS ARE THE THREE GYRO TORQUING ANGLES TO BE APPLIED TO THE Y, Z, AND X GYROS AND ARE STORED DP AT IGC,
052677,000037:                                                                                                  #  MGC, AND OGC RESPECTIVELY.
052678,000038: 
052679,000039: 23,3247                                           COUNT*   $$/INFLT                              
052680,000040: 23,3247           71220        CALCGTA            ITA      DLOAD                                 #  PUSHDOWN 00-03, 16D-27D, 34D-37D
052681,000041: 23,3250           00051                                    S2                                    #  XDC = (XD1 XD2 XD3)
052682,000042: 23,3251           02665                                    XDC                                   #  YDC = (YD1 YD2 YD3)
052683,000043: 23,3252           65325                           PDDL     PDDL                                  #  ZDC = (ZD1 ZD2 ZD3)
052684,000044: 23,3253           06522                                    HI6ZEROS                              
052685,000045: 23,3254           02671                                    XDC        +4                         
052686,000046: 23,3255           55476                           DCOMP    VDEF                                  
052687,000047: 23,3256           77656                           UNIT                                           
052688,000048: 23,3257           14027                           STODL    ZPRIME                                #  ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
052689,000049: 23,3260           00027                                    ZPRIME                                
052690,000050: 
052691,000051: 23,3261           77742                           SR1                                            
052692,000052: 23,3262           14023                           STODL    SINTH                                 #  SIN(IGC) = ZP1
052693,000053: 23,3263           00033                                    ZPRIME     +4                         
052694,000054: 23,3264           77742                           SR1                                            
052695,000055: 23,3265           34021                           STCALL   COSTH                                 #  COS(IGC) = ZP3
052696,000056: 23,3266           47320                                    ARCTRIG                               
052697,000057: 
052698,000058: 23,3267           16742                           STODL    IGC                                   #  Y GYRO TORQUING ANGLE   FRACTION OF REV.
052699,000059: 23,3270           02667                                    XDC        +2                         
052700,000060: 23,3271           77742                           SR1                                            
052701,000061: 23,3272           14023                           STODL    SINTH                                 #  SIN(MGC) = XD2
052702,000062: 23,3273           00027                                    ZPRIME                                
052703,000063: 
052704,000064: 23,3274           65205                           DMP      PDDL                                  
052705,000065: 23,3275           02671                                    XDC        +4                         #  PD00 = (ZP1)(XD3)
052706,000066: 23,3276           00033                                    ZPRIME     +4                         
052707,000067: 
052708,000068: 23,3277           45205                           DMP      DSU                                   
052709,000069: 23,3300           02665                                    XDC                                   #  MPAC = (ZP3)(XD1)
052710,000070: 23,3301           77626                           STADR                                          
052711,000071: 23,3302           43756                           STCALL   COSTH                                 #  COS(MGC) = MPAC - PD00
052712,000072: 23,3303           47320                                    ARCTRIG                               

Page 1250

052714,000074: 23,3304           26744                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
052715,000075: 23,3305           00027                                    ZPRIME                                
052716,000076: 23,3306           77641                           DOT                                            
052717,000077: 23,3307           02701                                    ZDC                                   
052718,000078: 23,3310           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
052719,000079: 23,3311           00027                                    ZPRIME                                
052720,000080: 23,3312           77641                           DOT                                            
052721,000081: 23,3313           02673                                    YDC                                   
052722,000082: 23,3314           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
052723,000083: 23,3315           47320                                    ARCTRIG                               
052724,000084: 
052725,000085: 23,3316           36740                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
052726,000086: 23,3317           00051                                    S2                                    
052727,000087: 

Page 1251

052729,000089:                                                                                                  #  ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
052730,000090: 
052731,000091:                                                                                                  #  THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
052732,000092: 
052733,000093:                                                                                                  #  THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA.  THE OUTPUT IS ALSO
052734,000094:                                                                                                  #  AVAILABLE AT MPAC.
052735,000095: 
052736,000096: 23,3320           51545        ARCTRIG            DLOAD    ABS                                   #  PUSHDOWN  16D-21D
052737,000097: 23,3321           00023                                    SINTH                                 
052738,000098: 23,3322           50025                           DSU      BMN                                   
052739,000099: 23,3323           07534                                    QTSN45                                #  ABS(SIN/4) - SIN(45)/4
052740,000100: 23,3324           47333                                    TRIG1                                 #  IF (-45,45) OR (135,-135)
052741,000101: 
052742,000102: 23,3325           72545                           DLOAD    SL1                                   #  (45,135) OR (-135,-45)
052743,000103: 23,3326           00021                                    COSTH                                 
052744,000104: 23,3327           75326                           ACOS     SIGN                                  
052745,000105: 23,3330           00023                                    SINTH                                 
052746,000106: 23,3331           00025                           STORE    THETA                                 #  X = ARCCOS(COS) WITH SIGN(SIN)
052747,000107: 23,3332           77616                           RVQ                                            
052748,000108: 
052749,000109: 23,3333           72545        TRIG1              DLOAD    SL1                                   #  (-45,45) OR (135,-135)
052750,000110: 23,3334           00023                                    SINTH                                 
052751,000111: 23,3335           77736                           ASIN                                           
052752,000112: 23,3336           14025                           STODL    THETA                                 #  X = ARCSIN(SIN) WITH SIGN(SIN)
052753,000113: 23,3337           00021                                    COSTH                                 
052754,000114: 23,3340           77640                           BMN                                            
052755,000115: 23,3341           47344                                    TRIG2                                 #  IF (135,-135)
052756,000116: 
052757,000117: 23,3342           43545                           DLOAD    RVQ                                   
052758,000118: 23,3343           00025                                    THETA                                 #  X = ARCSIN(SIN)   (-45,45)
052759,000119: 
052760,000120: 23,3344           75345        TRIG2              DLOAD    SIGN                                  #  (135,-135)
052761,000121: 23,3345           06520                                    HIDPHALF                              
052762,000122: 23,3346           00023                                    SINTH                                 
052763,000123: 23,3347           77625                           DSU                                            
052764,000124: 23,3350           00025                                    THETA                                 
052765,000125: 23,3351           00025                           STORE    THETA                                 #  X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
052766,000126: 23,3352           77616                           RVQ                                            #        (+) - (+) OR (-) - (-)
052767,000127: 

Page 1252

052769,000129:                                                                                                  #  SMNB, NBSM, AND AXISROT, WHICH USED TO APPEAR HERE, HAVE BEEN
052770,000130:                                                                                                  #  COMBINED IN A ROUTINE CALLED AX*SR*T, WHICH APPEARS AMONG THE POWERED
052771,000131:                                                                                                  #  FLIGHT SUBROUTINES.
052772,000132: 

Page 1253

052774,000134:                                                                                                  #  CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
052775,000135: 
052776,000136:                                                                                                  #  THE INPUTS ARE  1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM.  THE THREE HALF-UNIT
052777,000137:                                                                                                  #  VECTORS ARE STORED AT XNB, YNB, AND ZNB.  2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
052778,000138:                                                                                                  #  COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
052779,000139: 
052780,000140:                                                                                                  #  THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
052781,000141: 
052782,000142: 23,3353           77601        CALCGA             SETPD                                          #  PUSHDOWN 00-05, 16D-21D, 34D-37D
052783,000143: 23,3354           00001                                    0                                     
052784,000144: 23,3355           47375                           VLOAD    VXV                                   
052785,000145: 23,3356           02665                                    XNB                                   #  XNB = OGA (OUTER GIMBAL AXIS)
052786,000146: 23,3357           02651                                    YSM                                   #  YSM = IGA (INNER GIMBAL AXIS)
052787,000147: 23,3360           41456                           UNIT     PUSH                                  #  PD0 = UNIT(OGA X IGA) = MGA
052788,000148: 
052789,000149: 23,3361           44041                           DOT      ITA                                   
052790,000150: 23,3362           02701                                    ZNB                                   
052791,000151: 23,3363           00051                                    S2                                    
052792,000152: 23,3364           24021                           STOVL    COSTH                                 #  COS(OG) = MGA . ZNB
052793,000153: 23,3365           00001                                    0                                     
052794,000154: 23,3366           77641                           DOT                                            
052795,000155: 23,3367           02673                                    YNB                                   
052796,000156: 23,3370           34023                           STCALL   SINTH                                 #  SIN(OG) = MGA . YNB
052797,000157: 23,3371           47320                                    ARCTRIG                               
052798,000158: 23,3372           26740                           STOVL    OGC                                   
052799,000159: 23,3373           00001                                    0                                     
052800,000160: 
052801,000161: 23,3374           50235                           VXV      DOT                                   #  PROVISION FOR MG ANGLE OF 90 DEGREES
052802,000162: 23,3375           02665                                    XNB                                   
052803,000163: 23,3376           02651                                    YSM                                   
052804,000164: 23,3377           77752                           SL1                                            
052805,000165: 23,3400           24021                           STOVL    COSTH                                 #  COS(MG) = IGA . (MGA X OGA)
052806,000166: 23,3401           02651                                    YSM                                   
052807,000167: 23,3402           77641                           DOT                                            
052808,000168: 23,3403           02665                                    XNB                                   
052809,000169: 23,3404           34023                           STCALL   SINTH                                 #  SIN(MG) = IGA . OGA
052810,000170: 23,3405           47320                                    ARCTRIG                               
052811,000171: 23,3406           02744                           STORE    MGC                                   
052812,000172: 
052813,000173: 23,3407           45246                           ABS      DSU                                   
052814,000174: 23,3410           07536                                    .166...                               
052815,000175: 23,3411           77644                           BPL                                            
052816,000176: 23,3412           47431                                    GIMLOCK1                              #  IF ANGLE GREATER THAN 60 DEGREES
052817,000177: 
052818,000178: 23,3413           50375        CALCGA1            VLOAD    DOT                                   
052819,000179: 23,3414           02657                                    ZSM                                   
052820,000180: 23,3415           00001                                    0                                     
052821,000181: 23,3416           24021                           STOVL    COSTH                                 #  COS(IG) = ZSM . MGA
052822,000182: 23,3417           02643                                    XSM                                   

Page 1254

052824,000184: 23,3420           45441                           DOT      STADR                                 
052825,000185: 23,3421           43754                           STCALL   SINTH                                 #  SIN(IG) = XSM . MGA
052826,000186: 23,3422           47320                                    ARCTRIG                               
052827,000187: 
052828,000188: 23,3423           26742                           STOVL    IGC                                   
052829,000189: 23,3424           02740                                    OGC                                   
052830,000190: 23,3425           77634                           RTB                                            
052831,000191: 23,3426           21620                                    V1STO2S                               
052832,000192: 23,3427           34322                           STCALL   THETAD                                
052833,000193: 23,3430           00051                                    S2                                    
052834,000194: 
052835,000195: 23,3431           77776        GIMLOCK1           EXIT                                           
052836,000196: 23,3432           05567                           TC       ALARM                                 
052837,000197: 23,3433           00401                           OCT      00401                                 
052838,000198: 23,3434           05504                           TC       UPFLAG                                #  GIMBAL LOCK HAS OCCURED
052839,000199: 23,3435           00056                           ADRES    GLOKFAIL                              
052840,000200: 
052841,000201: 23,3436           06037                           TC       INTPRET                               
052842,000202: 23,3437           77650                           GOTO                                           
052843,000203: 23,3440           47413                                    CALCGA1                               
052844,000204: 

Page 1255

052846,000206:                                                                                                  #  AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
052847,000207: 
052848,000208:                                                                                                  #  THE INPUTS ARE  1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD.  2) THE STAR2 VECTOR
052849,000209:                                                                                                  #  REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6.  3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
052850,000210:                                                                                                  #  AT LOCATION 6 OF THE VAC AREA.  4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
052851,000211:                                                                                                  #  THE VAC AREA.
052852,000212: 
052853,000213:                                                                                                  #  THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B.  THE THREE HALF-UNIT VECTORS ARE STORED
052854,000214:                                                                                                  #  AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
052855,000215: 
052856,000216: 23,3441           66370        AXISGEN            AXT,1    SSP                                   #  PUSHDOWN 00-30D, 34D-37D
052857,000217: 23,3442           02714                                    STARAD     +6                         
052858,000218: 23,3443           00051                                    S1                                    
052859,000219: 23,3444           02700                                    STARAD     -6                         
052860,000220: 
052861,000221: 23,3445           77601                           SETPD                                          
052862,000222: 23,3446           00001                                    0                                     
052863,000223: 23,3447           46773        AXISGEN1           VLOAD*   VXV*                                  #  06D   UA = S1
052864,000224: 23,3450           02723                                    STARAD     +12D,1                     #        STARAD +00D     UB = S1
052865,000225: 23,3451           02731                                    STARAD     +18D,1                     
052866,000226: 23,3452           77656                           UNIT                                           #  12D   VA = UNIT(S1 X S2)
052867,000227: 23,3453           06731                           STORE    STARAD     +18D,1                     #        STARAD +06D     VB = UNIT(S1 X S2)
052868,000228: 23,3454           77773                           VLOAD*                                         
052869,000229: 23,3455           02723                                    STARAD     +12D,1                     
052870,000230: 
052871,000231: 23,3456           76433                           VXV*     VSL1                                  
052872,000232: 23,3457           02731                                    STARAD     +18D,1                     #  18D   WA = UA X VA
052873,000233: 23,3460           06737                           STORE    STARAD     +24D,1                     #        STARAD +12D     WB = UB X VB
052874,000234: 
052875,000235: 23,3461           77700                           TIX,1                                          
052876,000236: 23,3462           47447                                    AXISGEN1                              
052877,000237: 
052878,000238: 23,3463           66160                           AXC,1    SXA,1                                 
052879,000239: 23,3464           00006                                    6                                     
052880,000240: 23,3465           00036                                    30D                                   
052881,000241: 
052882,000242: 23,3466           66370                           AXT,1    SSP                                   
052883,000243: 23,3467           00022                                    18D                                   
052884,000244: 23,3470           00051                                    S1                                    
052885,000245: 23,3471           00006                                    6                                     
052886,000246: 
052887,000247: 23,3472           66374                           AXT,2    SSP                                   
052888,000248: 23,3473           00006                                    6                                     
052889,000249: 23,3474           00052                                    S2                                    
052890,000250: 23,3475           00002                                    2                                     
052891,000251: 
052892,000252: 23,3476           76720        AXISGEN2           XCHX,1   VLOAD*                                
052893,000253: 23,3477           00036                                    30D                                   #  X1=-6 X2=+6   X1=-6 X2=+4     X1=-6 X2=+2
052894,000254: 23,3500           00001                                    0,1                                   
052895,000255: 

Page 1256

052897,000257: 23,3501           62757                           VXSC*    PDVL*                                 #  J=(UA)(UB1)   J=(UA)(UB2)     J=(UA)(UB3)
052898,000258: 23,3502           75062                                    STARAD     +6,2                       
052899,000259: 23,3503           00007                                    6,1                                   
052900,000260: 23,3504           77757                           VXSC*                                          
052901,000261: 23,3505           75054                                    STARAD     +12D,2                     
052902,000262: 23,3506           30031                           STOVL*   24D                                   #  K=(VA)(VB1)   J=(VA)(VB2)     J=(VA)(VB3)
052903,000263: 23,3507           00015                                    12D,1                                 
052904,000264: 
052905,000265: 23,3510           53357                           VXSC*    VAD                                   
052906,000266: 23,3511           75046                                    STARAD     +18D,2                     #  L=(WA)(WB1)   J=(WA)(WB2)     J=(WA)(WB3)
052907,000267: 23,3512           76455                           VAD      VSL1                                  
052908,000268: 23,3513           00031                                    24D                                   
052909,000269: 23,3514           53520                           XCHX,1   UNIT                                  
052910,000270: 23,3515           00036                                    30D                                   
052911,000271: 23,3516           06707                           STORE    XDC        +18D,1                     #  XDC = L+J+K   YDC = L+J+K     ZDC = L+J+K
052912,000272: 
052913,000273: 23,3517           77700                           TIX,1                                          
052914,000274: 23,3520           47521                                    AXISGEN3                              
052915,000275: 
052916,000276: 23,3521           77704        AXISGEN3           TIX,2                                          
052917,000277: 23,3522           47476                                    AXISGEN2                              
052918,000278: 
052919,000279: 23,3523           77775                           VLOAD                                          
052920,000280: 23,3524           02665                                    XDC                                   
052921,000281: 23,3525           26707                           STOVL    STARAD                                
052922,000282: 23,3526           02673                                    YDC                                   
052923,000283: 23,3527           26715                           STOVL    STARAD     +6                         
052924,000284: 23,3530           02701                                    ZDC                                   
052925,000285: 23,3531           02723                           STORE    STARAD     +12D                       
052926,000286: 
052927,000287: 23,3532           77616                           RVQ                                            
052928,000288: 

Page 1257

052930,000290: 23,3533           05520 26075  QTSN45             2DEC     .1768                                 
052931,000291: 
052932,000292: 23,3535           05252 25253  .166...            2DEC     .1666666667                            
052933,000293: 

Page 1258 Empty page

052936,000296: 

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