Source Code

These source-code files are part of a reconstructed copy of Luminary 163, the first (unflown) release of the Apollo 14 Lunar Module (LM) Apollo Guidance Computer (AGC) software.

The reconstruction began with reconstructed source code for Luminary 173. Changes between revision 163 and 173 were backed out, as described by Luminary memos 157 and 158. The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021152N. Note that page numbers in the reconstructed code match those for the baseline log section mentioned in each file's changelog; the page numbers for a real Luminary 163 listing would be different.

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.

052820,000002:                                                                                                  ## Copyright:   Public domain.
052821,000003:                                                                                                  ## Filename:    INFLIGHT_ALIGNMENT_ROUTINES.agc
052822,000004:                                                                                                  ## Purpose:     A section of Luminary revision 163.
052823,000005:                                                                                                  ##              It is part of the reconstructed source code for the first
052824,000006:                                                                                                  ##              (unflown) release of the flight software for the Lunar
052825,000007:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 14.
052826,000008:                                                                                                  ##              The code has been recreated from a reconstructed copy of
052827,000009:                                                                                                  ##              Luminary 173, as well as Luminary memos 157 amd 158.
052828,000010:                                                                                                  ##              It has been adapted such that the resulting bugger words
052829,000011:                                                                                                  ##              exactly match those specified for Luminary 163 in NASA
052830,000012:                                                                                                  ##              drawing 2021152N, which gives relatively high confidence
052831,000013:                                                                                                  ##              that the reconstruction is correct.
052832,000014:                                                                                                  ## Reference:   pp. 1238-1247
052833,000015:                                                                                                  ## Assembler:   yaYUL
052834,000016:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
052835,000017:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
052836,000018:                                                                                                  ## Mod history: 2019-08-21 MAS  Created from Luminary 173.
052837,000019: 

Page 1238

052839,000021: 22,3772                                           BANK     22                                    
052840,000022: 23,2000                                           SETLOC   INFLIGHT                              
052841,000023: 23,2000                                           BANK                                           
052842,000024: 
052843,000025: 23,3245  E5,1642                                  EBANK=   XSM                                   
052844,000026: 
052845,000027:                                                                                                  #  CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
052846,000028: 
052847,000029:                                                                                                  #  THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES. THE THREE
052848,000030:                                                                                                  #  HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
052849,000031: 
052850,000032:                                                                                                  #  THE OUTPUTS ARE THE THREE GYRO TORQUING ANGLES TO BE APPLIED TO THE Y, Z, AND X GYROS AND ARE STORED DP AT IGC,
052851,000033:                                                                                                  #  MGC, AND OGC RESPECTIVELY.
052852,000034: 
052853,000035: 23,3245                                           COUNT*   $$/INFLT                              
052854,000036: 23,3245           71220        CALCGTA            ITA      DLOAD                                 #  PUSHDOWN  00-03,16D-27D,34D-37D
052855,000037: 23,3246           00051                                    S2                                    #  XDC = (XD1 XD2 XD3)
052856,000038: 23,3247           02665                                    XDC                                   #  YDC = (YD1 YD2 YD3)
052857,000039: 23,3250           65325                           PDDL     PDDL                                  #  ZDC = (ZD1 ZD2 ZD3)
052858,000040: 23,3251           06520                                    HI6ZEROS                              
052859,000041: 23,3252           02671                                    XDC        +4                         
052860,000042: 23,3253           55476                           DCOMP    VDEF                                  
052861,000043: 23,3254           77656                           UNIT                                           
052862,000044: 23,3255           14027                           STODL    ZPRIME                                #  ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
052863,000045: 23,3256           00027                                    ZPRIME                                
052864,000046: 
052865,000047: 23,3257           77742                           SR1                                            
052866,000048: 23,3260           14023                           STODL    SINTH                                 #  SIN(IGC) = ZP1
052867,000049: 23,3261           00033                                    ZPRIME     +4                         
052868,000050: 23,3262           77742                           SR1                                            
052869,000051: 23,3263           34021                           STCALL   COSTH                                 #  COS(IGC) = ZP3
052870,000052: 23,3264           47316                                    ARCTRIG                               
052871,000053: 
052872,000054: 23,3265           16742                           STODL    IGC                                   #  Y GYRO TORQUING ANGLE   FRACTION OF REV.
052873,000055: 23,3266           02667                                    XDC        +2                         
052874,000056: 23,3267           77742                           SR1                                            
052875,000057: 23,3270           14023                           STODL    SINTH                                 #  SIN(MGC) = XD2
052876,000058: 23,3271           00027                                    ZPRIME                                
052877,000059: 
052878,000060: 23,3272           65205                           DMP      PDDL                                  
052879,000061: 23,3273           02671                                    XDC        +4                         #  PD00 = (ZP1)(XD3)
052880,000062: 23,3274           00033                                    ZPRIME     +4                         
052881,000063: 
052882,000064: 23,3275           45205                           DMP      DSU                                   
052883,000065: 23,3276           02665                                    XDC                                   #  MPAC = (ZP3)(XD1)
052884,000066: 23,3277           77626                           STADR                                          
052885,000067: 23,3300           43756                           STCALL   COSTH                                 #  COS(MGC) = MPAC - PD00
052886,000068: 23,3301           47316                                    ARCTRIG                               

