Source Code

These source-code files derive from a printout of Luminary 210 (Apollo 15-17 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Jim Lawton, and transcribed to source code by a team of volunteers. This colorized, syntax-highlighted form was created by assembling that transcribed source code. Note that the full page images are available on the Virtual AGC project page at archive.org, while reduced-size images are presented at the VirtualAGC project website. Report or fix any transcription errors at the Virtual AGC project code repository.

Notations on the program listing read, in part:

	GAP: ASSEMBLE REVISION 210 OF AGC PROGRAM LUMINARY 
	BY NASA 2021112-161 17:11 MAR. 19,1971
Note that the date is the date of the printout, not the date of the program revision.

053836,000002:                                                                                                  ## Copyright:   Public domain.
053837,000003:                                                                                                  ## Filename:    INFLIGHT_ALIGNMENT_ROUTINES.agc
053838,000004:                                                                                                  ## Purpose:     A section of Luminary revision 210.
053839,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
053840,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 15-17.
053841,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
053842,000008:                                                                                                  ##              that the code format has been changed to conform to the
053843,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
053844,000010:                                                                                                  ##              original YUL assembler.
053845,000011:                                                                                                  ## Reference:   pp. 1246-1255
053846,000012:                                                                                                  ## Assembler:   yaYUL
053847,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
053848,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
053849,000015:                                                                                                  ## Mod history: 2016-11-17 JL   Created from Luminary131 version.
053850,000016:                                                                                                  ##              2016-12-07 RRB  Updated for Luminary210.
053851,000017:                                                                                                  ##              2016-12-26 RSB  Comment-text proofed using ProoferComments
053852,000018:                                                                                                  ##                              and corrected errors found.
053853,000019:                                                                                                  ##              2017-03-17 RSB  Comment-text fixes identified in diff'ing
053854,000020:                                                                                                  ##                              Luminary 99 vs Comanche 55.
053855,000021: 

Page 1246

053857,000023: 22,3774                                           BANK     22                                    
053858,000024: 23,2000                                           SETLOC   INFLIGHT                              
053859,000025: 23,2000                                           BANK                                           
053860,000026: 
053861,000027: 23,3232  E5,1642                                  EBANK=   XSM                                   
053862,000028: 
053863,000029:                                                                                                  #  CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
053864,000030: 
053865,000031:                                                                                                  #  THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES.  THE THREE
053866,000032:                                                                                                  #  HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
053867,000033: 
053868,000034:                                                                                                  #  THE OUTPUTS ARE THE THREE GYRO TORQUING ANGLES TO BE APPLIED TO THE Y, Z, AND X GYROS AND ARE STORED DP AT IGC,
053869,000035:                                                                                                  #  MGC, AND OGC RESPECTIVELY.
053870,000036: 
053871,000037: 23,3232                                           COUNT*   $$/INFLT                              
053872,000038: 23,3232           71220        CALCGTA            ITA      DLOAD                                 #  PUSHDOWN 00-03, 16D-27D, 34D-37D
053873,000039: 23,3233           00051                                    S2                                    #  XDC = (XD1 XD2 XD3)
053874,000040: 23,3234           02665                                    XDC                                   #  YDC = (YD1 YD2 YD3)
053875,000041: 23,3235           65325                           PDDL     PDDL                                  #  ZDC = (ZD1 ZD2 ZD3)
053876,000042: 23,3236           06505                                    HI6ZEROS                              
053877,000043: 23,3237           02671                                    XDC        +4                         
053878,000044: 23,3240           55476                           DCOMP    VDEF                                  
053879,000045: 23,3241           77656                           UNIT                                           
053880,000046: 23,3242           14027                           STODL    ZPRIME                                #  ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
053881,000047: 23,3243           00027                                    ZPRIME                                
053882,000048: 
053883,000049: 23,3244           77742                           SR1                                            
053884,000050: 23,3245           14023                           STODL    SINTH                                 #  SIN(IGC) = ZP1
053885,000051: 23,3246           00033                                    ZPRIME     +4                         
053886,000052: 23,3247           77742                           SR1                                            
053887,000053: 23,3250           34021                           STCALL   COSTH                                 #  COS(IGC) = ZP3
053888,000054: 23,3251           47303                                    ARCTRIG                               
053889,000055: 
053890,000056: 23,3252           16742                           STODL    IGC                                   #  Y GYRO TORQUING ANGLE   FRACTION OF REV.
053891,000057: 23,3253           02667                                    XDC        +2                         
053892,000058: 23,3254           77742                           SR1                                            
053893,000059: 23,3255           14023                           STODL    SINTH                                 #  SIN(MGC) = XD2
053894,000060: 23,3256           00027                                    ZPRIME                                
053895,000061: 
053896,000062: 23,3257           65205                           DMP      PDDL                                  
053897,000063: 23,3260           02671                                    XDC        +4                         #  PD00 = (ZP1)(XD3)
053898,000064: 23,3261           00033                                    ZPRIME     +4                         
053899,000065: 
053900,000066: 23,3262           45205                           DMP      DSU                                   
053901,000067: 23,3263           02665                                    XDC                                   #  MPAC = (ZP3)(XD1)
053902,000068: 23,3264           77626                           STADR                                          
053903,000069: 23,3265           43756                           STCALL   COSTH                                 #  COS(MGC) = MPAC - PD00
053904,000070: 23,3266           47303                                    ARCTRIG                               

Page 1247

053906,000072: 23,3267           26744                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
053907,000073: 23,3270           00027                                    ZPRIME                                
053908,000074: 23,3271           77641                           DOT                                            
053909,000075: 23,3272           02701                                    ZDC                                   
053910,000076: 23,3273           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
053911,000077: 23,3274           00027                                    ZPRIME                                
053912,000078: 23,3275           77641                           DOT                                            
053913,000079: 23,3276           02673                                    YDC                                   
053914,000080: 23,3277           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
053915,000081: 23,3300           47303                                    ARCTRIG                               
053916,000082: 
053917,000083: 23,3301           36740                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
053918,000084: 23,3302           00051                                    S2                                    
053919,000085: 

Page 1248

053921,000087:                                                                                                  #  ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
053922,000088: 
053923,000089:                                                                                                  #  THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
053924,000090: 
053925,000091:                                                                                                  #  THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA.  THE OUTPUT IS ALSO
053926,000092:                                                                                                  #  AVAILABLE AT MPAC.
053927,000093: 
053928,000094: 23,3303           51545        ARCTRIG            DLOAD    ABS                                   #  PUSHDOWN  16D-21D
053929,000095: 23,3304           00023                                    SINTH                                 
053930,000096: 23,3305           50025                           DSU      BMN                                   
053931,000097: 23,3306           07517                                    QTSN45                                #  ABS(SIN/4) - SIN(45)/4
053932,000098: 23,3307           47316                                    TRIG1                                 #  IF (-45,45) OR (135,-135)
053933,000099: 
053934,000100: 23,3310           72545                           DLOAD    SL1                                   #  (45,135) OR (-135,-45)
053935,000101: 23,3311           00021                                    COSTH                                 
053936,000102: 23,3312           75326                           ACOS     SIGN                                  
053937,000103: 23,3313           00023                                    SINTH                                 
053938,000104: 23,3314           00025                           STORE    THETA                                 #  X = ARCCOS(COS) WITH SIGN(SIN)
053939,000105: 23,3315           77616                           RVQ                                            
053940,000106: 
053941,000107: 23,3316           72545        TRIG1              DLOAD    SL1                                   #  (-45,45) OR (135,-135)
053942,000108: 23,3317           00023                                    SINTH                                 
053943,000109: 23,3320           77736                           ASIN                                           
053944,000110: 23,3321           14025                           STODL    THETA                                 #  X = ARCSIN(SIN) WITH SIGN(SIN)
053945,000111: 23,3322           00021                                    COSTH                                 
053946,000112: 23,3323           77640                           BMN                                            
053947,000113: 23,3324           47327                                    TRIG2                                 #  IF (135,-135)
053948,000114: 
053949,000115: 23,3325           43545                           DLOAD    RVQ                                   
053950,000116: 23,3326           00025                                    THETA                                 #  X = ARCSIN(SIN)   (-45,45)
053951,000117: 
053952,000118: 23,3327           75345        TRIG2              DLOAD    SIGN                                  #  (135,-135)
053953,000119: 23,3330           06503                                    HIDPHALF                              
053954,000120: 23,3331           00023                                    SINTH                                 
053955,000121: 23,3332           77625                           DSU                                            
053956,000122: 23,3333           00025                                    THETA                                 
053957,000123: 23,3334           00025                           STORE    THETA                                 #  X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
053958,000124: 23,3335           77616                           RVQ                                            #        (+) - (+) OR (-) - (-)
053959,000125: 

Page 1249

053961,000127:                                                                                                  #  SMNB, NBSM, AND AXISROT, WHICH USED TO APPEAR HERE, HAVE BEEN
053962,000128:                                                                                                  #  COMBINED IN A ROUTINE CALLED AX*SR*T, WHICH APPEARS AMONG THE POWERED
053963,000129:                                                                                                  #  FLIGHT SUBROUTINES.
053964,000130: 

Page 1250

053966,000132:                                                                                                  #  CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
053967,000133: 
053968,000134:                                                                                                  #  THE INPUTS ARE  1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM.  THE THREE HALF-UNIT
053969,000135:                                                                                                  #  VECTORS ARE STORED AT XNB,YNB, AND ZNB.  2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
053970,000136:                                                                                                  #  COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
053971,000137: 
053972,000138:                                                                                                  #  THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
053973,000139: 
053974,000140: 23,3336           77601        CALCGA             SETPD                                          #  PUSHDOWN 00-05, 16D-21D, 34D-37D
053975,000141: 23,3337           00001                                    0                                     
053976,000142: 23,3340           47375                           VLOAD    VXV                                   
053977,000143: 23,3341           02665                                    XNB                                   #  XNB = OGA (OUTER GIMBAL AXIS)
053978,000144: 23,3342           02651                                    YSM                                   #  YSM = IGA (INNER GIMBAL AXIS)
053979,000145: 23,3343           41456                           UNIT     PUSH                                  #  PD0 = UNIT(OGA X IGA) = MGA
053980,000146: 
053981,000147: 23,3344           44041                           DOT      ITA                                   
053982,000148: 23,3345           02701                                    ZNB                                   
053983,000149: 23,3346           00051                                    S2                                    
053984,000150: 23,3347           24021                           STOVL    COSTH                                 #  COS(OG) = MGA . ZNB
053985,000151: 23,3350           00001                                    0                                     
053986,000152: 23,3351           77641                           DOT                                            
053987,000153: 23,3352           02673                                    YNB                                   
053988,000154: 23,3353           34023                           STCALL   SINTH                                 #  SIN(OG) = MGA . YNB
053989,000155: 23,3354           47303                                    ARCTRIG                               
053990,000156: 23,3355           26740                           STOVL    OGC                                   
053991,000157: 23,3356           00001                                    0                                     
053992,000158: 
053993,000159: 23,3357           50235                           VXV      DOT                                   #  PROVISION FOR MG ANGLE OF 90 DEGREES
053994,000160: 23,3360           02665                                    XNB                                   
053995,000161: 23,3361           02651                                    YSM                                   
053996,000162: 23,3362           77752                           SL1                                            
053997,000163: 23,3363           24021                           STOVL    COSTH                                 #  COS(MG) = IGA . (MGA X OGA)
053998,000164: 23,3364           02651                                    YSM                                   
053999,000165: 23,3365           77641                           DOT                                            
054000,000166: 23,3366           02665                                    XNB                                   
054001,000167: 23,3367           34023                           STCALL   SINTH                                 #  SIN(MG) = IGA . OGA
054002,000168: 23,3370           47303                                    ARCTRIG                               
054003,000169: 23,3371           02744                           STORE    MGC                                   
054004,000170: 
054005,000171: 23,3372           45246                           ABS      DSU                                   
054006,000172: 23,3373           07521                                    .166...                               
054007,000173: 23,3374           77644                           BPL                                            
054008,000174: 23,3375           47414                                    GIMLOCK1                              #  IF ANGLE GREATER THAN 60 DEGREES
054009,000175: 
054010,000176: 23,3376           50375        CALCGA1            VLOAD    DOT                                   
054011,000177: 23,3377           02657                                    ZSM                                   
054012,000178: 23,3400           00001                                    0                                     
054013,000179: 23,3401           24021                           STOVL    COSTH                                 #  COS(IG) = ZSM . MGA
054014,000180: 23,3402           02643                                    XSM                                   

Page 1251

054016,000182: 23,3403           45441                           DOT      STADR                                 
054017,000183: 23,3404           43754                           STCALL   SINTH                                 #  SIN(IG) = XSM . MGA
054018,000184: 23,3405           47303                                    ARCTRIG                               
054019,000185: 
054020,000186: 23,3406           26742                           STOVL    IGC                                   
054021,000187: 23,3407           02740                                    OGC                                   
054022,000188: 23,3410           77634                           RTB                                            
054023,000189: 23,3411           21630                                    V1STO2S                               
054024,000190: 23,3412           34322                           STCALL   THETAD                                
054025,000191: 23,3413           00051                                    S2                                    
054026,000192: 
054027,000193: 23,3414           77776        GIMLOCK1           EXIT                                           
054028,000194: 23,3415           05571                           TC       ALARM                                 
054029,000195: 23,3416           00401                           OCT      00401                                 
054030,000196: 23,3417           05506                           TC       UPFLAG                                #  GIMBAL LOCK HAS OCCURED
054031,000197: 23,3420           00056                           ADRES    GLOKFAIL                              
054032,000198: 
054033,000199: 23,3421           06060                           TC       INTPRET                               
054034,000200: 23,3422           77650                           GOTO                                           
054035,000201: 23,3423           47376                                    CALCGA1                               
054036,000202: 

Page 1252

054038,000204:                                                                                                  #  AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
054039,000205: 
054040,000206:                                                                                                  #  THE INPUTS ARE  1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD.  2) THE STAR2 VECTOR
054041,000207:                                                                                                  #  REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6.  3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
054042,000208:                                                                                                  #  AT LOCATION 6 OF THE VAC AREA.  4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
054043,000209:                                                                                                  #  THE VAC AREA.
054044,000210: 
054045,000211:                                                                                                  #  THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B.  THE THREE HALF-UNIT VECTORS ARE STORED
054046,000212:                                                                                                  #  AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
054047,000213: 
054048,000214: 23,3424           66370        AXISGEN            AXT,1    SSP                                   #  PUSHDOWN 00-30D, 34D-37D
054049,000215: 23,3425           02714                                    STARAD     +6                         
054050,000216: 23,3426           00051                                    S1                                    
054051,000217: 23,3427           02700                                    STARAD     -6                         
054052,000218: 
054053,000219: 23,3430           77601                           SETPD                                          
054054,000220: 23,3431           00001                                    0                                     
054055,000221: 23,3432           46773        AXISGEN1           VLOAD*   VXV*                                  #  06D   UA = S1
054056,000222: 23,3433           02723                                    STARAD     +12D,1                     #         STARAD +00D    UB = S1
054057,000223: 23,3434           02731                                    STARAD     +18D,1                     
054058,000224: 23,3435           77656                           UNIT                                           #  12D   VA = UNIT(S1 X S2)
054059,000225: 23,3436           06731                           STORE    STARAD     +18D,1                     #         STARAD +06D    VB = UNIT(S1 X S2)
054060,000226: 23,3437           77773                           VLOAD*                                         
054061,000227: 23,3440           02723                                    STARAD     +12D,1                     
054062,000228: 
054063,000229: 23,3441           76433                           VXV*     VSL1                                  
054064,000230: 23,3442           02731                                    STARAD     +18D,1                     #  18D   WA = UA X VA
054065,000231: 23,3443           06737                           STORE    STARAD     +24D,1                     #         STARAD +12D    WB = UB X VB
054066,000232: 
054067,000233: 23,3444           77700                           TIX,1                                          
054068,000234: 23,3445           47432                                    AXISGEN1                              
054069,000235: 
054070,000236: 23,3446           66160                           AXC,1    SXA,1                                 
054071,000237: 23,3447           00006                                    6                                     
054072,000238: 23,3450           00036                                    30D                                   
054073,000239: 
054074,000240: 23,3451           66370                           AXT,1    SSP                                   
054075,000241: 23,3452           00022                                    18D                                   
054076,000242: 23,3453           00051                                    S1                                    
054077,000243: 23,3454           00006                                    6                                     
054078,000244: 
054079,000245: 23,3455           66374                           AXT,2    SSP                                   
054080,000246: 23,3456           00006                                    6                                     
054081,000247: 23,3457           00052                                    S2                                    
054082,000248: 23,3460           00002                                    2                                     
054083,000249: 
054084,000250: 23,3461           76720        AXISGEN2           XCHX,1   VLOAD*                                
054085,000251: 23,3462           00036                                    30D                                   #  X1=-6 X2=+6   X1=-6 X2=+4     X1=-6 X2=+2
054086,000252: 23,3463           00001                                    0,1                                   
054087,000253: 

Page 1253

054089,000255: 23,3464           62757                           VXSC*    PDVL*                                 #  J=(UA)(UB1)   J=(UA)(UB2)     J=(UA)(UB3)
054090,000256: 23,3465           75062                                    STARAD     +6,2                       
054091,000257: 23,3466           00007                                    6,1                                   
054092,000258: 23,3467           77757                           VXSC*                                          
054093,000259: 23,3470           75054                                    STARAD     +12D,2                     
054094,000260: 23,3471           30031                           STOVL*   24D                                   #  K=(VA)(VB1)   J=(VA)(VB2)     J=(VA)(VB3)
054095,000261: 23,3472           00015                                    12D,1                                 
054096,000262: 
054097,000263: 23,3473           53357                           VXSC*    VAD                                   
054098,000264: 23,3474           75046                                    STARAD     +18D,2                     #  L=(WA)(WB1)   J=(WA)(WB2)     J=(WA)(WB3)
054099,000265: 23,3475           76455                           VAD      VSL1                                  
054100,000266: 23,3476           00031                                    24D                                   
054101,000267: 23,3477           53520                           XCHX,1   UNIT                                  
054102,000268: 23,3500           00036                                    30D                                   
054103,000269: 23,3501           06707                           STORE    XDC        +18D,1                     #  XDC = L+J+K   YDC = L+J+K     ZDC = L+J+K
054104,000270: 
054105,000271: 23,3502           77700                           TIX,1                                          
054106,000272: 23,3503           47504                                    AXISGEN3                              
054107,000273: 
054108,000274: 23,3504           77704        AXISGEN3           TIX,2                                          
054109,000275: 23,3505           47461                                    AXISGEN2                              
054110,000276: 
054111,000277: 23,3506           77775                           VLOAD                                          
054112,000278: 23,3507           02665                                    XDC                                   
054113,000279: 23,3510           26707                           STOVL    STARAD                                
054114,000280: 23,3511           02673                                    YDC                                   
054115,000281: 23,3512           26715                           STOVL    STARAD     +6                         
054116,000282: 23,3513           02701                                    ZDC                                   
054117,000283: 23,3514           02723                           STORE    STARAD     +12D                       
054118,000284: 
054119,000285: 23,3515           77616                           RVQ                                            
054120,000286: 

Page 1254

054122,000288: 23,3516           05520 26075  QTSN45             2DEC     .1768                                 
054123,000289: 23,3520           05252 25253  .166...            2DEC     .1666666667                            
054124,000290: 

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