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.

008449,000002:                                                                                                  ## Copyright:   Public domain.
008450,000003:                                                                                                  ## Filename:    AGS_INITIALIZATION.agc
008451,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
008452,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM) 
008453,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
008454,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
008455,000008:                                                                                                  ##              that the code format has been changed to conform to the
008456,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
008457,000010:                                                                                                  ##              original YUL assembler.
008458,000011:                                                                                                  ## Reference:   pp. 207-211
008459,000012:                                                                                                  ## Assembler:   yaYUL
008460,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
008461,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
008462,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
008463,000016:                                                                                                  ##              2017-02-10 NV   Updated for Luminary 116.
008464,000017:                                                                                                  ##              2017-03-01 RSB  Proofed comment text by diff vs Luminary 131
008465,000018:                                                                                                  ##                              and fixed error found.
008466,000019: 

Page 207

008468,000021: 
008469,000022:                                                                                                  #  PROGRAM NAME:  AGS INITIALIZATION (R47)
008470,000023: 
008471,000024:                                                                                                  #  WRITTEN BY:  RHODE/KILROY/FOLLETT
008472,000025: 
008473,000026:                                                                                                  #  MOD NO. :     0
008474,000027:                                                                                                  #  DATE:         23 MARCH 1967
008475,000028:                                                                                                  #  MOD BY:       KILROY
008476,000029: 
008477,000030:                                                                                                  #  MOD NO.:      1
008478,000031:                                                                                                  #  DATE:         28 OCTOBER 1967
008479,000032:                                                                                                  #  MOD BY:       FOLLETT
008480,000033: 
008481,000034:                                                                                                  #  FUNCT. DESC.: (1) TO PROVIDE THE AGS ABORT ELECTRONICS ASSEMBLY (AEA) WITH THE LEM AND CSM STATE VECTORS
008482,000035:                                                                                                  #                (POSITION,VELOCITY,TIME) IN LEM IMU COORDINATES BY MEANS OF THE LGC DIGITAL DOWNLINK.
008483,000036: 
008484,000037:                                                                                                  #                (2) TO ZERO THE ICDU, LGC AND AEA GIMBAL ANGLE COUNTERS SIMULTANEOUSLY IN ORDER TO ESTABLISH A
008485,000038:                                                                                                  #                COMMON ZERO REFERENCE FOR THE MEASUREMENT OF GIMBAL (EULER) ANGLES WHICH DEFINE LEM ATTITUDE
008486,000039: 
008487,000040:                                                                                                  #                (3) TO ESTABLISH THE GROUND ELAPSED TIME OF AEA CLOCK ZERO.  (IF AN AEA CLOCK ZERO IS
008488,000041:                                                                                                  #                REQUESTED DURING THIS PROGRAM
008489,000042: 
008490,000043:                                                                                                  #  LOG SECTION:  AGS INITIALIZATION
008491,000044: 
008492,000045:                                                                                                  #  CALLING SEQ:  PROGRAM IS ENTERED WHEN ASTRONAUT KEYS V47E ON DSKY.
008493,000046:                                                                                                  #                R47 MAY BE CALLED AT ANY TIME EXCEPT WHEN ANOTHER EXTENDED VERB IS IN PROGRESS
008494,000047: 
008495,000048:                                                                                                  #  SUBROUTINES
008496,000049:                                                                                                  #  CALLED:
008497,000050: 
008498,000051:                                                                                                  #  NORMAL EXIT:  ENDEXT
008499,000052: 
008500,000053:                                                                                                  #  ALARM/ABORT:  ALARM - BAD REFSMMAT - CODE:220
008501,000054:                                                                                                  #                OPERATOR ERROR IF V47 SELECTED DURING ANOTHER EXTENDED VERB.
008502,000055: 
008503,000056:                                                                                                  #  ERASABLES
008504,000057:                                                                                                  #  USED:         SAMPTIME        (2)     TIME OF :ENTER: KEYSTROKE
008505,000058:                                                                                                  #                AGSK            (2)     GROUND ELAPSED TIME OF THE AEA CLOCK :ZERO:
008506,000059:                                                                                                  #                AGSBUFF         (140)   CONTAINS AGS INITIALIZATION DATA (SEE :OUTPUT: BELOW)
008507,000060:                                                                                                  #                AGSWORD         (1)     PREVIOUS DOWNLIST SAVED HERE
008508,000061: 
008509,000062: 05,2447  E4,1600                                  EBANK=   AGSBUFF                               
008510,000063: 
008511,000064: 40,2000                                           BANK     40                                    
008512,000065: 32,2000                                           SETLOC   R47                                   
008513,000066: 32,2000                                           BANK                                           
008514,000067: 
008515,000068: 32,2005                                           COUNT*   $$/R47                                
008516,000069: 
008517,000070: 32,2005           34737        AGSINIT            CAF      REFSMBIT                              
008518,000071: 32,2006           70077                           MASK     FLAGWRD3                              #  CHECK REFSMFLG.
008519,000072: 32,2007           10000                           CCS      A                                     

