Source Code

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

The reconstruction began with source code of Zerlina 56, Luminary 210, and Luminary 131, previously transcribed from digitized copies of those programs. The code was created by combining the three, using Zerlina 56 as a base, since it was based off of Luminary 183. The differences between the three were carefully merged using the Luminary memos as a guide, with all changes made after Luminary 178 being backed out. 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 178 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.

008904,000002:                                                                                                  ## Copyright:   Public domain.
008905,000003:                                                                                                  ## Filename:    AGS_INITIALIZATION.agc
008906,000004:                                                                                                  ## Purpose:     A section of Luminary revision 178.
008907,000005:                                                                                                  ##              It is part of the reconstructed source code for the final
008908,000006:                                                                                                  ##              release of the flight software for the Lunar Module's
008909,000007:                                                                                                  ##              (LM) Apollo Guidance Computer (AGC) for Apollo 14. The
008910,000008:                                                                                                  ##              code has been recreated from copies of Zerlina 56, Luminary
008911,000009:                                                                                                  ##              210, and Luminary 131, as well as many Luminary memos.
008912,000010:                                                                                                  ##              It has been adapted such that the resulting bugger words
008913,000011:                                                                                                  ##              exactly match those specified for Luminary 178 in NASA
008914,000012:                                                                                                  ##              drawing 2021152N, which gives relatively high confidence
008915,000013:                                                                                                  ##              that the reconstruction is correct.
008916,000014:                                                                                                  ## Reference:   pp. 213-217
008917,000015:                                                                                                  ## Assembler:   yaYUL
008918,000016:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
008919,000017:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
008920,000018:                                                                                                  ## Mod history: 2019-08-14 MAS  Created from Zerlina 56.
008921,000019: 

Page 213

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

Page 214

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

Page 215

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

Page 216

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

Page 217

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

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