Source Code

These source-code files are part of a reconstructed copy of LM131 revision 1, the final release of the Apollo 13 Lunar Module (LM) Apollo Guidance Computer (AGC) software.

The source reconstruction began with source code of Luminary 131 previously transcribed from a digitized copy of that program. A dump of the flight spare core rope memory module B5, part number 2010802-171, serial number RAY 411, was obtained. This module is the only module different between Luminary 131 and LM131 revision 1. The dump was disassembled and all changes were incorporated into these source files. Note that page numbers in the reconstructed code match those on the Luminary 131 printout, although the changed code would likely have changed page numbers for a real LM131 revision 1 listing.

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.

013277,000002:                                                                                                  ## Copyright:   Public domain.
013278,000003:                                                                                                  ## Filename:    LEM_GEOMETRY.agc
013279,000004:                                                                                                  ## Purpose:     A section of LM131 revision 1.
013280,000005:                                                                                                  ##              It is part of the reconstructed source code for the final
013281,000006:                                                                                                  ##              release of the flight software for the Lunar Module's (LM)
013282,000007:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13. The code has
013283,000008:                                                                                                  ##              been reconstructed from a listing of Luminary 131 and a dump
013284,000009:                                                                                                  ##              of a core rope memory module B5, part number 2010802-171,
013285,000010:                                                                                                  ##              which is the only module different between LM131 revision 1
013286,000011:                                                                                                  ##              and Luminary 131. The executable generated from this source
013287,000012:                                                                                                  ##              has been verified against the module dump, so while the names,
013288,000013:                                                                                                  ##              comments, and ordering may not be exactly correct, the
013289,000014:                                                                                                  ##              resulting binary is.
013290,000015:                                                                                                  ## Reference:   pp. 322-327
013291,000016:                                                                                                  ## Assembler:   yaYUL
013292,000017:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
013293,000018:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
013294,000019:                                                                                                  ## Mod history: 2022-10-28 MAS  Created from Luminary 131.
013295,000020: 

Page 322

013297,000022: 23,2041                                           BANK     23                                    
013298,000023: 13,2000                                           SETLOC   LEMGEOM                               
013299,000024: 13,2000                                           BANK                                           
013300,000025: 
013301,000026: 13,2070  30,2000                                  SBANK=   LOWSUPER                              
013302,000027: 13,2070  E5,1642                                  EBANK=   XSM                                   
013303,000028: 
013304,000029:                                                                                                  #  THESE TWO ROUTINES COMPUTE THE ACTUAL STATE VECTOR FOR LM,CSM BY ADDING
013305,000030:                                                                                                  #  THE CONIC R,V AND THE DEVIATIONS R,V.  THE STATE VECTORS ARE CONVERTED TO
013306,000031:                                                                                                  #  METERS B-29 AND METERS/CSEC B-7 AND STORED APPROPRIATELY IN RN,VN OR
013307,000032:                                                                                                  #  R-OTHER,V-OTHER FOR DOWNLINK.  THE ROUTINES NAMES ARE SWITCHED IN THE
013308,000033:                                                                                                  #  OTHER VEHICLES COMPUTER.
013309,000034: 
013310,000035:                                                                                                  #  INPUT
013311,000036:                                                                                                  #        STATE VECTOR IN TEMPORARY STORAGE AREA
013312,000037:                                                                                                  #        IF STATE VECTOR IS SCALED POS B27 AND VEL B5
013313,000038:                                                                                                  #                SET X2 TO +2
013314,000039:                                                                                                  #        IF STATE VECTOR IS SCALED POS B29 AND VEL B7
013315,000040:                                                                                                  #                SET X2 TO 0
013316,000041: 
013317,000042:                                                                                                  #  OUTPUT
013318,000043:                                                                                                  #        R(T) IN RN, V(T) IN VN, T IN PIPTIME
013319,000044:                                                                                                  #  OR
013320,000045:                                                                                                  #        R(T) IN R-OTHER, V(T) IN V-OTHER        (T IS DEFINED BY T-OTHER)
013321,000046: 
013322,000047: 13,2070                                           COUNT*   $$/GEOM                               
013323,000048: 13,2070           43414        SVDWN2             BOF      RVQ                                   #  SW=1=AVETOMID DOING W-MATRIX INTEG.
013324,000049: 13,2071           04756                                    AVEMIDSW                              
013325,000050: 13,2072           26073                                    +1                                    
013326,000051: 13,2073           53775                           VLOAD    VSL*                                  
013327,000052: 13,2074           01521                                    TDELTAV                               
013328,000053: 13,2075           57605                                    0          -7,2                       
013329,000054: 13,2076           53655                           VAD      VSL*                                  
013330,000055: 13,2077           01535                                    RCV                                   
013331,000056: 13,2100           57576                                    0,2                                   
013332,000057: 13,2101           25220                           STOVL    RN                                    
013333,000058: 13,2102           01527                                    TNUV                                  
013334,000059: 13,2103           53257                           VSL*     VAD                                   
013335,000060: 13,2104           57602                                    0          -4,2                       
013336,000061: 13,2105           01543                                    VCV                                   
013337,000062: 13,2106           77657                           VSL*                                           
013338,000063: 13,2107           57576                                    0,2                                   
013339,000064: 13,2110           15226                           STODL    VN                                    
013340,000065: 13,2111           01517                                    TET                                   
013341,000066: 13,2112           01234                           STORE    PIPTIME                               
013342,000067: 13,2113           77616                           RVQ                                            

