Source Code

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

The reconstruction began with reconstructed source code for Luminary 173. Changes between revision 163 and 173 were backed out, as described by Luminary memos 157 and 158. The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021152N. Note that page numbers in the reconstructed code match those for the baseline log section mentioned in each file's changelog; the page numbers for a real Luminary 163 listing would be different.

Comments from the original source code are prefixed with a single '#' symbol, whereas comments added later are prefixed by "##" or "###". Report any errors noted by creating an issue report at the Virtual AGC project's GitHub repository.

008875,000002:                                                                                                  ## Copyright:   Public domain.
008876,000003:                                                                                                  ## Filename:    AGS_INITIALIZATION.agc
008877,000004:                                                                                                  ## Purpose:     A section of Luminary revision 163.
008878,000005:                                                                                                  ##              It is part of the reconstructed source code for the first
008879,000006:                                                                                                  ##              (unflown) release of the flight software for the Lunar
008880,000007:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 14.
008881,000008:                                                                                                  ##              The code has been recreated from a reconstructed copy of
008882,000009:                                                                                                  ##              Luminary 173, as well as Luminary memos 157 amd 158.
008883,000010:                                                                                                  ##              It has been adapted such that the resulting bugger words
008884,000011:                                                                                                  ##              exactly match those specified for Luminary 163 in NASA
008885,000012:                                                                                                  ##              drawing 2021152N, which gives relatively high confidence
008886,000013:                                                                                                  ##              that the reconstruction is correct.
008887,000014:                                                                                                  ## Reference:   pp. 213-217
008888,000015:                                                                                                  ## Assembler:   yaYUL
008889,000016:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
008890,000017:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
008891,000018:                                                                                                  ## Mod history: 2019-08-21 MAS  Created from Luminary 173.
008892,000019: 

Page 213

008894,000021:                                                                                                  #  PROGRAM NAME:   AGS INITIALIZATION (R47)
008895,000022: 
008896,000023:                                                                                                  #  WRITTEN BY  :   RHODE/KILROY/FOLLETT
008897,000024: 
008898,000025:                                                                                                  #  MOD NO. :       0
008899,000026:                                                                                                  #  DATE    :       23 MARCH 1967
008900,000027:                                                                                                  #  MOD BY  :       KILROY
008901,000028: 
008902,000029:                                                                                                  #  MOD NO. :       1
008903,000030:                                                                                                  #  DATE    :       28 OCTOBER 1967
008904,000031:                                                                                                  #  MOD BY  :       FOLLETT
008905,000032: 
008906,000033:                                                                                                  #  FUNCT. DESC.:   (1) TO PROVIDE THE AGS ABORT ELECTRONICS ASSEMBLY(AEA) WITH THE LEM AND CSM STATE VECTORS
008907,000034:                                                                                                  #                  (POSITION,VELOCITY,TIME) IN LEM IMU COORDINATES BY MEANS OF THE LGC DIGITAL DOWNLINK.
008908,000035: 
008909,000036:                                                                                                  #                  (2) TO ZERO THE ICDU, LGC AND AEA GIMBAL ANGLE COUNTERS SIMULTANEOUSLY IN ORDER TO ESTABLISH A
008910,000037:                                                                                                  #                  COMMON ZERO REFERENCE FOR THE MEASUREMENT OF GIMBAL(EULER) ANGLES WHICH DEFINE LEM ATTITUDE
008911,000038:                                                                                                  #                  (3) TO ESTABLISH THE GROUND ELAPSED TIME OF AEA CLOCK ZERO.(IF AN AEA CLOCK ZERO IS
008912,000039:                                                                                                  #                  REQUESTED DURING THIS PROGRAM
008913,000040: 
008914,000041:                                                                                                  #  LOG SECTION :   AGS INITIALIZATION
008915,000042: 
008916,000043:                                                                                                  #  CALLING SEQ :   PROGRAM IS ENTERED WHEN ASTRONAUT KEYS V47E ON DSKY.
008917,000044:                                                                                                  #                  R47 MAY BE CALLED AT ANY TIME EXCEPT WHEN ANOTHER EXTENDED VERB IS IN PROGRESS
008918,000045: 
008919,000046:                                                                                                  #  SUBROUTINES
008920,000047:                                                                                                  #  CALLED      :
008921,000048: 
008922,000049:                                                                                                  #  NORMAL EXIT :  ENDEXT
008923,000050: 
008924,000051:                                                                                                  #  ALARM/ABORT :  ALARM - BAD REFSMMAT - CODE:220
008925,000052:                                                                                                  #                 OPERATOR ERROR IF V47 SELECTED DURING ANOTHER EXTENDED VERB.
008926,000053: 
008927,000054:                                                                                                  #  ERASABLES
008928,000055:                                                                                                  #  USED        :  SAMPTIME    (2) TIME OF :ENTER: KEYSTROKE
008929,000056:                                                                                                  #                 AGSK        (2) GROUND ELAPSED TIME OF THE AEA CLOCK :ZERO:
008930,000057:                                                                                                  #                 AGSBUFF   (140) CONTAINS AGS INITIALIZATION DATA (SEE :OUTPUT: BELOW)
008931,000058:                                                                                                  #                 AGSWORD     (1) PREVIOUS DOWNLIST SAVED HERE
008932,000059: 
008933,000060: 05,2460  E6,1771                                  EBANK=   AGSK                                  
008934,000061: 40,2000                                           BANK     40                                    
008935,000062: 32,2000                                           SETLOC   R47                                   
008936,000063: 32,2000                                           BANK                                           
008937,000064: 
008938,000065: 32,2005                                           COUNT*   $$/R47                                
008939,000066: 
008940,000067: 32,2005           34737        AGSINIT            CAF      REFSMBIT                              
008941,000068: 32,2006           70077                           MASK     FLAGWRD3                              #  CHECK REFSMFLG.
008942,000069: 32,2007           10000                           CCS      A                                     
008943,000070: 32,2010           02017                           TC       REDSPTEM                              #  REFSMMAT IS OK

