Source Code

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

The reconstruction began with source code of Zerlina 56, Luminary 210, and Luminary 131, previously transcribed from digitized copies of those programs. The code was created by combining the three, using Zerlina 56 as a base, since it was based off of Luminary 183. The differences between the three were carefully merged using the Luminary memos as a guide, with all changes made after Luminary 178 being backed out. 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 178 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.

052982,000002:                                                                                                  ## Copyright:   Public domain.
052983,000003:                                                                                                  ## Filename:    INFLIGHT_ALIGNMENT_ROUTINES.agc
052984,000004:                                                                                                  ## Purpose:     A section of Luminary revision 178.
052985,000005:                                                                                                  ##              It is part of the reconstructed source code for the final
052986,000006:                                                                                                  ##              release of the flight software for the Lunar Module's
052987,000007:                                                                                                  ##              (LM) Apollo Guidance Computer (AGC) for Apollo 14. The
052988,000008:                                                                                                  ##              code has been recreated from copies of Zerlina 56, Luminary
052989,000009:                                                                                                  ##              210, and Luminary 131, as well as many Luminary memos.
052990,000010:                                                                                                  ##              It has been adapted such that the resulting bugger words
052991,000011:                                                                                                  ##              exactly match those specified for Luminary 178 in NASA
052992,000012:                                                                                                  ##              drawing 2021152N, which gives relatively high confidence
052993,000013:                                                                                                  ##              that the reconstruction is correct.
052994,000014:                                                                                                  ## Reference:   pp. 1238-1247
052995,000015:                                                                                                  ## Assembler:   yaYUL
052996,000016:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
052997,000017:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
052998,000018:                                                                                                  ## Mod history: 2019-08-14 MAS  Created from Zerlina 56.
052999,000019: 

Page 1238

053001,000021: 22,3772                                           BANK     22                                    
053002,000022: 23,2000                                           SETLOC   INFLIGHT                              
053003,000023: 23,2000                                           BANK                                           
053004,000024: 
053005,000025: 23,3215  E5,1642                                  EBANK=   XSM                                   
053006,000026: 
053007,000027:                                                                                                  #  CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
053008,000028: 
053009,000029:                                                                                                  #  THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES. THE THREE
053010,000030:                                                                                                  #  HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
053011,000031: 
053012,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,
053013,000033:                                                                                                  #  MGC, AND OGC RESPECTIVELY.
053014,000034: 
053015,000035: 23,3215                                           COUNT*   $$/INFLT                              
053016,000036: 23,3215           71220        CALCGTA            ITA      DLOAD                                 #  PUSHDOWN  00-03,16D-27D,34D-37D
053017,000037: 23,3216           00051                                    S2                                    #  XDC = (XD1 XD2 XD3)
053018,000038: 23,3217           02665                                    XDC                                   #  YDC = (YD1 YD2 YD3)
053019,000039: 23,3220           65325                           PDDL     PDDL                                  #  ZDC = (ZD1 ZD2 ZD3)
053020,000040: 23,3221           06470                                    HI6ZEROS                              
053021,000041: 23,3222           02671                                    XDC        +4                         
053022,000042: 23,3223           55476                           DCOMP    VDEF                                  
053023,000043: 23,3224           77656                           UNIT                                           
053024,000044: 23,3225           14027                           STODL    ZPRIME                                #  ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
053025,000045: 23,3226           00027                                    ZPRIME                                
053026,000046: 
053027,000047: 23,3227           77742                           SR1                                            
053028,000048: 23,3230           14023                           STODL    SINTH                                 #  SIN(IGC) = ZP1
053029,000049: 23,3231           00033                                    ZPRIME     +4                         
053030,000050: 23,3232           77742                           SR1                                            
053031,000051: 23,3233           34021                           STCALL   COSTH                                 #  COS(IGC) = ZP3
053032,000052: 23,3234           47266                                    ARCTRIG                               
053033,000053: 
053034,000054: 23,3235           16742                           STODL    IGC                                   #  Y GYRO TORQUING ANGLE   FRACTION OF REV.
053035,000055: 23,3236           02667                                    XDC        +2                         
053036,000056: 23,3237           77742                           SR1                                            
053037,000057: 23,3240           14023                           STODL    SINTH                                 #  SIN(MGC) = XD2
053038,000058: 23,3241           00027                                    ZPRIME                                
053039,000059: 
053040,000060: 23,3242           65205                           DMP      PDDL                                  
053041,000061: 23,3243           02671                                    XDC        +4                         #  PD00 = (ZP1)(XD3)
053042,000062: 23,3244           00033                                    ZPRIME     +4                         
053043,000063: 
053044,000064: 23,3245           45205                           DMP      DSU                                   
053045,000065: 23,3246           02665                                    XDC                                   #  MPAC = (ZP3)(XD1)
053046,000066: 23,3247           77626                           STADR                                          
053047,000067: 23,3250           43756                           STCALL   COSTH                                 #  COS(MGC) = MPAC - PD00
053048,000068: 23,3251           47266                                    ARCTRIG                               