Page 1239

052888,000070: 23,3302           26744                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
052889,000071: 23,3303           00027                                    ZPRIME                                
052890,000072: 23,3304           77641                           DOT                                            
052891,000073: 23,3305           02701                                    ZDC                                   
052892,000074: 23,3306           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
052893,000075: 23,3307           00027                                    ZPRIME                                
052894,000076: 23,3310           77641                           DOT                                            
052895,000077: 23,3311           02673                                    YDC                                   
052896,000078: 23,3312           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
052897,000079: 23,3313           47316                                    ARCTRIG                               
052898,000080: 
052899,000081: 23,3314           36740                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
052900,000082: 23,3315           00051                                    S2                                    
052901,000083: 

Page 1240

052903,000085:                                                                                                  #  ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
052904,000086: 
052905,000087:                                                                                                  #  THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
052906,000088: 
052907,000089:                                                                                                  #  THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA.  THE OUTPUT IS ALSO
052908,000090:                                                                                                  #  AVAILABLE AT MPAC.
052909,000091: 
052910,000092: 23,3316           51545        ARCTRIG            DLOAD    ABS                                   #  PUSHDOWN  16D-21D
052911,000093: 23,3317           00023                                    SINTH                                 
052912,000094: 23,3320           50025                           DSU      BMN                                   
052913,000095: 23,3321           07532                                    QTSN45                                #  ABS(SIN/4) - SIN(45)/4
052914,000096: 23,3322           47331                                    TRIG1                                 #  IF (-45,45) OR (135,-135)
052915,000097: 
052916,000098: 23,3323           72545                           DLOAD    SL1                                   #  (45,135) OR (-135,-45)
052917,000099: 23,3324           00021                                    COSTH                                 
052918,000100: 23,3325           75326                           ACOS     SIGN                                  
052919,000101: 23,3326           00023                                    SINTH                                 
052920,000102: 23,3327           00025                           STORE    THETA                                 #  X = ARCCOS(COS) WITH SIGN(SIN)
052921,000103: 23,3330           77616                           RVQ                                            
052922,000104: 
052923,000105: 23,3331           72545        TRIG1              DLOAD    SL1                                   #  (-45,45) OR (135,-135)
052924,000106: 23,3332           00023                                    SINTH                                 
052925,000107: 23,3333           77736                           ASIN                                           
052926,000108: 23,3334           14025                           STODL    THETA                                 #  X = ARCSIN(SIN) WITH SIGN(SIN)
052927,000109: 23,3335           00021                                    COSTH                                 
052928,000110: 23,3336           77640                           BMN                                            
052929,000111: 23,3337           47342                                    TRIG2                                 #  IF (135,-135)
052930,000112: 
052931,000113: 23,3340           43545                           DLOAD    RVQ                                   
052932,000114: 23,3341           00025                                    THETA                                 #  X = ARCSIN(SIN)   (-45,45)
052933,000115: 
052934,000116: 23,3342           75345        TRIG2              DLOAD    SIGN                                  #  (135,-135)
052935,000117: 23,3343           06516                                    HIDPHALF                              
052936,000118: 23,3344           00023                                    SINTH                                 
052937,000119: 23,3345           77625                           DSU                                            
052938,000120: 23,3346           00025                                    THETA                                 
052939,000121: 23,3347           00025                           STORE    THETA                                 #  X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
052940,000122: 23,3350           77616                           RVQ                                            #                   (+) - (+) OR (-) - (-)
052941,000123: 