Page 214

008945,000072: 32,2011           05600                           TC       ALARM                                 #  REFSMMAT IS BAD
008946,000073: 32,2012           00220                           OCT      220                                   
008947,000074: 32,2013           05503                           TC       ENDEXT                                
008948,000075: 
008949,000076: 32,2014           00006        NEWAGS             EXTEND                                         
008950,000077: 32,2015           30014                           DCA      SAMPTIME                              #  TIME OF THE :ENTER: KEYSTROKE
008951,000078: 32,2016           53772                           DXCH     AGSK                                  #  BECOMES NEW AEA CLOCK :ZERO:
008952,000079: 
008953,000080: 32,2017           00006        REDSPTEM           EXTEND                                         
008954,000081: 32,2020           31772                           DCA      AGSK                                  
008955,000082: 32,2021           53051                           DXCH     DSPTEMX                               
008956,000083: 32,2022           32172        AGSDISPK           CAF      V06N16                                
008957,000084: 32,2023           04616                           TC       BANKCALL                              #  R1 = 00XXX. HRS., R2 = 000XX MIN.,
008958,000085: 32,2024           20334                           CADR     GOMARKF                               #  R3 = 0XX.XX SEC.
008959,000086: 32,2025           05503                           TC       ENDEXT                                #  TERMINATE RETURN
008960,000087: 32,2026           02036                           TC       AGSVCALC                              #  PROCEED RETURN
008961,000088: 32,2027           44746                           CS       BIT6                                  #  IS ENTER VIA A V32
008962,000089: 32,2030           60154                           AD       MPAC                                  
008963,000090: 32,2031           00006                           EXTEND                                         
008964,000091: 32,2032           12014                           BZF      NEWAGS                                #  YES, USE KEYSTROKE TIME FOR NEW AGSK
008965,000092: 
008966,000093: 32,2033           00006                           EXTEND                                         #  NO, NEW AGSK LOADED VIA V25
008967,000094: 32,2034           31051                           DCA      DSPTEMX                               #  LOADED INTO DSPTEMX BY KEYING
008968,000095: 32,2035           02016                           TC       REDSPTEM   -1                         #  V25E FOLLOWED BY HRS.,MINS.,SECS.
008969,000096:                                                                                                  #  DISPLAY THE NEW K
008970,000097: 
008971,000098: 32,2036           06042        AGSVCALC           TC       INTPRET                               
008972,000099: 32,2037           77614                           SET                                            
008973,000100: 32,2040           01076                                    NODOFLAG                              #  DONT ALLOW V37
008974,000101: 32,2041           77414                           SET      EXIT                                  
008975,000102: 32,2042           02076                                    XDSPFLAG                              
008976,000103: 
008977,000104: 32,2043           32172                           CAF      V06N16                                
008978,000105: 32,2044           04616                           TC       BANKCALL                              
008979,000106: 32,2045           20621                           CADR     EXDSPRET                              
008980,000107: 
008981,000108: 32,2046           06042                           TC       INTPRET                               #  EXTRAPOLATE LEM AND CSM STATE VECTORS
008982,000109: 32,2047           77634                           RTB                                            #  TO THE PRESENT TIME
008983,000110: 32,2050           21574                                    LOADTIME                              #  LOAD MPAC WITH TIME2,TIME1
008984,000111: 32,2051           34041                           STCALL   TDEC1                                 #  CALCULATE LEM STATE VECTOR
008985,000112: 32,2052           27056                                    LEMPREC                               
008986,000113: 32,2053           77624                           CALL                                           #  CALL ROUTINE TO CONVERT TO SM COORDS AND
008987,000114: 32,2054           64132                                    SCALEVEC                              #  PROVIDE PROPER SCALING
008988,000115: 32,2055           16201                           STODL    AGSBUFF                               #  (LEMPREC AND CSMPREC LEAVE TDEC1 IN TAT)
008989,000116: 32,2056           00015                                    TAT                                   #  TAT = TIME TO WHICH RATT1 AND VATT1 ARE
008990,000117: 32,2057           34041                           STCALL   TDEC1                                 #  COMPUTED(CSEC SINCE CLOCK START B-28).
008991,000118: 32,2060           27042                                    CSMPREC                               #  CALCULATE CSM STATE VECTOR FOR SAME TIME
008992,000119: 32,2061           77624                           CALL                                           
008993,000120: 32,2062           64132                                    SCALEVEC                              
008994,000121: 32,2063           16207                           STODL    AGSBUFF    +6                         

