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.

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

Page 1246

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

Page 1247

053918,000072: 23,3267           26744                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
053919,000073: 23,3270           00027                                    ZPRIME                                
053920,000074: 23,3271           77641                           DOT                                            
053921,000075: 23,3272           02701                                    ZDC                                   
053922,000076: 23,3273           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
053923,000077: 23,3274           00027                                    ZPRIME                                
053924,000078: 23,3275           77641                           DOT                                            
053925,000079: 23,3276           02673                                    YDC                                   
053926,000080: 23,3277           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
053927,000081: 23,3300           47303                                    ARCTRIG                               
053928,000082: 
053929,000083: 23,3301           36740                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
053930,000084: 23,3302           00051                                    S2                                    
053931,000085: 

Page 1248

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

Page 1249

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

Page 1250

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

Page 1251

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

Page 1252

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

Page 1253

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

Page 1254

054134,000288: 23,3516           05520 26075  QTSN45             2DEC     .1768                                 
054135,000289: 23,3520           05252 25253  .166...            2DEC     .1666666667                            
054136,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