Page 323

013344,000069: 13,2114           53775        SVDWN1             VLOAD    VSL*                                  
013345,000070: 13,2115           01521                                    TDELTAV                               
013346,000071: 13,2116           57605                                    0          -7,2                       
013347,000072: 13,2117           53655                           VAD      VSL*                                  
013348,000073: 13,2120           01535                                    RCV                                   
013349,000074: 13,2121           57576                                    0,2                                   
013350,000075: 13,2122           25720                           STOVL    R-OTHER                               
013351,000076: 13,2123           01527                                    TNUV                                  
013352,000077: 13,2124           53257                           VSL*     VAD                                   
013353,000078: 13,2125           57602                                    0          -4,2                       
013354,000079: 13,2126           01543                                    VCV                                   
013355,000080: 13,2127           77657                           VSL*                                           
013356,000081: 13,2130           57576                                    0,2                                   
013357,000082: 13,2131           01726                           STORE    V-OTHER                               
013358,000083: 13,2132           77616                           RVQ                                            
013359,000084: 

Page 324

013361,000086:                                                                                                  #  THE FOLLOWING ROUTINE TAKES A HALF UNIT TARGET VECTOR REFERRED TO NAV BASE COORDINATES AND FINDS BOTH
013362,000087:                                                                                                  #  GIMBAL ORIENTATIONS AT WHICH THE RR MIGHT SIGHT THE TARGET.  THE GIMBAL ANGLES CORRESPONDING TO THE PRESENT MODE
013363,000088:                                                                                                  #  ARE LEFT IN MODEA AND THOSE WHICH WOULD BE USED AFTER A REMODE IN MODEB.  THIS ROUTINE ASSUMES MODE 1 IS TRUNNION
013364,000089:                                                                                                  #  ANGLE LESS THAN 90 DEGS IN ABS VALUE WITH ARBITRARY SHAFT, WITH A CORRESPONDING DEFINITION FOR MODE 2.  MODE
013365,000090:                                                                                                  #  SELECTION AND LIMIT CHECKING ARE DONE ELSEWHERE.
013366,000091: 
013367,000092:                                                                                                  #  THE MODE 1 CONFIGURATION IS CALCULATED FROM THE VECTOR AND THEN MODE 2 IS FOUND USING THE RELATIONS
013368,000093: 
013369,000094:                                                                                                  #        S(2) = 180 + S(1)
013370,000095:                                                                                                  #        T(2) = 180 - T(1)
013371,000096: 
013372,000097:                                                                                                  #  THE VECTOR ARRIVES IN MPAC WHERE TRG*SMNG OR *SMNB* WILL HAVE LEFT IT.
013373,000098: 
013374,000099: 13,2133           00041        RRANGLES           STORE    32D                                   
013375,000100: 13,2134           57545                           DLOAD    DCOMP                                 #  SINCE WE WILL FIND THE MODE 1 SHAFT
013376,000101: 13,2135           00043                                    34D                                   #  ANGLE LATER, WE CAN FIND THE MODE 1
013377,000102: 13,2136           67401                           SETPD    ASIN                                  #  TRUNNION BY SIMPLY TAKING THE ARCSIN OF
013378,000103: 13,2137           00001                                    0                                     #  THE Y COMPONENT, THE ASIN GIVING AN
013379,000104: 13,2140           44206                           PUSH     BDSU                                  #  ANSWER WHOSE ABS VAL IS LESS THAN 90 DEG
013380,000105: 13,2141           24005                                    LODPHALF                              
013381,000106: 13,2142           14005                           STODL    4                                     #  MODE 2 TRUNNION TO 4.
013382,000107: 13,2143           24007                                    LO6ZEROS                              
013383,000108: 13,2144           24043                           STOVL    34D                                   #  UNIT THE PROJECTION OF THE VECTOR
013384,000109: 13,2145           00041                                    32D                                   #        IN THE X-Z PLANE
013385,000110: 13,2146           41056                           UNIT     BOVB                                  #  IF OVERFLOW, TARGET VECTOR IS ALONG Y
013386,000111: 13,2147           52432                                    LUNDESCH                              #  CALL FOR MANEUVER UNLESS ON LUNAR SURF
013387,000112: 13,2150           14041                           STODL    32D                                   #  PROJECTION VECTOR.
013388,000113: 13,2151           00041                                    32D                                   
013389,000114: 13,2152           44142                           SR1      STQ                                   
013390,000115: 13,2153           00051                                    S2                                    
013391,000116: 13,2154           14023                           STODL    SINTH                                 #  USE ARCTRIG SINCE SHAFT COULD BE ARB.
013392,000117: 13,2155           00045                                    36D                                   
013393,000118: 13,2156           77742                           SR1                                            
013394,000119: 13,2157           34021                           STCALL   COSTH                                 
013395,000120: 13,2160           47322                                    ARCTRIG                               