Page 215

008996,000123: 32,2064           00015                                    TAT                                   
008997,000124: 32,2065           56225                           DSU      DDV                                   #  CALCULATE AND STORE THE TIME
008998,000125: 
008999,000126: 32,2066           03372                                    AGSK                                  
009000,000127: 32,2067           24175                                    TSCALE                                
009001,000128: 32,2070           02215                           STORE    AGSBUFF    +12D                       
009002,000129: 32,2071           77776                           EXIT                                           
009003,000130: 
009004,000131: 32,2072           34753                           CAF      LAGSLIST                              
009005,000132: 32,2073           54333                           TS       DNLSTCOD                              
009006,000133: 
009007,000134: 32,2074           32176                           CAF      20SEC                                 #  DELAY FOR 20 SEC WHILE THE AGS
009008,000135: 32,2075           04616                           TC       BANKCALL                              #  DOWNLIST IS TRANSMITTED
009009,000136: 32,2076           01736                           CADR     DELAYJOB                              
009010,000137: 
009011,000138: 32,2077           31321                           CA       AGSWORD                               
009012,000139: 32,2100           54333                           TS       DNLSTCOD                              #  RETURN TO THE OLD DOWNLIST
009013,000140: 32,2101           34744                           CAF      IMUSEBIT                              
009014,000141: 32,2102           70074                           MASK     FLAGWRD0                              #  CHECK IMUSE FLAG.
009015,000142: 32,2103           10000                           CCS      A                                     
009016,000143: 32,2104           02122                           TC       AGSEND                                #  IMU IS BEING USED - DO NOT ZERO
009017,000144: 32,2105           11301        CKSTALL            CCS      IMUCADR                               #  CHECK FOR IMU USAGE WHICH AVOIDS THE
009018,000145: 32,2106           12111                           TCF      +3                                    #  IMUSE BIT:  I.E., IMU COMPENSATION.
009019,000146: 32,2107           12115                           TCF      +6                                    #  FREE.  GO AHEAD WITH THE IMU ZERO.
009020,000147: 32,2110           12111                           TCF      +1                                    
009021,000148: 32,2111           34363                 +3        CAF      TEN                                   #  WAIT .1 SEC AND TRY AGAIN.
009022,000149: 32,2112           04616                           TC       BANKCALL                              
009023,000150: 32,2113           01736                           CADR     DELAYJOB                              
009024,000151: 32,2114           12105                           TCF      CKSTALL                               
009025,000152: 
009026,000153: 32,2115           04616                 +6        TC       BANKCALL                              #  IMU IS NOT IN USE
009027,000154: 32,2116           16700                           CADR     IMUZERO                               #  SET IMU ZERO DISCRETE FOR 320 MSECS
009028,000155: 32,2117           04616                           TC       BANKCALL                              #  WAIT 3 SEC FOR COUNTERS TO INCREMENT
009029,000156: 32,2120           17722                           CADR     IMUSTALL                              
009030,000157: 32,2121           02122                           TC       AGSEND                                
009031,000158: 32,2122           05527        AGSEND             TC       DOWNFLAG                              #  ALLOW V37
009032,000159: 32,2123           00054                           ADRES    NODOFLAG                              
009033,000160: 32,2124           32173                           CAF      V50N16                                
009034,000161: 32,2125           04616                           TC       BANKCALL                              
009035,000162: 32,2126           20342                           CADR     GOMARK3                               
009036,000163: 32,2127           15503                           TCF      ENDEXT                                
009037,000164: 32,2130           15503                           TCF      ENDEXT                                
009038,000165: 32,2131           05503                           TC       ENDEXT                                
009039,000166: 
009040,000167: 32,2132           64375        SCALEVEC           VLOAD    MXV                                   
009041,000168: 32,2133           00025                                    VATT1                                 
009042,000169: 32,2134           01732                                    REFSMMAT                              
009043,000170: 32,2135           72561                           VXSC     VSL2                                  
009044,000171: 32,2136           24202                                    VSCALE                                
009045,000172: 32,2137           53255                           VAD      VAD                                   #  THIS SECTION ROUNDS THE VECTOR, AND

