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.

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

Page 218

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

Page 219

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

Page 220

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

Page 221

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

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