Page 1241

052943,000125:                                                                                                  #      SMNB, NBSM, AND AXISROT, WHICH USED TO APPEAR HERE, HAVE BEEN
052944,000126:                                                                                                  #  COMBINED IN A ROUTINE CALLED AX*SR*T, WHICH APPEARS AMONG THE POWERED
052945,000127:                                                                                                  #  FLIGHT SUBROUTINES.
052946,000128: 

Page 1242

052948,000130:                                                                                                  #  CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
052949,000131: 
052950,000132:                                                                                                  #  THE INPUTS ARE  1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM. THE THREE HALF-UNIT
052951,000133:                                                                                                  #  VECTORS ARE STORED AT XNB,YNB, AND ZNB.  2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
052952,000134:                                                                                                  #  COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
052953,000135: 
052954,000136:                                                                                                  #  THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
052955,000137: 
052956,000138: 23,3351           77601        CALCGA             SETPD                                          #  PUSHDOWN  00-05, 16D-21D, 34D-37D
052957,000139: 23,3352           00001                                    0                                     
052958,000140: 23,3353           47375                           VLOAD    VXV                                   
052959,000141: 23,3354           02665                                    XNB                                   #  XNB = OGA (OUTER GIMBAL AXIS)
052960,000142: 23,3355           02651                                    YSM                                   #  YSM = IGA (INNER GIMBAL AXIS)
052961,000143: 23,3356           41456                           UNIT     PUSH                                  #  PD0 = UNIT(OGA X IGA) = MGA
052962,000144: 
052963,000145: 23,3357           44041                           DOT      ITA                                   
052964,000146: 23,3360           02701                                    ZNB                                   
052965,000147: 23,3361           00051                                    S2                                    
052966,000148: 23,3362           24021                           STOVL    COSTH                                 #  COS(OG) = MGA . ZNB
052967,000149: 23,3363           00001                                    0                                     
052968,000150: 23,3364           77641                           DOT                                            
052969,000151: 23,3365           02673                                    YNB                                   
052970,000152: 23,3366           34023                           STCALL   SINTH                                 #  SIN(OG) = MGA . YNB
052971,000153: 23,3367           47316                                    ARCTRIG                               
052972,000154: 23,3370           26740                           STOVL    OGC                                   
052973,000155: 23,3371           00001                                    0                                     
052974,000156: 
052975,000157: 23,3372           50235                           VXV      DOT                                   #  PROVISION FOR MG ANGLE OF 90 DEGREES
052976,000158: 23,3373           02665                                    XNB                                   
052977,000159: 23,3374           02651                                    YSM                                   
052978,000160: 23,3375           77752                           SL1                                            
052979,000161: 23,3376           24021                           STOVL    COSTH                                 #  COS(MG) = IGA . (MGA X OGA)
052980,000162: 23,3377           02651                                    YSM                                   
052981,000163: 23,3400           77641                           DOT                                            
052982,000164: 23,3401           02665                                    XNB                                   
052983,000165: 23,3402           34023                           STCALL   SINTH                                 #  SIN(MG) = IGA . OGA
052984,000166: 23,3403           47316                                    ARCTRIG                               
052985,000167: 23,3404           02744                           STORE    MGC                                   
052986,000168: 
052987,000169: 23,3405           45246                           ABS      DSU                                   
052988,000170: 23,3406           07534                                    .166...                               
052989,000171: 23,3407           77644                           BPL                                            
052990,000172: 23,3410           47427                                    GIMLOCK1                              #  IF ANGLE GREATER THAN 60 DEGREES
052991,000173: 
052992,000174: 23,3411           50375        CALCGA1            VLOAD    DOT                                   
052993,000175: 23,3412           02657                                    ZSM                                   
052994,000176: 23,3413           00001                                    0                                     
052995,000177: 23,3414           24021                           STOVL    COSTH                                 #  COS(IG) = ZSM . MGA
052996,000178: 23,3415           02643                                    XSM                                   