Page 208

008521,000074: 32,2010           02017                           TC       REDSPTEM                              #  REFSMMAT IS OK
008522,000075: 32,2011           05567                           TC       ALARM                                 #  REFSMMAT IS BAD
008523,000076: 32,2012           00220                           OCT      220                                   
008524,000077: 32,2013           05472                           TC       ENDEXT                                
008525,000078: 
008526,000079: 32,2014           00006        NEWAGS             EXTEND                                         
008527,000080: 32,2015           30014                           DCA      SAMPTIME                              #  TIME OF THE :ENTER: KEYSTROKE
008528,000081: 32,2016           53421                           DXCH     AGSK                                  #  BECOMES NEW AEA CLOCK :ZERO:
008529,000082: 
008530,000083: 32,2017           00006        REDSPTEM           EXTEND                                         
008531,000084: 32,2020           31421                           DCA      AGSK                                  
008532,000085: 32,2021           53051                           DXCH     DSPTEMX                               
008533,000086: 32,2022           32172        AGSDISPK           CAF      V06N16                                
008534,000087: 32,2023           04616                           TC       BANKCALL                              #  R1 = 00XXX. HRS., R2 = 000XX MIN.,
008535,000088: 32,2024           20334                           CADR     GOMARKF                               #  R3 = 0XX.XX SEC.
008536,000089: 32,2025           05472                           TC       ENDEXT                                #  TERMINATE RETURN
008537,000090: 32,2026           02036                           TC       AGSVCALC                              #  PROCEED RETURN
008538,000091: 32,2027           44746                           CS       BIT6                                  #  IS ENTER VIA A V32
008539,000092: 32,2030           60154                           AD       MPAC                                  
008540,000093: 32,2031           00006                           EXTEND                                         
008541,000094: 32,2032           12014                           BZF      NEWAGS                                #  YES, USE KEYSTROKE TIME FOR NEW AGSK
008542,000095: 
008543,000096: 32,2033           00006                           EXTEND                                         #  NO, NEW AGSK LOADED VIA V25
008544,000097: 32,2034           31051                           DCA      DSPTEMX                               #  LOADED INTO DSPTEMX BY KEYING
008545,000098: 32,2035           02016                           TC       REDSPTEM   -1                         #  V25E FOLLOWED BY HRS.,MINS.,SECS.
008546,000099:                                                                                                  #  DISPLAY THE NEW K
008547,000100: 
008548,000101: 32,2036           06042        AGSVCALC           TC       INTPRET                               
008549,000102: 32,2037           77614                           SET                                            
008550,000103: 32,2040           01076                                    NODOFLAG                              #  DONT ALLOW V37
008551,000104: 32,2041           77414                           SET      EXIT                                  
008552,000105: 32,2042           02076                                    XDSPFLAG                              
008553,000106: 
008554,000107: 32,2043           32172                           CAF      V06N16                                
008555,000108: 32,2044           04616                           TC       BANKCALL                              
008556,000109: 32,2045           20621                           CADR     EXDSPRET                              
008557,000110: 
008558,000111: 32,2046           06042                           TC       INTPRET                               #  EXTRAPOLATE LEM AND CSM STATE VECTORS
008559,000112: 32,2047           77634                           RTB                                            #  TO THE PRESENT TIME
008560,000113: 32,2050           21574                                    LOADTIME                              #  LOAD MPAC WITH TIME2,TIME1
008561,000114: 32,2051           34041                           STCALL   TDEC1                                 #  CALCULATE LEM STATE VECTOR
008562,000115: 32,2052           27060                                    LEMPREC                               
008563,000116: 32,2053           77624                           CALL                                           #  CALL ROUTINE TO CONVERT TO SM COORDS AND
008564,000117: 32,2054           64132                                    SCALEVEC                              #  PROVIDE PROPER SCALING
008565,000118: 32,2055           16201                           STODL    AGSBUFF                               #  (LEMPREC AND CSMPREC LEAVE TDEC1 IN TAT)
008566,000119: 32,2056           00015                                    TAT                                   #  TAT = TIME TO WHICH RATT1 AND VATT1 ARE
008567,000120: 32,2057           34041                           STCALL   TDEC1                                 #  COMPUTED (CSEC SINCE CLOCK START B-28).
008568,000121: 32,2060           27044                                    CSMPREC                               #  CALCULATE CSM STATE VECTOR FOR SAME TIME
008569,000122: 32,2061           77624                           CALL                                           
008570,000123: 32,2062           64132                                    SCALEVEC                              