Page 325

013397,000122: 13,2161           43206                           PUSH     DAD                                   #  MODE 1 SHAFT TO 2.
013398,000123: 13,2162           24005                                    LODPHALF                              
013399,000124: 13,2163           24007                           STOVL    6                                     
013400,000125: 13,2164           00005                                    4                                     
013401,000126: 13,2165           77634                           RTB                                            #  FIND MODE 2 CDU ANGLES.
013402,000127: 13,2166           21636                                    2V1STO2S                              
013403,000128: 13,2167           25111                           STOVL    MODEB                                 
013404,000129: 13,2170           00001                                    0                                     
013405,000130: 13,2171           77634                           RTB                                            #  MODE 1 ANGLES TO MODE A.
013406,000131: 13,2172           21636                                    2V1STO2S                              
013407,000132: 13,2173           01107                           STORE    MODEA                                 
013408,000133: 13,2174           77776                           EXIT                                           
013409,000134: 
013410,000135: 13,2175           40110                           CS       RADMODES                              #  SWAP MODEA AND MODEB IF RR IN MODE 2.
013411,000136: 13,2176           74740                           MASK     ANTENBIT                              
013412,000137: 13,2177           10000                           CCS      A                                     
013413,000138: 13,2200           12204                           TCF      +4                                    
013414,000139: 
013415,000140: 13,2201           53107                           DXCH     MODEA                                 
013416,000141: 13,2202           53111                           DXCH     MODEB                                 
013417,000142: 13,2203           53107                           DXCH     MODEA                                 
013418,000143: 
013419,000144: 13,2204           06042                           TC       INTPRET                               
013420,000145: 13,2205           77650                           GOTO                                           
013421,000146: 13,2206           00051                                    S2                                    