Page 1239

053050,000070: 23,3252           26744                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
053051,000071: 23,3253           00027                                    ZPRIME                                
053052,000072: 23,3254           77641                           DOT                                            
053053,000073: 23,3255           02701                                    ZDC                                   
053054,000074: 23,3256           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
053055,000075: 23,3257           00027                                    ZPRIME                                
053056,000076: 23,3260           77641                           DOT                                            
053057,000077: 23,3261           02673                                    YDC                                   
053058,000078: 23,3262           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
053059,000079: 23,3263           47266                                    ARCTRIG                               
053060,000080: 
053061,000081: 23,3264           36740                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
053062,000082: 23,3265           00051                                    S2                                    
053063,000083: 

Page 1240

053065,000085:                                                                                                  #  ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
053066,000086: 
053067,000087:                                                                                                  #  THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
053068,000088: 
053069,000089:                                                                                                  #  THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA.  THE OUTPUT IS ALSO
053070,000090:                                                                                                  #  AVAILABLE AT MPAC.
053071,000091: 
053072,000092: 23,3266           51545        ARCTRIG            DLOAD    ABS                                   #  PUSHDOWN  16D-21D
053073,000093: 23,3267           00023                                    SINTH                                 
053074,000094: 23,3270           50025                           DSU      BMN                                   
053075,000095: 23,3271           07502                                    QTSN45                                #  ABS(SIN/4) - SIN(45)/4
053076,000096: 23,3272           47301                                    TRIG1                                 #  IF (-45,45) OR (135,-135)
053077,000097: 
053078,000098: 23,3273           72545                           DLOAD    SL1                                   #  (45,135) OR (-135,-45)
053079,000099: 23,3274           00021                                    COSTH                                 
053080,000100: 23,3275           75326                           ACOS     SIGN                                  
053081,000101: 23,3276           00023                                    SINTH                                 
053082,000102: 23,3277           00025                           STORE    THETA                                 #  X = ARCCOS(COS) WITH SIGN(SIN)
053083,000103: 23,3300           77616                           RVQ                                            
053084,000104: 
053085,000105: 23,3301           72545        TRIG1              DLOAD    SL1                                   #  (-45,45) OR (135,-135)
053086,000106: 23,3302           00023                                    SINTH                                 
053087,000107: 23,3303           77736                           ASIN                                           
053088,000108: 23,3304           14025                           STODL    THETA                                 #  X = ARCSIN(SIN) WITH SIGN(SIN)
053089,000109: 23,3305           00021                                    COSTH                                 
053090,000110: 23,3306           77640                           BMN                                            
053091,000111: 23,3307           47312                                    TRIG2                                 #  IF (135,-135)
053092,000112: 
053093,000113: 23,3310           43545                           DLOAD    RVQ                                   
053094,000114: 23,3311           00025                                    THETA                                 #  X = ARCSIN(SIN)   (-45,45)
053095,000115: 
053096,000116: 23,3312           75345        TRIG2              DLOAD    SIGN                                  #  (135,-135)
053097,000117: 23,3313           06466                                    HIDPHALF                              
053098,000118: 23,3314           00023                                    SINTH                                 
053099,000119: 23,3315           77625                           DSU                                            
053100,000120: 23,3316           00025                                    THETA                                 
053101,000121: 23,3317           00025                           STORE    THETA                                 #  X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
053102,000122: 23,3320           77616                           RVQ                                            #                   (+) - (+) OR (-) - (-)
053103,000123: 

Page 1241

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

Page 1242