Page 209

008572,000125: 32,2063           16207                           STODL    AGSBUFF    +6                         
008573,000126: 32,2064           00015                                    TAT                                   
008574,000127: 32,2065           56225                           DSU      DDV                                   #  CALCULATE AND STORE THE TIME
008575,000128: 32,2066           02021                                    AGSK                                  
008576,000129: 32,2067           24175                                    TSCALE                                
008577,000130: 32,2070           02215                           STORE    AGSBUFF    +12D                       
008578,000131: 32,2071           77776                           EXIT                                           
008579,000132: 
008580,000133: 32,2072           34753                           CAF      LAGSLIST                              
008581,000134: 32,2073           54333                           TS       DNLSTCOD                              
008582,000135: 
008583,000136: 32,2074           32176                           CAF      20SEC                                 #  DELAY FOR 20 SEC WHILE THE AGS
008584,000137: 32,2075           04616                           TC       BANKCALL                              #  DOWNLIST IS TRANSMITTED
008585,000138: 32,2076           01736                           CADR     DELAYJOB                              
008586,000139: 
008587,000140: 32,2077           31321                           CA       AGSWORD                               
008588,000141: 32,2100           54333                           TS       DNLSTCOD                              #  RETURN TO THE OLD DOWNLIST
008589,000142: 32,2101           34744                           CAF      IMUSEBIT                              
008590,000143: 32,2102           70074                           MASK     FLAGWRD0                              #  CHECK IMUSE FLAG.
008591,000144: 32,2103           10000                           CCS      A                                     
008592,000145: 32,2104           02122                           TC       AGSEND                                #  IMU IS BEING USED - DO NOT ZERO
008593,000146: 32,2105           11301        CKSTALL            CCS      IMUCADR                               #  CHECK FOR IMU USAGE WHICH AVOIDS THE
008594,000147: 32,2106           12111                           TCF      +3                                    #  IMUSE BIT:  I.E., IMU COMPENSATION.
008595,000148: 32,2107           12115                           TCF      +6                                    #  FREE.  GO AHEAD WITH THE IMU ZERO.
008596,000149: 32,2110           12111                           TCF      +1                                    
008597,000150: 32,2111           34363                 +3        CAF      TEN                                   #  WAIT .1 SEC AND TRY AGAIN.
008598,000151: 32,2112           04616                           TC       BANKCALL                              
008599,000152: 32,2113           01736                           CADR     DELAYJOB                              
008600,000153: 32,2114           12105                           TCF      CKSTALL                               
008601,000154: 
008602,000155: 32,2115           04616                 +6        TC       BANKCALL                              #  IMU IS NOT IN USE
008603,000156: 32,2116           16706                           CADR     IMUZERO                               #  SET IMU ZERO DISCRETE FOR 320MSECS
008604,000157: 32,2117           04616                           TC       BANKCALL                              #  WAIT 3 SEC FOR COUNTERS TO INCREMENT
008605,000158: 32,2120           17710                           CADR     IMUSTALL                              
008606,000159: 32,2121           02122                           TC       AGSEND                                
008607,000160: 32,2122           05516        AGSEND             TC       DOWNFLAG                              #  ALLOW V37
008608,000161: 32,2123           00054                           ADRES    NODOFLAG                              
008609,000162: 
008610,000163: 32,2124           32173                           CAF      V50N16                                
008611,000164: 32,2125           04616                           TC       BANKCALL                              
008612,000165: 32,2126           20342                           CADR     GOMARK3                               
008613,000166: 32,2127           15472                           TCF      ENDEXT                                
008614,000167: 32,2130           15472                           TCF      ENDEXT                                
008615,000168: 32,2131           05472                           TC       ENDEXT                                
008616,000169: 
008617,000170: 32,2132           64375        SCALEVEC           VLOAD    MXV                                   
008618,000171: 32,2133           00025                                    VATT1                                 
008619,000172: 32,2134           01734                                    REFSMMAT                              
008620,000173: 32,2135           72561                           VXSC     VSL2                                  
008621,000174: 32,2136           24202                                    VSCALE                                