Page 326

013423,000148:                                                                                                  #  GIVEN RR TRUNNION AND SHAFT (T,S) IN TANGNB,+1, FIND THE ASSOCIATED
013424,000149:                                                                                                  #  LINE OF SIGHT IN NAV BASE AXES.  THE HALF UNIT VECTOR, .5(SIN(S)COS(T),
013425,000150:                                                                                                  #  -SIN(T),COS(S)COS(T)) IS LEFT IN MPAC AND 32D.
013426,000151: 
013427,000152: 23,2000                                           SETLOC   INFLIGHT                              
013428,000153: 23,2000                                           BANK                                           
013429,000154: 
013430,000155: 23,2041                                           COUNT*   $$/GEOM                               
013431,000156: 
013432,000157: 23,2041           47135        RRNB               SLOAD    RTB                                   
013433,000158: 23,2042           03753                                    TANGNB                                
013434,000159: 23,2043           21577                                    CDULOGIC                              
013435,000160: 23,2044           41401                           SETPD    PUSH                                  #  TRUNNION ANGLE TO 0
013436,000161: 23,2045           00001                                    0                                     
013437,000162: 23,2046           57556                           SIN      DCOMP                                 
013438,000163: 23,2047           14043                           STODL    34D                                   #  Y COMPONENT
013439,000164: 
013440,000165: 23,2050           41546                           COS      PUSH                                  #  .5 COS(T) TO 0
013441,000166: 23,2051           47135                           SLOAD    RTB                                   
013442,000167: 23,2052           03754                                    TANGNB     +1                         
013443,000168: 23,2053           21577                                    CDULOGIC                              
013444,000169: 23,2054           71406        RRNB1              PUSH     COS                                   #  SHAFT ANGLE TO 2
013445,000170: 23,2055           72405                           DMP      SL1                                   
013446,000171: 23,2056           00001                                    0                                     
013447,000172: 23,2057           14045                           STODL    36D                                   #  Z COMPONENT
013448,000173: 
013449,000174: 23,2060           41356                           SIN      DMP                                   
013450,000175: 23,2061           77752                           SL1                                            
013451,000176: 23,2062           24041                           STOVL    32D                                   
013452,000177: 23,2063           00041                                    32D                                   
013453,000178: 23,2064           77616                           RVQ                                            
013454,000179: 
013455,000180:                                                                                                  #  THIS ENTRY TO RRNB REQUIRES THE TRUNNION AND SHAFT ANGLES IN MPAC AND MPAC +1 RESPECTIVELY
013456,000181: 
013457,000182: 23,2065           14025        RRNBMPAC           STODL    20D                                   #  SAVE SHAFT CDU IN 21.
013458,000183: 23,2066           00155                                    MPAC                                  #  SET MODE TO DP.  (THE PRECEEDING STORE
013459,000184:                                                                                                  #  MAY BE DP, TP OR VECTOR.)
013460,000185: 23,2067           40234                           RTB      SETPD                                 
013461,000186: 23,2070           21577                                    CDULOGIC                              
013462,000187: 23,2071           00001                                    0                                     
013463,000188: 23,2072           73406                           PUSH     SIN                                   #  TRUNNION ANGLE TO 0
013464,000189: 23,2073           77676                           DCOMP                                          
013465,000190: 23,2074           14043                           STODL    34D                                   #  Y COMPONENT
013466,000191: 23,2075           41546                           COS      PUSH                                  #  .5COS(T) TO 0
013467,000192: 23,2076           47135                           SLOAD    RTB                                   #  PICK UP CDU'S.
013468,000193: 23,2077           00026                                    21D                                   
013469,000194: 23,2100           21577                                    CDULOGIC                              
013470,000195: 23,2101           77650                           GOTO                                           
013471,000196: 23,2102           46054                                    RRNB1                                 

Page 327
This page has nothing on it.

013474,000199: 
013475,000200: 

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