Page 1243

052998,000180: 23,3416           45441                           DOT      STADR                                 
052999,000181: 23,3417           43754                           STCALL   SINTH                                 #  SIN(IG) = XSM . MGA
053000,000182: 23,3420           47316                                    ARCTRIG                               
053001,000183: 
053002,000184: 23,3421           26742                           STOVL    IGC                                   
053003,000185: 23,3422           02740                                    OGC                                   
053004,000186: 23,3423           77634                           RTB                                            
053005,000187: 23,3424           21621                                    V1STO2S                               
053006,000188: 23,3425           34322                           STCALL   THETAD                                
053007,000189: 23,3426           00051                                    S2                                    
053008,000190: 
053009,000191: 23,3427           77776        GIMLOCK1           EXIT                                           
053010,000192: 23,3430           05600                           TC       ALARM                                 
053011,000193: 23,3431           00401                           OCT      00401                                 
053012,000194: 23,3432           05515                           TC       UPFLAG                                #  GIMBAL LOCK HAS OCCURED
053013,000195: 23,3433           00056                           ADRES    GLOKFAIL                              
053014,000196: 
053015,000197: 23,3434           06042                           TC       INTPRET                               
053016,000198: 23,3435           77650                           GOTO                                           
053017,000199: 23,3436           47411                                    CALCGA1                               
053018,000200: 

Page 1244

053020,000202:                                                                                                  #  AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
053021,000203: 
053022,000204:                                                                                                  #  THE INPUTS ARE  1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD.  2) THE STAR2 VECTOR
053023,000205:                                                                                                  #  REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6.  3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
053024,000206:                                                                                                  #  AT LOCATION 6 OF THE VAC AREA.  4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
053025,000207:                                                                                                  #  THE VAC AREA.
053026,000208: 
053027,000209:                                                                                                  #  THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B. THE THREE HALF-UNIT VECTORS ARE STORED
053028,000210:                                                                                                  #  AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
053029,000211: 
053030,000212: 23,3437           66370        AXISGEN            AXT,1    SSP                                   #  PUSHDOWN  00-30D,34D-37D
053031,000213: 23,3440           02714                                    STARAD     +6                         
053032,000214: 23,3441           00051                                    S1                                    
053033,000215: 23,3442           02700                                    STARAD     -6                         
053034,000216: 
053035,000217: 23,3443           77601                           SETPD                                          
053036,000218: 23,3444           00001                                    0                                     
053037,000219: 23,3445           46773        AXISGEN1           VLOAD*   VXV*                                  #  06D   UA = S1
053038,000220: 23,3446           02723                                    STARAD     +12D,1                     #         STARAD +00D   UB = S1
053039,000221: 23,3447           02731                                    STARAD     +18D,1                     
053040,000222: 23,3450           77656                           UNIT                                           #  12D   VA = UNIT(S1 X S2)
053041,000223: 23,3451           06731                           STORE    STARAD     +18D,1                     #         STARAD +06D   VB = UNIT(S1 X S2)
053042,000224: 23,3452           77773                           VLOAD*                                         
053043,000225: 23,3453           02723                                    STARAD     +12D,1                     
053044,000226: 
053045,000227: 23,3454           76433                           VXV*     VSL1                                  
053046,000228: 23,3455           02731                                    STARAD     +18D,1                     #  18D   WA = UA X VA
053047,000229: 23,3456           06737                           STORE    STARAD     +24D,1                     #         STARAD +12D   WB = UB X VB
053048,000230: 
053049,000231: 23,3457           77700                           TIX,1                                          
053050,000232: 23,3460           47445                                    AXISGEN1                              
053051,000233: 
053052,000234: 23,3461           66160                           AXC,1    SXA,1                                 
053053,000235: 23,3462           00006                                    6                                     
053054,000236: 23,3463           00036                                    30D                                   
053055,000237: 
053056,000238: 23,3464           66370                           AXT,1    SSP                                   
053057,000239: 23,3465           00022                                    18D                                   
053058,000240: 23,3466           00051                                    S1                                    
053059,000241: 23,3467           00006                                    6                                     
053060,000242: 
053061,000243: 23,3470           66374                           AXT,2    SSP                                   
053062,000244: 23,3471           00006                                    6                                     
053063,000245: 23,3472           00052                                    S2                                    
053064,000246: 23,3473           00002                                    2                                     
053065,000247: 
053066,000248: 23,3474           76720        AXISGEN2           XCHX,1   VLOAD*                                
053067,000249: 23,3475           00036                                    30D                                   #  X1=-6 X2=+6   X1=-6 X2=+4   X1=-6 X2=+2
053068,000250: 23,3476           00001                                    0,1                                   
053069,000251: 

