Source Code

These source-code files derive from a printout of Luminary 116 (the Apollo 12 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Ron Burkey, 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 116 OF AGC PROGRAM LUMINARY BY NASA 2021112-071
	19:09 AUG. 11,1969
Note that the date is the date of the printout, not the date of the program revision.

013476,000002:                                                                                                  ## Copyright:   Public domain.
013477,000003:                                                                                                  ## Filename:    LEM_GEOMETRY.agc
013478,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
013479,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM) 
013480,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
013481,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
013482,000008:                                                                                                  ##              that the code format has been changed to conform to the
013483,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
013484,000010:                                                                                                  ##              original YUL assembler.
013485,000011:                                                                                                  ## Reference:   pp. 321-326
013486,000012:                                                                                                  ## Assembler:   yaYUL
013487,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
013488,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
013489,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
013490,000016:                                                                                                  ##              2017-03-07 RSB  Transcribed, and then proofed comment-text using
013491,000017:                                                                                                  ##                              3-way diff vs Luminary 99 and Luminary 131.
013492,000018:                                                                                                  ##                              (Admittedly, the former is more for detecting errors
013493,000019:                                                                                                  ##                              in Luminary 99 than the other way around.)
013494,000020: 

Page 321

013496,000022: 23,2041                                           BANK     23                                    
013497,000023: 13,2000                                           SETLOC   LEMGEOM                               
013498,000024: 13,2000                                           BANK                                           
013499,000025: 
013500,000026: 13,2070  30,2000                                  SBANK=   LOWSUPER                              
013501,000027: 13,2070  E5,1642                                  EBANK=   XSM                                   
013502,000028: 
013503,000029:                                                                                                  #  THESE TWO ROUTINES COMPUTE THE ACTUAL STATE VECTOR FOR LM,CSM BY ADDING
013504,000030:                                                                                                  #  THE CONIC R,V AND THE DEVIATIONSR,V. THE STATE VECTORS ARE CONVERTED TO
013505,000031:                                                                                                  #  METERS B-29 AND METERS/CSEC B-7 AND STORED APPROPRIATELY IN RN,VN OR
013506,000032:                                                                                                  #  R-OTHER,V-OTHER FOR DOWNLINK.  THE ROUTINES NAMES ARE SWITCHED IN THE
013507,000033:                                                                                                  #  OTHER VEHICLES COMPUTER.
013508,000034: 
013509,000035:                                                                                                  #  INPUT
013510,000036:                                                                                                  #    STATE VECTOR IN TEMPORARY STORAGE AREA
013511,000037:                                                                                                  #    IF STATE VECTOR IS SCALED POS B27 AND VEL B5
013512,000038:                                                                                                  #       SET X2 TO +2
013513,000039:                                                                                                  #    IF STATE VECTOR IS SCALED POS B29 AND VEL B7
013514,000040:                                                                                                  #       SET X2 TO 0
013515,000041: 
013516,000042:                                                                                                  #  OUTPUT
013517,000043:                                                                                                  #    R(T) IN RN, V(T) IN VN, T IN PIPTIME
013518,000044:                                                                                                  #  OR
013519,000045:                                                                                                  #    R(T) IN R-OTHER, V(T) IN V-OTHER   (T IS DEFINED BY T-OTHER)
013520,000046: 
013521,000047: 13,2070                                           COUNT*   $$/GEOM                               
013522,000048: 13,2070           43414        SVDWN2             BOF      RVQ                                   #  SW=1=AVETOMID DOING W-MATRIX INTEG.
013523,000049: 13,2071           04756                                    AVEMIDSW                              
013524,000050: 13,2072           26073                                    +1                                    
013525,000051: 13,2073           53775                           VLOAD    VSL*                                  
013526,000052: 13,2074           01521                                    TDELTAV                               
013527,000053: 13,2075           57605                                    0          -7,2                       
013528,000054: 13,2076           53655                           VAD      VSL*                                  
013529,000055: 13,2077           01535                                    RCV                                   
013530,000056: 13,2100           57576                                    0,2                                   
013531,000057: 13,2101           25220                           STOVL    RN                                    
013532,000058: 13,2102           01527                                    TNUV                                  
013533,000059: 13,2103           53257                           VSL*     VAD                                   
013534,000060: 13,2104           57602                                    0          -4,2                       
013535,000061: 13,2105           01543                                    VCV                                   
013536,000062: 13,2106           77657                           VSL*                                           
013537,000063: 13,2107           57576                                    0,2                                   
013538,000064: 13,2110           15226                           STODL    VN                                    
013539,000065: 13,2111           01517                                    TET                                   
013540,000066: 13,2112           01234                           STORE    PIPTIME                               
013541,000067: 13,2113           77616                           RVQ                                            

Page 322