Page 210

008623,000176: 32,2137           53255                           VAD      VAD                                   #  THIS SECTION ROUNDS THE VECTOR, AND
008624,000177: 32,2140           24204                                    AGSRND1                               #  CORRECTS FOR THE FACT THAT THE AGS
008625,000178: 32,2141           24212                                    AGSRND2                               #  IS A 2 S COMPLIMENT MACHINE WHILE THE
008626,000179: 32,2142           77634                           RTB                                            #  LGC IS A 1 S COMPLIMENT MACHINE.
008627,000180: 32,2143           21773                                    VECSGNAG                              
008628,000181: 32,2144           24025                           STOVL    VATT1                                 
008629,000182: 32,2145           00017                                    RATT1                                 
008630,000183: 32,2146           74321                           MXV      VXSC                                  
008631,000184: 32,2147           01734                                    REFSMMAT                              
008632,000185: 32,2150           24200                                    RSCALE                                
008633,000186: 32,2151           53212                           VSL8     VAD                                   #  AGAIN THIS SECTION ROUNDS.  TWO VECTORS
008634,000187: 32,2152           24204                                    AGSRND1                               #  ARE ADDED TO DEFEAT ALSIGNAG IN THE
008635,000188: 32,2153           47055                           VAD      RTB                                   #  CASE OF A HIGH-ORDER ZERO COUPLED WITH
008636,000189: 32,2154           24212                                    AGSRND2                               #  A LOW ORDER NEGATIVE PART.
008637,000190: 32,2155           21773                                    VECSGNAG                              
008638,000191: 32,2156           77750                           LXA,1                                          
008639,000192: 32,2157           00024                                    VATT1                                 
008640,000193: 32,2160           72130                           SXA,1    LXA,1                                 
008641,000194: 32,2161           00155                                    MPAC       +1                         
008642,000195: 32,2162           00026                                    VATT1      +2                         
008643,000196: 32,2163           72130                           SXA,1    LXA,1                                 
008644,000197: 32,2164           00160                                    MPAC       +4                         
008645,000198: 32,2165           00030                                    VATT1      +4                         
008646,000199: 32,2166           43530                           SXA,1    RVQ                                   
008647,000200: 32,2167           00162                                    MPAC       +6                         
008648,000201: 
008649,000202: 32,2170     4753               LAGSLIST           =        ONE                                   
008650,000203: 32,2170           00216        V01N14             VN       0114                                  
008651,000204: 32,2171           14400        V50N00A            VN       5000                                  
008652,000205: 32,2172     6010               V00N25             EQUALS   OCT31                                 
008653,000206: 32,2172           01420        V06N16             VN       0616                                  
008654,000207: 32,2173     4242               V00N34             EQUALS   34DEC                                 
008655,000208: 32,2173           14420        V50N16             VN       5016                                  
008656,000209: 32,2174           03100 00000  TSCALE             2DEC     100        B-10                       #  CSEC TO SEC SCALE FACTOR
008657,000210: 32,2176           03720        20SEC              DEC      2000       B-14                       
008658,000211: 32,2177           15077 05041  RSCALE             2DEC     3.280839   B-3                        #  METERS TO FEET SCALE FACTOR
008659,000212: 32,2201           24402 25724  VSCALE             2DEC     3.280839   E2         B-9             #  METERS/CS TO FEET/SEC SCALE FACTOR
008660,000213: 32,2203           00000 60000  AGSRND1            2OCT     0000060000                            
008661,000214: 32,2205           00000 60000                     2OCT     0000060000                            
008662,000215: 32,2207           00000 60000                     2OCT     0000060000                            
008663,000216: 32,2211           00000 37777  AGSRND2            2OCT     0000037777                            
008664,000217: 32,2213           00000 37777                     2OCT     0000037777                            

Page 211

008666,000219: 32,2215           00000 37777                     2OCT     0000037777                            
008667,000220: 
008668,000221: 32,2217  30,2000                                  SBANK=   LOWSUPER                              #  FOR SUBSEQUENT LOW 2CADRS.
008669,000222: 

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