053110,000130:                                                                                                  #  CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
053111,000131: 
053112,000132:                                                                                                  #  THE INPUTS ARE  1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM. THE THREE HALF-UNIT
053113,000133:                                                                                                  #  VECTORS ARE STORED AT XNB,YNB, AND ZNB.  2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
053114,000134:                                                                                                  #  COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
053115,000135: 
053116,000136:                                                                                                  #  THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
053117,000137: 
053118,000138: 23,3321           77601        CALCGA             SETPD                                          #  PUSHDOWN  00-05, 16D-21D, 34D-37D
053119,000139: 23,3322           00001                                    0                                     
053120,000140: 23,3323           47375                           VLOAD    VXV                                   
053121,000141: 23,3324           02665                                    XNB                                   #  XNB = OGA (OUTER GIMBAL AXIS)
053122,000142: 23,3325           02651                                    YSM                                   #  YSM = IGA (INNER GIMBAL AXIS)
053123,000143: 23,3326           41456                           UNIT     PUSH                                  #  PD0 = UNIT(OGA X IGA) = MGA
053124,000144: 
053125,000145: 23,3327           44041                           DOT      ITA                                   
053126,000146: 23,3330           02701                                    ZNB                                   
053127,000147: 23,3331           00051                                    S2                                    
053128,000148: 23,3332           24021                           STOVL    COSTH                                 #  COS(OG) = MGA . ZNB
053129,000149: 23,3333           00001                                    0                                     
053130,000150: 23,3334           77641                           DOT                                            
053131,000151: 23,3335           02673                                    YNB                                   
053132,000152: 23,3336           34023                           STCALL   SINTH                                 #  SIN(OG) = MGA . YNB
053133,000153: 23,3337           47266                                    ARCTRIG                               
053134,000154: 23,3340           26740                           STOVL    OGC                                   
053135,000155: 23,3341           00001                                    0                                     
053136,000156: 
053137,000157: 23,3342           50235                           VXV      DOT                                   #  PROVISION FOR MG ANGLE OF 90 DEGREES
053138,000158: 23,3343           02665                                    XNB                                   
053139,000159: 23,3344           02651                                    YSM                                   
053140,000160: 23,3345           77752                           SL1                                            
053141,000161: 23,3346           24021                           STOVL    COSTH                                 #  COS(MG) = IGA . (MGA X OGA)
053142,000162: 23,3347           02651                                    YSM                                   
053143,000163: 23,3350           77641                           DOT                                            
053144,000164: 23,3351           02665                                    XNB                                   
053145,000165: 23,3352           34023                           STCALL   SINTH                                 #  SIN(MG) = IGA . OGA
053146,000166: 23,3353           47266                                    ARCTRIG                               
053147,000167: 23,3354           02744                           STORE    MGC                                   
053148,000168: 
053149,000169: 23,3355           45246                           ABS      DSU                                   
053150,000170: 23,3356           07504                                    .166...                               
053151,000171: 23,3357           77644                           BPL                                            
053152,000172: 23,3360           47377                                    GIMLOCK1                              #  IF ANGLE GREATER THAN 60 DEGREES
053153,000173: 
053154,000174: 23,3361           50375        CALCGA1            VLOAD    DOT                                   
053155,000175: 23,3362           02657                                    ZSM                                   
053156,000176: 23,3363           00001                                    0                                     
053157,000177: 23,3364           24021                           STOVL    COSTH                                 #  COS(IG) = ZSM . MGA
053158,000178: 23,3365           02643                                    XSM                                   

Page 1243

053160,000180: 23,3366           45441                           DOT      STADR                                 
053161,000181: 23,3367           43754                           STCALL   SINTH                                 #  SIN(IG) = XSM . MGA
053162,000182: 23,3370           47266                                    ARCTRIG                               
053163,000183: 
053164,000184: 23,3371           26742                           STOVL    IGC                                   
053165,000185: 23,3372           02740                                    OGC                                   
053166,000186: 23,3373           77634                           RTB                                            
053167,000187: 23,3374           21621                                    V1STO2S                               
053168,000188: 23,3375           34322                           STCALL   THETAD                                
053169,000189: 23,3376           00051                                    S2                                    
053170,000190: 
053171,000191: 23,3377           77776        GIMLOCK1           EXIT                                           
053172,000192: 23,3400           05600                           TC       ALARM                                 
053173,000193: 23,3401           00401                           OCT      00401                                 
053174,000194: 23,3402           05515                           TC       UPFLAG                                #  GIMBAL LOCK HAS OCCURED
053175,000195: 23,3403           00056                           ADRES    GLOKFAIL                              
053176,000196: 
053177,000197: 23,3404           06042                           TC       INTPRET                               
053178,000198: 23,3405           77650                           GOTO                                           
053179,000199: 23,3406           47361                                    CALCGA1                               
053180,000200: 

Page 1244