Page 1245

053071,000253: 23,3477           62757                           VXSC*    PDVL*                                 #  J=(UA)(UB1)   J=(UA)(UB2)   J=(UA)(UB3)
053072,000254: 23,3500           75062                                    STARAD     +6,2                       
053073,000255: 23,3501           00007                                    6,1                                   
053074,000256: 23,3502           77757                           VXSC*                                          
053075,000257: 23,3503           75054                                    STARAD     +12D,2                     
053076,000258: 23,3504           30031                           STOVL*   24D                                   #  K=(VA)(VB1)   J=(VA)(VB2)   J=(VA)(VB3)
053077,000259: 23,3505           00015                                    12D,1                                 
053078,000260: 
053079,000261: 23,3506           53357                           VXSC*    VAD                                   
053080,000262: 23,3507           75046                                    STARAD     +18D,2                     #  L=(WA)(WB1)   J=(WA)(WB2)   J=(WA)(WB3)
053081,000263: 23,3510           76455                           VAD      VSL1                                  
053082,000264: 23,3511           00031                                    24D                                   
053083,000265: 23,3512           53520                           XCHX,1   UNIT                                  
053084,000266: 23,3513           00036                                    30D                                   
053085,000267: 23,3514           06707                           STORE    XDC        +18D,1                     #  XDC = L+J+K   YDC = L+J+K   ZDC = L+J+K
053086,000268: 
053087,000269: 23,3515           77700                           TIX,1                                          
053088,000270: 23,3516           47517                                    AXISGEN3                              
053089,000271: 
053090,000272: 23,3517           77704        AXISGEN3           TIX,2                                          
053091,000273: 23,3520           47474                                    AXISGEN2                              
053092,000274: 
053093,000275: 23,3521           77775                           VLOAD                                          
053094,000276: 23,3522           02665                                    XDC                                   
053095,000277: 23,3523           26707                           STOVL    STARAD                                
053096,000278: 23,3524           02673                                    YDC                                   
053097,000279: 23,3525           26715                           STOVL    STARAD     +6                         
053098,000280: 23,3526           02701                                    ZDC                                   
053099,000281: 23,3527           02723                           STORE    STARAD     +12D                       
053100,000282: 
053101,000283: 23,3530           77616                           RVQ                                            
053102,000284: 

Page 1246

053104,000286: 23,3531           05520 26075  QTSN45             2DEC     .1768                                 
053105,000287: 23,3533           05252 25253  .166...            2DEC     .1666666667                            
053106,000288: 

Page 1247 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