Source Code

These source-code files derive from a printout of Luminary 210 (Apollo 15-17 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Jim Lawton, 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 210 OF AGC PROGRAM LUMINARY 
	BY NASA 2021112-161 17:11 MAR. 19,1971
Note that the date is the date of the printout, not the date of the program revision.

009341,000002:                                                                                                  ## Copyright:   Public domain.
009342,000003:                                                                                                  ## Filename:    AGS_INITIALIZATION.agc
009343,000004:                                                                                                  ## Purpose:     A section of Luminary revision 210.
009344,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
009345,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 15-17.
009346,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
009347,000008:                                                                                                  ##              that the code format has been changed to conform to the
009348,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
009349,000010:                                                                                                  ##              original YUL assembler.
009350,000011:                                                                                                  ## Reference:   pp. 218-221
009351,000012:                                                                                                  ## Assembler:   yaYUL
009352,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
009353,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
009354,000015:                                                                                                  ## Mod history: 2016-11-17 JL   Created from Luminary131 version.
009355,000016:                                                                                                  ##              2016-11-22 HG   Transcribed
009356,000017:                                                                                                  ##              2016-12-23 RSB  Proofed comment text with octopus/ProoferComments
009357,000018:                                                                                                  ##                              and fixed all errors found.
009358,000019: 

Page 218

009360,000021: 
009361,000022:                                                                                                  #  PROGRAM NAME:   AGS INITIALIZATION (R47)
009362,000023: 
009363,000024:                                                                                                  #  WRITTEN BY  :   RHODE/KILROY/FOLLETT
009364,000025: 
009365,000026:                                                                                                  #  MOD NO. :       0
009366,000027:                                                                                                  #  DATE    :       23 MARCH 1967
009367,000028:                                                                                                  #  MOD BY  :       KILROY
009368,000029: 
009369,000030:                                                                                                  #  MOD NO. :       1
009370,000031:                                                                                                  #  DATE    :       28 OCTOBER 1967
009371,000032:                                                                                                  #  MOD BY  :       FOLLETT
009372,000033: 
009373,000034:                                                                                                  #  FUNCT. DESC.:   (1) TO PROVIDE THE AGS ABORT ELECTRONICS ASSEMBLY(AEA) WITH THE LEM AND CSM STATE VECTORS
009374,000035:                                                                                                  #                  (POSITION,VELOCITY,TIME) IN LEM IMU COORDINATES BY MEANS OF THE LGC DIGITAL DOWNLINK.
009375,000036: 
009376,000037:                                                                                                  #                  (2) TO ZERO THE ICDU, LGC AND AEA GIMBAL ANGLE COUNTERS SIMULTANEOUSLY IN ORDER TO ESTABLISH A
009377,000038:                                                                                                  #                  COMMON ZERO REFERENCE FOR THE MEASUREMENT OF GIMBAL(EULER) ANGLES WHICH DEFINE LEM ATTITUDE
009378,000039:                                                                                                  #                  (3) TO ESTABLISH THE GROUND ELAPSED TIME OF AEA CLOCK ZERO.(IF AN AEA CLOCK ZERO IS
009379,000040:                                                                                                  #                  REQUESTED DURING THIS PROGRAM
009380,000041: 
009381,000042:                                                                                                  #  LOG SECTION :   AGS INITIALIZATION
009382,000043: 
009383,000044:                                                                                                  #  CALLING SEQ :   PROGRAM IS ENTERED WHEN ASTRONAUT KEYS V47E ON DSKY.
009384,000045:                                                                                                  #                  R47 MAY BE CALLED AT ANY TIME EXCEPT WHEN ANOTHER EXTENDED VERB IS IN PROGRESS
009385,000046: 
009386,000047:                                                                                                  #  SUBROUTINES
009387,000048:                                                                                                  #  CALLED      :
009388,000049: 
009389,000050:                                                                                                  #  NORMAL EXIT :  ENDEXT
009390,000051: 
009391,000052:                                                                                                  #  ALARM/ABORT :  ALARM - BAD REFSMMAT - CODE:220
009392,000053:                                                                                                  #                 OPERATOR ERROR IF V47 SELECTED DURING ANOTHER EXTENDED VERB.
009393,000054: 
009394,000055:                                                                                                  #  ERASABLES
009395,000056:                                                                                                  #  USED        :  SAMPTIME    (2) TIME OF :ENTER: KEYSTROKE
009396,000057:                                                                                                  #                 AGSK        (2) GROUND ELAPSED TIME OF THE AEA CLOCK :ZERO:
009397,000058:                                                                                                  #                 AGSBUFF   (140) CONTAINS AGS INITIALIZATION DATA (SEE :OUTPUT: BELOW)
009398,000059:                                                                                                  #                 AGSWORD     (1) PREVIOUS DOWNLIST SAVED HERE
009399,000060: 
009400,000061: 05,2454  E6,1771                                  EBANK=   AGSK                                  
009401,000062: 40,2000                                           BANK     40                                    
009402,000063: 32,2000                                           SETLOC   R47                                   
009403,000064: 32,2000                                           BANK                                           
009404,000065: 
009405,000066: 32,2005                                           COUNT*   $$/R47                                
009406,000067: 
009407,000068: 32,2005           34730        AGSINIT            CAF      REFSMBIT                              
009408,000069: 32,2006           70077                           MASK     FLAGWRD3                              #  CHECK REFSMFLG.
009409,000070: 32,2007           10000                           CCS      A                                     
009410,000071: 32,2010           02017                           TC       REDSPTEM                              #  REFSMMAT IS OK
009411,000072: 

Page 219

009413,000074: 
009414,000075: 32,2011           05571                           TC       ALARM                                 #  REFSMMAT IS BAD
009415,000076: 32,2012           00220                           OCT      220                                   
009416,000077: 32,2013           05474                           TC       ENDEXT                                
009417,000078: 
009418,000079: 32,2014           00006        NEWAGS             EXTEND                                         
009419,000080: 32,2015           30014                           DCA      SAMPTIME                              #  TIME OF THE :ENTER: KEYSTROKE
009420,000081: 32,2016           53772                           DXCH     AGSK                                  #  BECOMES NEW AEA CLOCK :ZERO:
009421,000082: 
009422,000083: 32,2017           00006        REDSPTEM           EXTEND                                         
009423,000084: 32,2020           31772                           DCA      AGSK                                  
009424,000085: 32,2021           53051                           DXCH     DSPTEMX                               
009425,000086: 32,2022           32166        AGSDISPK           CAF      V06N16                                
009426,000087: 32,2023           04607                           TC       BANKCALL                              #  R1 = 00XXX. HRS., R2 = 000XX MIN.,
009427,000088: 32,2024           20323                           CADR     GOMARKF                               #  R3 = 0XX.XX SEC.
009428,000089: 32,2025           05474                           TC       ENDEXT                                #  TERMINATE RETURN
009429,000090: 32,2026           02036                           TC       AGSVCALC                              #  PROCEED RETURN
009430,000091: 32,2027           44737                           CS       BIT6                                  #  IS ENTER VIA A V32
009431,000092: 32,2030           60154                           AD       MPAC                                  
009432,000093: 32,2031           00006                           EXTEND                                         
009433,000094: 32,2032           12014                           BZF      NEWAGS                                #  YES, USE KEYSTROKE TIME FOR NEW AGSK
009434,000095: 
009435,000096: 32,2033           00006                           EXTEND                                         #  NO, NEW AGSK LOADED VIA V25
009436,000097: 32,2034           31051                           DCA      DSPTEMX                               #  LOADED INTO DSPTEMX BY KEYING
009437,000098: 32,2035           02016                           TC       REDSPTEM   -1                         #  V25E FOLLOWED BY HRS.,MINS.,SECS.
009438,000099:                                                                                                  #  DISPLAY THE NEW K
009439,000100: 
009440,000101: 32,2036           06060        AGSVCALC           TC       INTPRET                               
009441,000102: 32,2037           77414                           SET      EXIT                                  
009442,000103: 32,2040           02076                                    XDSPFLAG                              
009443,000104: 
009444,000105: 32,2041           32166                           CAF      V06N16                                
009445,000106: 32,2042           04607                           TC       BANKCALL                              
009446,000107: 32,2043           20632                           CADR     EXDSPRET                              
009447,000108: 
009448,000109: 32,2044           06060                           TC       INTPRET                               #  EXTRAPOLATE LEM AND CSM STATE VECTORS
009449,000110: 32,2045           77634                           RTB                                            #  TO THE PRESENT TIME
009450,000111: 32,2046           21603                                    LOADTIME                              #  LOAD MPAC WITH TIME2,TIME1
009451,000112: 32,2047           34041                           STCALL   TDEC1                                 #  CALCULATE LEM STATE VECTOR
009452,000113: 32,2050           27115                                    LEMPREC                               
009453,000114: 32,2051           77624                           CALL                                           #  CALL ROUTINE TO CONVERT TO SM COORDS AND
009454,000115: 32,2052           64126                                    SCALEVEC                              #  PROVIDE PROPER SCALING
009455,000116: 32,2053           16172                           STODL    AGSBUFF                               #  (LEMPREC AND CSMPREC LEAVE TDEC1 IN TAT)
009456,000117: 32,2054           00015                                    TAT                                   #  TAT = TIME TO WHICH RATT1 AND VATT1 ARE
009457,000118: 32,2055           34041                           STCALL   TDEC1                                 #  COMPUTED(CSEC SINCE CLOCK START B-28).
009458,000119: 32,2056           27101                                    CSMPREC                               #  CALCULATE CSM STATE VECTOR FOR SAME TIME
009459,000120: 32,2057           77624                           CALL                                           
009460,000121: 32,2060           64126                                    SCALEVEC                              
009461,000122: 32,2061           16200                           STODL    AGSBUFF    +6                         
009462,000123: 32,2062           00015                                    TAT                                   
009463,000124: 32,2063           56225                           DSU      DDV                                   #  CALCULATE AND STORE THE TIME
009464,000125: 

Page 220

009466,000127: 32,2064           03372                                    AGSK                                  
009467,000128: 32,2065           24171                                    TSCALE                                
009468,000129: 32,2066           02206                           STORE    AGSBUFF    +12D                       
009469,000130: 32,2067           77776                           EXIT                                           
009470,000131: 
009471,000132: 32,2070           34744                           CAF      LAGSLIST                              
009472,000133: 32,2071           54333                           TS       DNLSTCOD                              
009473,000134: 
009474,000135: 32,2072           32172                           CAF      20SEC                                 #  DELAY FOR 20 SEC WHILE THE AGS
009475,000136: 32,2073           04607                           TC       BANKCALL                              #  DOWNLIST IS TRANSMITTED
009476,000137: 32,2074           01736                           CADR     DELAYJOB                              
009477,000138: 
009478,000139: 32,2075           31321                           CA       AGSWORD                               
009479,000140: 32,2076           54333                           TS       DNLSTCOD                              #  RETURN TO THE OLD DOWNLIST
009480,000141: 32,2077           34735                           CAF      IMUSEBIT                              
009481,000142: 32,2100           70074                           MASK     FLAGWRD0                              #  CHECK IMUSE FLAG.
009482,000143: 32,2101           10000                           CCS      A                                     
009483,000144: 32,2102           02120                           TC       AGSEND                                #  IMU IS BEING USED - DO NOT ZERO
009484,000145: 32,2103           11301        CKSTALL            CCS      IMUCADR                               #  CHECK FOR IMU USAGE WHICH AVOIDS THE
009485,000146: 32,2104           12107                           TCF      +3                                    #  IMUSE BIT:  I.E., IMU COMPENSATION.
009486,000147: 32,2105           12113                           TCF      +6                                    #  FREE.  GO AHEAD WITH THE IMU ZERO.
009487,000148: 32,2106           12107                           TCF      +1                                    
009488,000149: 32,2107           34354                 +3        CAF      TEN                                   #  WAIT .1 SEC AND TRY AGAIN.
009489,000150: 32,2110           04607                           TC       BANKCALL                              
009490,000151: 32,2111           01736                           CADR     DELAYJOB                              
009491,000152: 32,2112           12103                           TCF      CKSTALL                               
009492,000153: 
009493,000154: 32,2113           04607                 +6        TC       BANKCALL                              #  IMU IS NOT IN USE
009494,000155: 32,2114           16701                           CADR     IMUZERO                               #  SET IMU ZERO DISCRETE FOR 320 MSECS
009495,000156: 32,2115           04607                           TC       BANKCALL                              #  WAIT 3 SEC FOR COUNTERS TO INCREMENT
009496,000157: 32,2116           17735                           CADR     IMUSTALL                              
009497,000158: 32,2117           02120                           TC       AGSEND                                
009498,000159: 32,2120           32167        AGSEND             CAF      V50N16                                
009499,000160: 32,2121           04607                           TC       BANKCALL                              
009500,000161: 32,2122           20334                           CADR     GOMARK3                               
009501,000162: 32,2123           15474                           TCF      ENDEXT                                
009502,000163: 32,2124           15474                           TCF      ENDEXT                                
009503,000164: 32,2125           05474                           TC       ENDEXT                                
009504,000165: 
009505,000166: 32,2126           64375        SCALEVEC           VLOAD    MXV                                   
009506,000167: 32,2127           00025                                    VATT1                                 
009507,000168: 32,2130           01732                                    REFSMMAT                              
009508,000169: 32,2131           72561                           VXSC     VSL2                                  
009509,000170: 32,2132           24176                                    VSCALE                                
009510,000171: 32,2133           53255                           VAD      VAD                                   #  THIS SECTION ROUNDS THE VECTOR, AND
009511,000172: 32,2134           24200                                    AGSRND1                               #  CORRECTS FOR THE FACT THAT THE AGS
009512,000173: 32,2135           24206                                    AGSRND2                               #  IS A 2 S COMPLIMENT MACHINE WHILE THE
009513,000174: 32,2136           77634                           RTB                                            #  LGC IS A 1 S COMPLIMENT MACHINE.
009514,000175: 32,2137           21770                                    VECSGNAG                              
009515,000176: 32,2140           24025                           STOVL    VATT1                                 
009516,000177: 

Page 221

009518,000179: 32,2141           00017                                    RATT1                                 
009519,000180: 32,2142           74321                           MXV      VXSC                                  
009520,000181: 32,2143           01732                                    REFSMMAT                              
009521,000182: 32,2144           24174                                    RSCALE                                
009522,000183: 32,2145           53212                           VSL8     VAD                                   #  AGAIN THIS SECTION ROUNDS.  TWO VECTORS
009523,000184: 32,2146           24200                                    AGSRND1                               #  ARE ADDED TO DEFEAT ALSIGNAG IN THE
009524,000185: 32,2147           47055                           VAD      RTB                                   #  CASE OF A HIGH-ORDER ZERO COUPLED WITH
009525,000186: 32,2150           24206                                    AGSRND2                               #  A LOW ORDER NEGATIVE PART.
009526,000187: 32,2151           21770                                    VECSGNAG                              
009527,000188: 32,2152           77750                           LXA,1                                          
009528,000189: 32,2153           00024                                    VATT1                                 
009529,000190: 32,2154           72130                           SXA,1    LXA,1                                 
009530,000191: 32,2155           00155                                    MPAC       +1                         
009531,000192: 32,2156           00026                                    VATT1      +2                         
009532,000193: 32,2157           72130                           SXA,1    LXA,1                                 
009533,000194: 32,2160           00160                                    MPAC       +4                         
009534,000195: 32,2161           00030                                    VATT1      +4                         
009535,000196: 32,2162           43530                           SXA,1    RVQ                                   
009536,000197: 32,2163           00162                                    MPAC       +6                         
009537,000198: 
009538,000199: 32,2164     4744               LAGSLIST           =        ONE                                   
009539,000200: 32,2164           00216        V01N14             VN       0114                                  
009540,000201: 32,2165           14400        V50N00A            VN       5000                                  
009541,000202: 32,2166     6010               V00N25             EQUALS   OCT31                                 
009542,000203: 32,2166           01420        V06N16             VN       0616                                  
009543,000204: 32,2167     4233               V00N34             EQUALS   34DEC                                 
009544,000205: 32,2167           14420        V50N16             VN       5016                                  
009545,000206: 32,2170           03100 00000  TSCALE             2DEC     100        B-10                       #  CSEC TO SEC SCALE FACTOR
009546,000207: 32,2172           03720        20SEC              DEC      2000       B-14                       
009547,000208: 32,2173           15077 05041  RSCALE             2DEC     3.280839   B-3                        #  METERS TO FEET SCALE FACTOR
009548,000209: 32,2175           24402 25724  VSCALE             2DEC     3.280839   E2         B-9             #  METERS/CS TO FEET/SEC SCALE FACTOR
009549,000210: 32,2177           00000 60000  AGSRND1            2OCT     0000060000                            
009550,000211: 32,2201           00000 60000                     2OCT     0000060000                            
009551,000212: 32,2203           00000 60000                     2OCT     0000060000                            
009552,000213: 32,2205           00000 37777  AGSRND2            2OCT     0000037777                            
009553,000214: 32,2207           00000 37777                     2OCT     0000037777                            
009554,000215: 32,2211           00000 37777                     2OCT     0000037777                            
009555,000216: 32,2213  30,2000                                  SBANK=   LOWSUPER                              #  FOR SUBSEQUENT LOW 2CADRS.

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