053182,000202:                                                                                                  #  AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
053183,000203: 
053184,000204:                                                                                                  #  THE INPUTS ARE  1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD.  2) THE STAR2 VECTOR
053185,000205:                                                                                                  #  REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6.  3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
053186,000206:                                                                                                  #  AT LOCATION 6 OF THE VAC AREA.  4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
053187,000207:                                                                                                  #  THE VAC AREA.
053188,000208: 
053189,000209:                                                                                                  #  THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B. THE THREE HALF-UNIT VECTORS ARE STORED
053190,000210:                                                                                                  #  AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
053191,000211: 
053192,000212: 23,3407           66370        AXISGEN            AXT,1    SSP                                   #  PUSHDOWN  00-30D,34D-37D
053193,000213: 23,3410           02714                                    STARAD     +6                         
053194,000214: 23,3411           00051                                    S1                                    
053195,000215: 23,3412           02700                                    STARAD     -6                         
053196,000216: 
053197,000217: 23,3413           77601                           SETPD                                          
053198,000218: 23,3414           00001                                    0                                     
053199,000219: 23,3415           46773        AXISGEN1           VLOAD*   VXV*                                  #  06D   UA = S1
053200,000220: 23,3416           02723                                    STARAD     +12D,1                     #         STARAD +00D   UB = S1
053201,000221: 23,3417           02731                                    STARAD     +18D,1                     
053202,000222: 23,3420           77656                           UNIT                                           #  12D   VA = UNIT(S1 X S2)
053203,000223: 23,3421           06731                           STORE    STARAD     +18D,1                     #         STARAD +06D   VB = UNIT(S1 X S2)
053204,000224: 23,3422           77773                           VLOAD*                                         
053205,000225: 23,3423           02723                                    STARAD     +12D,1                     
053206,000226: 
053207,000227: 23,3424           76433                           VXV*     VSL1                                  
053208,000228: 23,3425           02731                                    STARAD     +18D,1                     #  18D   WA = UA X VA
053209,000229: 23,3426           06737                           STORE    STARAD     +24D,1                     #         STARAD +12D   WB = UB X VB
053210,000230: 
053211,000231: 23,3427           77700                           TIX,1                                          
053212,000232: 23,3430           47415                                    AXISGEN1                              
053213,000233: 
053214,000234: 23,3431           66160                           AXC,1    SXA,1                                 
053215,000235: 23,3432           00006                                    6                                     
053216,000236: 23,3433           00036                                    30D                                   
053217,000237: 
053218,000238: 23,3434           66370                           AXT,1    SSP                                   
053219,000239: 23,3435           00022                                    18D                                   
053220,000240: 23,3436           00051                                    S1                                    
053221,000241: 23,3437           00006                                    6                                     
053222,000242: 
053223,000243: 23,3440           66374                           AXT,2    SSP                                   
053224,000244: 23,3441           00006                                    6                                     
053225,000245: 23,3442           00052                                    S2                                    
053226,000246: 23,3443           00002                                    2                                     
053227,000247: 
053228,000248: 23,3444           76720        AXISGEN2           XCHX,1   VLOAD*                                
053229,000249: 23,3445           00036                                    30D                                   #  X1=-6 X2=+6   X1=-6 X2=+4   X1=-6 X2=+2
053230,000250: 23,3446           00001                                    0,1                                   
053231,000251: 

Page 1245

053233,000253: 23,3447           62757                           VXSC*    PDVL*                                 #  J=(UA)(UB1)   J=(UA)(UB2)   J=(UA)(UB3)
053234,000254: 23,3450           75062                                    STARAD     +6,2                       
053235,000255: 23,3451           00007                                    6,1                                   
053236,000256: 23,3452           77757                           VXSC*                                          
053237,000257: 23,3453           75054                                    STARAD     +12D,2                     
053238,000258: 23,3454           30031                           STOVL*   24D                                   #  K=(VA)(VB1)   J=(VA)(VB2)   J=(VA)(VB3)
053239,000259: 23,3455           00015                                    12D,1                                 
053240,000260: 
053241,000261: 23,3456           53357                           VXSC*    VAD                                   
053242,000262: 23,3457           75046                                    STARAD     +18D,2                     #  L=(WA)(WB1)   J=(WA)(WB2)   J=(WA)(WB3)
053243,000263: 23,3460           76455                           VAD      VSL1                                  
053244,000264: 23,3461           00031                                    24D                                   
053245,000265: 23,3462           53520                           XCHX,1   UNIT                                  
053246,000266: 23,3463           00036                                    30D                                   
053247,000267: 23,3464           06707                           STORE    XDC        +18D,1                     #  XDC = L+J+K   YDC = L+J+K   ZDC = L+J+K
053248,000268: 
053249,000269: 23,3465           77700                           TIX,1                                          
053250,000270: 23,3466           47467                                    AXISGEN3                              
053251,000271: 
053252,000272: 23,3467           77704        AXISGEN3           TIX,2                                          
053253,000273: 23,3470           47444                                    AXISGEN2                              
053254,000274: 
053255,000275: 23,3471           77775                           VLOAD                                          
053256,000276: 23,3472           02665                                    XDC                                   
053257,000277: 23,3473           26707                           STOVL    STARAD                                
053258,000278: 23,3474           02673                                    YDC                                   
053259,000279: 23,3475           26715                           STOVL    STARAD     +6                         
053260,000280: 23,3476           02701                                    ZDC                                   
053261,000281: 23,3477           02723                           STORE    STARAD     +12D                       
053262,000282: 
053263,000283: 23,3500           77616                           RVQ                                            
053264,000284: 

Page 1246

053266,000286: 23,3501           05520 26075  QTSN45             2DEC     .1768                                 
053267,000287: 23,3503           05252 25253  .166...            2DEC     .1666666667                            
053268,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