013543,000069: 13,2114           53775        SVDWN1             VLOAD    VSL*                                  
013544,000070: 13,2115           01521                                    TDELTAV                               
013545,000071: 13,2116           57605                                    0          -7,2                       
013546,000072: 13,2117           53655                           VAD      VSL*                                  
013547,000073: 13,2120           01535                                    RCV                                   
013548,000074: 13,2121           57576                                    0,2                                   
013549,000075: 13,2122           25720                           STOVL    R-OTHER                               
013550,000076: 13,2123           01527                                    TNUV                                  
013551,000077: 13,2124           53257                           VSL*     VAD                                   
013552,000078: 13,2125           57602                                    0          -4,2                       
013553,000079: 13,2126           01543                                    VCV                                   
013554,000080: 13,2127           77657                           VSL*                                           
013555,000081: 13,2130           57576                                    0,2                                   
013556,000082: 13,2131           01726                           STORE    V-OTHER                               
013557,000083: 13,2132           77616                           RVQ                                            
013558,000084: 

Page 323

013560,000086:                                                                                                  #           THE FOLLOWING ROUTINE TAKES A HALF UNIT TARGET VECTOR REFERRED TO NAV BASE COORDINATES AND FINDS BOTH
013561,000087:                                                                                                  #  GIMBAL ORIENTATIONS AT WHICH THE RR MIGHT SIGHT THE TARGET. THE GIMBAL ANGLES CORRESPONDING TO THE PRESENT MODE
013562,000088:                                                                                                  #  ARE LEFT IN MODEA AND THOSE WHICH WOULD BE USED AFTER A REMODE IN MODEB. THIS ROUTINE ASSUMES MODE 1 IS TRUNNION
013563,000089:                                                                                                  #  ANGLE LESS THAN 90 DEGS IN ABS VALUE WITH ARBITRARY SHAFT, WITH A CORRESPONDING DEFINITION FOR MODE 2. MODE
013564,000090:                                                                                                  #  SELECTION AND LIMIT CHECKING ARE DONE ELSEWHERE.
013565,000091: 
013566,000092:                                                                                                  #           THE MODE 1 CONFIGURATION IS CALCULATED FROM THE VECTOR AND THEN MODE 2 IS FOUND USING THE RELATIONS
013567,000093: 
013568,000094:                                                                                                  #           S(2) = 180 + S(1)
013569,000095:                                                                                                  #           T(2) = 180 - T(1)
013570,000096: 
013571,000097:                                                                                                  #      THE VECTOR ARRIVES IN MPAC WHERE TRG*SMNG OR *SMNB* WILL HAVE LEFT IT.
013572,000098: 
013573,000099: 13,2133           00041        RRANGLES           STORE    32D                                   
013574,000100: 13,2134           57545                           DLOAD    DCOMP                                 #  SINCE WE WILL FIND THE MODE 1 SHAFT
013575,000101: 13,2135           00043                                    34D                                   #  ANGLE LATER, WE CAN FIND THE MODE 1
013576,000102: 13,2136           67401                           SETPD    ASIN                                  #  TRUNNION BY SIMPLY TAKING THE ARCSIN OF
013577,000103: 13,2137           00001                                    0                                     #  THE Y COMPONENT, THE ASIN GIVING AN
013578,000104: 13,2140           44206                           PUSH     BDSU                                  #  ANSWER WHOSE ABS VAL IS LESS THAN 90 DEG
013579,000105: 13,2141           24005                                    LODPHALF                              
013580,000106: 13,2142           14005                           STODL    4                                     #  MODE 2 TRUNNION TO 4.
013581,000107: 
013582,000108: 13,2143           24007                                    LO6ZEROS                              
013583,000109: 13,2144           24043                           STOVL    34D                                   #  UNIT THE PROJECTION OF THE VECTOR
013584,000110: 13,2145           00041                                    32D                                   #    IN THE X-Z PLANE
013585,000111: 13,2146           41056                           UNIT     BOVB                                  #  IF OVERFLOW,TARGET VECTOR IS ALONG Y
013586,000112: 13,2147           52432                                    LUNDESCH                              #  CALL FOR MANEUVER UNLESS ON LUNAR SURF
013587,000113: 13,2150           14041                           STODL    32D                                   #  PROJECTION VECTOR.
013588,000114: 13,2151           00041                                    32D                                   
013589,000115: 13,2152           44142                           SR1      STQ                                   
013590,000116: 13,2153           00051                                    S2                                    
013591,000117: 13,2154           14023                           STODL    SINTH                                 #  USE ARCTRIG SINCE SHAFT COULD BE ARB.
013592,000118: 13,2155           00045                                    36D                                   
013593,000119: 13,2156           77742                           SR1                                            
013594,000120: 13,2157           34021                           STCALL   COSTH                                 
013595,000121: 13,2160           47322                                    ARCTRIG                               

Page 324