Page 216

009047,000174: 32,2140           24204                                    AGSRND1                               #  CORRECTS FOR THE FACT THAT THE AGS
009048,000175: 32,2141           24212                                    AGSRND2                               #  IS A 2 S COMPLIMENT MACHINE WHILE THE
009049,000176: 32,2142           77634                           RTB                                            #  LGC IS A 1 S COMPLIMENT MACHINE.
009050,000177: 32,2143           21773                                    VECSGNAG                              
009051,000178: 32,2144           24025                           STOVL    VATT1                                 
009052,000179: 32,2145           00017                                    RATT1                                 
009053,000180: 32,2146           74321                           MXV      VXSC                                  
009054,000181: 32,2147           01732                                    REFSMMAT                              
009055,000182: 32,2150           24200                                    RSCALE                                
009056,000183: 32,2151           53212                           VSL8     VAD                                   #  AGAIN THIS SECTION ROUNDS.  TWO VECTORS
009057,000184: 32,2152           24204                                    AGSRND1                               #  ARE ADDED TO DEFEAT ALSIGNAG IN THE
009058,000185: 32,2153           47055                           VAD      RTB                                   #  CASE OF A HIGH-ORDER ZERO COUPLED WITH
009059,000186: 32,2154           24212                                    AGSRND2                               #  A LOW ORDER NEGATIVE PART.
009060,000187: 32,2155           21773                                    VECSGNAG                              
009061,000188: 32,2156           77750                           LXA,1                                          
009062,000189: 32,2157           00024                                    VATT1                                 
009063,000190: 32,2160           72130                           SXA,1    LXA,1                                 
009064,000191: 32,2161           00155                                    MPAC       +1                         
009065,000192: 32,2162           00026                                    VATT1      +2                         
009066,000193: 32,2163           72130                           SXA,1    LXA,1                                 
009067,000194: 32,2164           00160                                    MPAC       +4                         
009068,000195: 32,2165           00030                                    VATT1      +4                         
009069,000196: 32,2166           43530                           SXA,1    RVQ                                   
009070,000197: 32,2167           00162                                    MPAC       +6                         
009071,000198: 
009072,000199: 32,2170     4753               LAGSLIST           =        ONE                                   
009073,000200: 32,2170           00216        V01N14             VN       0114                                  
009074,000201: 32,2171           14400        V50N00A            VN       5000                                  
009075,000202: 32,2172     6010               V00N25             EQUALS   OCT31                                 
009076,000203: 32,2172           01420        V06N16             VN       0616                                  
009077,000204: 32,2173     4242               V00N34             EQUALS   34DEC                                 
009078,000205: 32,2173           14420        V50N16             VN       5016                                  
009079,000206: 32,2174           03100 00000  TSCALE             2DEC     100        B-10                       #  CSEC TO SEC SCALE FACTOR
009080,000207: 32,2176           03720        20SEC              DEC      2000       B-14                       
009081,000208: 32,2177           15077 05041  RSCALE             2DEC     3.280839   B-3                        #  METERS TO FEET SCALE FACTOR
009082,000209: 32,2201           24402 25724  VSCALE             2DEC     3.280839   E2         B-9             #  METERS/CS TO FEET/SEC SCALE FACTOR
009083,000210: 32,2203           00000 60000  AGSRND1            2OCT     0000060000                            
009084,000211: 32,2205           00000 60000                     2OCT     0000060000                            
009085,000212: 32,2207           00000 60000                     2OCT     0000060000                            
009086,000213: 32,2211           00000 37777  AGSRND2            2OCT     0000037777                            
009087,000214: 32,2213           00000 37777                     2OCT     0000037777                            
009088,000215: 32,2215           00000 37777                     2OCT     0000037777                            

Page 217

009090,000217: 32,2217  30,2000                                  SBANK=   LOWSUPER                              #  FOR SUBSEQUENT LOW 2CADRS.

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