013597,000123: 13,2161           43206                           PUSH     DAD                                   #  MODE 1 SHAFT TO 2.
013598,000124: 13,2162           24005                                    LODPHALF                              
013599,000125: 13,2163           24007                           STOVL    6                                     
013600,000126: 13,2164           00005                                    4                                     
013601,000127: 13,2165           77634                           RTB                                            #  FIND MODE 2 CDU ANGLES.
013602,000128: 13,2166           21636                                    2V1STO2S                              
013603,000129: 13,2167           25111                           STOVL    MODEB                                 
013604,000130: 13,2170           00001                                    0                                     
013605,000131: 13,2171           77634                           RTB                                            #  MODE 1 ANGLES TO MODE A.
013606,000132: 13,2172           21636                                    2V1STO2S                              
013607,000133: 13,2173           01107                           STORE    MODEA                                 
013608,000134: 13,2174           77776                           EXIT                                           
013609,000135: 
013610,000136: 13,2175           40110                           CS       RADMODES                              #  SWAP MODEA AND MODEB IF RR IN MODE 2.
013611,000137: 13,2176           74740                           MASK     ANTENBIT                              
013612,000138: 13,2177           10000                           CCS      A                                     
013613,000139: 13,2200           12204                           TCF      +4                                    
013614,000140: 
013615,000141: 13,2201           53107                           DXCH     MODEA                                 
013616,000142: 13,2202           53111                           DXCH     MODEB                                 
013617,000143: 13,2203           53107                           DXCH     MODEA                                 
013618,000144: 
013619,000145: 13,2204           06042                           TC       INTPRET                               
013620,000146: 13,2205           77650                           GOTO                                           
013621,000147: 13,2206           00051                                    S2                                    

Page 325

013623,000149:                                                                                                  #  GIVEN RR TRUNNION AND SHAFT (T,S) IN TANGNB,+1,FIND THE ASSOCIATED
013624,000150:                                                                                                  #  LINE OF SIGHT IN NAV BASE AXES.  THE HALF UNIT VECTOR, .5(SIN(S)COS(T),
013625,000151:                                                                                                  #  -SIN(T),COS(S)COS(T)) IS LEFT IN MPAC AND 32D.
013626,000152: 
013627,000153: 23,2000                                           SETLOC   INFLIGHT                              
013628,000154: 23,2000                                           BANK                                           
013629,000155: 
013630,000156: 23,2041                                           COUNT*   $$/GEOM                               
013631,000157: 
013632,000158: 23,2041           47135        RRNB               SLOAD    RTB                                   
013633,000159: 23,2042           03753                                    TANGNB                                
013634,000160: 23,2043           21577                                    CDULOGIC                              
013635,000161: 23,2044           41401                           SETPD    PUSH                                  #  TRUNNION ANGLE TO 0
013636,000162: 23,2045           00001                                    0                                     
013637,000163: 23,2046           57556                           SIN      DCOMP                                 
013638,000164: 23,2047           14043                           STODL    34D                                   #  Y COMPONENT
013639,000165: 
013640,000166: 23,2050           41546                           COS      PUSH                                  #  .5 COS(T) TO 0
013641,000167: 23,2051           47135                           SLOAD    RTB                                   
013642,000168: 23,2052           03754                                    TANGNB     +1                         
013643,000169: 23,2053           21577                                    CDULOGIC                              
013644,000170: 23,2054           71406        RRNB1              PUSH     COS                                   #  SHAFT ANGLE TO 2
013645,000171: 23,2055           72405                           DMP      SL1                                   
013646,000172: 23,2056           00001                                    0                                     
013647,000173: 23,2057           14045                           STODL    36D                                   #  Z COMPONENT
013648,000174: 
013649,000175: 23,2060           41356                           SIN      DMP                                   
013650,000176: 23,2061           77752                           SL1                                            
013651,000177: 23,2062           24041                           STOVL    32D                                   
013652,000178: 23,2063           00041                                    32D                                   
013653,000179: 23,2064           77616                           RVQ                                            
013654,000180: 
013655,000181:                                                                                                  #  THIS ENTRY TO RRNB REQUIRES THE TRUNNION AND SHAFT ANGLES IN MPAC AND MPAC +1 RESPECTIVELY
013656,000182: 
013657,000183: 23,2065           14025        RRNBMPAC           STODL    20D                                   #  SAVE SHAFT CDU IN 21.
013658,000184: 23,2066           00155                                    MPAC                                  #  SET MODE TO DP.  (THE PRECEEDING STORE
013659,000185:                                                                                                  #  MAY BE DP, TP OR VECTOR.)
013660,000186: 23,2067           40234                           RTB      SETPD                                 
013661,000187: 23,2070           21577                                    CDULOGIC                              
013662,000188: 23,2071           00001                                    0                                     
013663,000189: 23,2072           73406                           PUSH     SIN                                   #  TRUNNION ANGLE TO 0
013664,000190: 23,2073           77676                           DCOMP                                          
013665,000191: 23,2074           14043                           STODL    34D                                   #  Y COMPONENT
013666,000192: 23,2075           41546                           COS      PUSH                                  #  .5COS(T) TO 0
013667,000193: 23,2076           47135                           SLOAD    RTB                                   #  PICK UP CDU'S.
013668,000194: 23,2077           00026                                    21D                                   
013669,000195: 23,2100           21577                                    CDULOGIC                              
013670,000196: 23,2101           77650                           GOTO                                           
013671,000197: 23,2102           46054                                    RRNB1                                 

Page 326
This page has nothing on it.

013674,000200: 
013675,000201: 

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