Source Code

This source code is very close to the Apollo Guidance Computer software for the Apollo 13 Lunar module. This revision of the Luminary 131 program is from December of 1969, whereas there was a later revision in January of 1970, and still another revision in February, which is the code that flew on the mission. As far as this transcription is concerned, it was originally from a copy made in 1991 of a printout from the collection of AGC developer Don Eyles for collector David Craig. It was subsequently scanned by Gary Neff, reprocessed for online presentation at the now-discontinued History of Recent Science and Technology (HRST) website of MIT's Dibner Institute (the full-quality scans being discarded in the process), and finally transcribed by Ron Burkey for the Virtual AGC Project. Although a high-quality replacement scan for a completely illegible page was later provided by Gary Neff, the reduced legibility of the reprocessed HRST posting nevertheless caused many errors to be introduced into the transcription. Accordingly, a second scan of the same physical printout was made in 2017 for the Virtual AGC Project's collection at the Internet Archive, and used to correct the transcription errors. All of the scanned materials mentioned, as well as other Luminary 131 related material, are available online. Don Eyles apprently made additional hand-written notes in printout between 1991 and 2017, so the two scans are not identical in that respect. The page-headings in the printout read, in part:
	GAP:  ASSEMBLE REVISION 131 OF AGC PROGRAM LUMINARY BY NASA 2021112-091
	17:53 DEC. 19, 1969
Note that the date is the date the printout was made, not the date on which the program revision was released, although these happen to be very close together.

008304,000002:                                                                                                  ## Copyright:   Public domain.
008305,000003:                                                                                                  ## Filename:    AGS_INITIALIZATION.agc
008306,000004:                                                                                                  ## Purpose:     A section of Luminary 1C, revision 131.
008307,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
008308,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13.
008309,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
008310,000008:                                                                                                  ##              that the code format has been changed to conform to the
008311,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the 
008312,000010:                                                                                                  ##              original YUL assembler.
008313,000011:                                                                                                  ## Reference:   pp. 208-212
008314,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
008315,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
008316,000014:                                                                                                  ## Mod history: 05/05/03 RSB.   Began transcribing.
008317,000015:                                                                                                  ##              05/14/05 RSB    Corrected website reference above.
008318,000016:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
008319,000017:                                                                                                  ##                              original harcopy, as opposed to the PDF page
008320,000018:                                                                                                  ##                              numbers in 1701.pdf.
008321,000019:                                                                                                  ##              2017-02-22 RSB  Proofed comment text using octopus/ProoferComments.
008322,000020: 

Page 208

008324,000022: 
008325,000023:                                                                                                  #  PROGRAM NAME:  AGS INITIALIZATION (R47)
008326,000024: 
008327,000025:                                                                                                  #  WRITTEN BY:  RHODE/KILROY/FOLLETT
008328,000026: 
008329,000027:                                                                                                  #  MOD NO.:      0
008330,000028:                                                                                                  #  DATE:         23 MARCH 1967
008331,000029:                                                                                                  #  MOD BY:       KILROY
008332,000030: 
008333,000031:                                                                                                  #  MOD NO.:      1
008334,000032:                                                                                                  #  DATE:         28 OCTOBER 1967
008335,000033:                                                                                                  #  MOD BY:       FOLLETT
008336,000034: 
008337,000035:                                                                                                  #  FUNCT. DESC.: (1) TO PROVIDE THE AGS ABORT ELECTRONICS ASSEMBLY (AEA) WITH THE LEM AND CSM STATE VECTORS
008338,000036:                                                                                                  #                (POSITION,VELOCITY,TIME) IN LEM IMU COORDINATES BY MEANS OF THE LGC DIGITAL DOWNLINK.
008339,000037: 
008340,000038:                                                                                                  #                (2) TO ZERO THE ICDU, LGC AND AEA GIMBAL ANGLE COUNTERS SIMULTANEOUSLY IN ORDER TO ESTABLISH A
008341,000039:                                                                                                  #                COMMON ZERO REFERENCE FOR THE MEASUREMENT OF GIMBAL (EULER) ANGLES WHICH DEFINE LEM ATTITUDE
008342,000040: 
008343,000041:                                                                                                  #                (3) TO ESTABLISH THE GROUND ELAPSED TIME OF AEA CLOCK ZERO.  (IF AN AEA CLOCK ZERO IS
008344,000042:                                                                                                  #                REQUESTED DURING THIS PROGRAM
008345,000043: 
008346,000044:                                                                                                  #  LOG SECTION:  AGS INITIALIZATION
008347,000045: 
008348,000046:                                                                                                  #  CALLING SEQ:  PROGRAM IS ENTERED WHEN ASTRONAUT KEYS V47E ON DSKY.
008349,000047:                                                                                                  #                R47 MAY BE CALLED AT ANY TIME EXCEPT WHEN ANOTHER EXTENDED VERB IS IN PROGRESS
008350,000048: 
008351,000049:                                                                                                  #  SUBROUTINES
008352,000050:                                                                                                  #  CALLED:
008353,000051: 
008354,000052:                                                                                                  #  NORMAL EXIT:  ENDEXT
008355,000053: 
008356,000054:                                                                                                  #  ALARM/ABORT:  ALARM - BAD REFSMMAT - CODE:220
008357,000055:                                                                                                  #                OPERATOR ERROR IF V47 SELECTED DURING ANOTHER EXTENDED VERB.
008358,000056: 
008359,000057:                                                                                                  #  ERASABLES
008360,000058:                                                                                                  #  USED:         SAMPTIME        (2)     TIME OF :ENTER: KEYSTROKE
008361,000059:                                                                                                  #                AGSK            (2)     GROUND ELAPSED TIME OF THE AEA CLOCK :ZERO:
008362,000060:                                                                                                  #                AGSBUFF         (140)   CONTAINS AGS INITIALIZATION DATA (SEE :OUTPUT: BELOW)
008363,000061:                                                                                                  #                AGSWORD         (1)     PREVIOUS DOWNLIST SAVED HERE
008364,000062: 
008365,000063: 05,2447  E4,1600                                  EBANK=   AGSBUFF                               
008366,000064: 
008367,000065: 40,2000                                           BANK     40                                    
008368,000066: 32,2000                                           SETLOC   R47                                   
008369,000067: 32,2000                                           BANK                                           
008370,000068: 
008371,000069: 32,2005                                           COUNT*   $$/R47                                
008372,000070: 
008373,000071: 32,2005           34737        AGSINIT            CAF      REFSMBIT                              
008374,000072: 32,2006           70077                           MASK     FLAGWRD3                              #  CHECK REFSMFLG.
008375,000073: 32,2007           10000                           CCS      A                                     

Page 209

008377,000075: 32,2010           02017                           TC       REDSPTEM                              #  REFSMMAT IS OK
008378,000076: 32,2011           05567                           TC       ALARM                                 #  REFSMMAT IS BAD
008379,000077: 32,2012           00220                           OCT      220                                   
008380,000078: 32,2013           05472                           TC       ENDEXT                                
008381,000079: 
008382,000080: 32,2014           00006        NEWAGS             EXTEND                                         
008383,000081: 32,2015           30014                           DCA      SAMPTIME                              #  TIME OF THE :ENTER: KEYSTROKE
008384,000082: 32,2016           53421                           DXCH     AGSK                                  #  BECOMES NEW AEA CLOCK :ZERO:
008385,000083: 
008386,000084: 32,2017           00006        REDSPTEM           EXTEND                                         
008387,000085: 32,2020           31421                           DCA      AGSK                                  
008388,000086: 32,2021           53051                           DXCH     DSPTEMX                               
008389,000087: 32,2022           32172        AGSDISPK           CAF      V06N16                                
008390,000088: 32,2023           04616                           TC       BANKCALL                              #  R1 = 00XXX. HRS., R2 = 000XX MIN.,
008391,000089: 32,2024           20334                           CADR     GOMARKF                               #  R3 = 0XX.XX SEC.
008392,000090: 32,2025           05472                           TC       ENDEXT                                #  TERMINATE RETURN
008393,000091: 32,2026           02036                           TC       AGSVCALC                              #  PROCEED RETURN
008394,000092: 32,2027           44746                           CS       BIT6                                  #  IS ENTER VIA A V32
008395,000093: 32,2030           60154                           AD       MPAC                                  
008396,000094: 32,2031           00006                           EXTEND                                         
008397,000095: 32,2032           12014                           BZF      NEWAGS                                #  YES, USE KEYSTROKE TIME FOR NEW AGSK
008398,000096: 
008399,000097: 32,2033           00006                           EXTEND                                         #  NO, NEW AGSK LOADED VIA V25
008400,000098: 32,2034           31051                           DCA      DSPTEMX                               #  LOADED INTO DSPTEMX BY KEYING
008401,000099: 32,2035           02016                           TC       REDSPTEM   -1                         #  V25E FOLLOWED BY HRS.,MINS.,SECS.
008402,000100:                                                                                                  #  DISPLAY THE NEW K
008403,000101: 
008404,000102: 32,2036           06042        AGSVCALC           TC       INTPRET                               
008405,000103: 32,2037           77614                           SET                                            
008406,000104: 32,2040           01076                                    NODOFLAG                              #  DONT ALLOW V37
008407,000105: 32,2041           77414                           SET      EXIT                                  
008408,000106: 32,2042           02076                                    XDSPFLAG                              
008409,000107: 
008410,000108: 32,2043           32172                           CAF      V06N16                                
008411,000109: 32,2044           04616                           TC       BANKCALL                              
008412,000110: 32,2045           20621                           CADR     EXDSPRET                              
008413,000111: 
008414,000112: 32,2046           06042                           TC       INTPRET                               #  EXTRAPOLATE LEM AND CSM STATE VECTORS
008415,000113: 32,2047           77634                           RTB                                            #  TO THE PRESENT TIME
008416,000114: 32,2050           21574                                    LOADTIME                              #  LOAD MPAC WITH TIME2,TIME1
008417,000115: 32,2051           34041                           STCALL   TDEC1                                 #  CALCULATE LEM STATE VECTOR
008418,000116: 32,2052           27056                                    LEMPREC                               
008419,000117: 32,2053           77624                           CALL                                           #  CALL ROUTINE TO CONVERT TO SM COORDS AND
008420,000118: 32,2054           64132                                    SCALEVEC                              #  PROVIDE PROPER SCALING
008421,000119: 32,2055           16201                           STODL    AGSBUFF                               #  (LEMPREC AND CSMPREC LEAVE TDEC1 IN TAT)
008422,000120: 32,2056           00015                                    TAT                                   #  TAT = TIME TO WHICH RATT1 AND VATT1 ARE
008423,000121: 32,2057           34041                           STCALL   TDEC1                                 #  COMPUTED (CSEC SINCE CLOCK START B-28).
008424,000122: 32,2060           27042                                    CSMPREC                               #  CALCULATE CSM STATE VECTOR FOR SAME TIME
008425,000123: 32,2061           77624                           CALL                                           
008426,000124: 32,2062           64132                                    SCALEVEC                              

Page 210

008428,000126: 32,2063           16207                           STODL    AGSBUFF    +6                         
008429,000127: 32,2064           00015                                    TAT                                   
008430,000128: 32,2065           56225                           DSU      DDV                                   #  CALCULATE AND STORE THE TIME
008431,000129: 32,2066           02021                                    AGSK                                  
008432,000130: 32,2067           24175                                    TSCALE                                
008433,000131: 32,2070           02215                           STORE    AGSBUFF    +12D                       
008434,000132: 32,2071           77776                           EXIT                                           
008435,000133: 
008436,000134: 32,2072           34753                           CAF      LAGSLIST                              
008437,000135: 32,2073           54333                           TS       DNLSTCOD                              
008438,000136: 
008439,000137: 32,2074           32176                           CAF      20SEC                                 #  DELAY FOR 20 SEC WHILE THE AGS
008440,000138: 32,2075           04616                           TC       BANKCALL                              #  DOWNLIST IS TRANSMITTED
008441,000139: 32,2076           01736                           CADR     DELAYJOB                              
008442,000140: 
008443,000141: 32,2077           31321                           CA       AGSWORD                               
008444,000142: 32,2100           54333                           TS       DNLSTCOD                              #  RETURN TO THE OLD DOWNLIST
008445,000143: 32,2101           34744                           CAF      IMUSEBIT                              
008446,000144: 32,2102           70074                           MASK     FLAGWRD0                              #  CHECK IMUSE FLAG.
008447,000145: 32,2103           10000                           CCS      A                                     
008448,000146: 32,2104           02122                           TC       AGSEND                                #  IMU IS BEING USED - DO NOT ZERO
008449,000147: 32,2105           11301        CKSTALL            CCS      IMUCADR                               #  CHECK FOR IMU USAGE WHICH AVOIDS THE
008450,000148: 32,2106           12111                           TCF      +3                                    #  IMUSE BIT:  I.E., IMU COMPENSATION.
008451,000149: 32,2107           12115                           TCF      +6                                    #  FREE.  GO AHEAD WITH THE IMU ZERO.
008452,000150: 32,2110           12111                           TCF      +1                                    
008453,000151: 32,2111           34363                 +3        CAF      TEN                                   #  WAIT .1 SEC AND TRY AGAIN.
008454,000152: 32,2112           04616                           TC       BANKCALL                              
008455,000153: 32,2113           01736                           CADR     DELAYJOB                              
008456,000154: 32,2114           12105                           TCF      CKSTALL                               
008457,000155: 
008458,000156: 32,2115           04616                 +6        TC       BANKCALL                              #  IMU IS NOT IN USE
008459,000157: 32,2116           16705                           CADR     IMUZERO                               #  SET IMU ZERO DISCRETE FOR 320 MSECS
008460,000158: 32,2117           04616                           TC       BANKCALL                              #  WAIT 3SEC FOR COUNTERS TO INCREMENT
008461,000159: 32,2120           17707                           CADR     IMUSTALL                              
008462,000160: 32,2121           02122                           TC       AGSEND                                
008463,000161: 32,2122           05516        AGSEND             TC       DOWNFLAG                              #  ALLOW V37
008464,000162: 32,2123           00054                           ADRES    NODOFLAG                              
008465,000163: 
008466,000164: 32,2124           32173                           CAF      V50N16                                
008467,000165: 32,2125           04616                           TC       BANKCALL                              
008468,000166: 32,2126           20342                           CADR     GOMARK3                               
008469,000167: 32,2127           15472                           TCF      ENDEXT                                
008470,000168: 32,2130           15472                           TCF      ENDEXT                                
008471,000169: 32,2131           05472                           TC       ENDEXT                                
008472,000170: 
008473,000171: 32,2132           64375        SCALEVEC           VLOAD    MXV                                   
008474,000172: 32,2133           00025                                    VATT1                                 
008475,000173: 32,2134           01734                                    REFSMMAT                              
008476,000174: 32,2135           72561                           VXSC     VSL2                                  
008477,000175: 32,2136           24202                                    VSCALE                                

Page 211

008479,000177: 32,2137           53255                           VAD      VAD                                   #  THIS SECTION ROUNDS THE VECTOR, AND
008480,000178: 32,2140           24204                                    AGSRND1                               #  CORRECTS FOR THE FACT THAT THE AGS
008481,000179: 32,2141           24212                                    AGSRND2                               #  IS A 2 S COMPLIMENT MACHINE WHILE THE
008482,000180: 32,2142           77634                           RTB                                            #  LGC IS A 1 S COMPLIMENT MACHINE.
008483,000181: 32,2143           21773                                    VECSGNAG                              
008484,000182: 32,2144           24025                           STOVL    VATT1                                 
008485,000183: 32,2145           00017                                    RATT1                                 
008486,000184: 32,2146           74321                           MXV      VXSC                                  
008487,000185: 32,2147           01734                                    REFSMMAT                              
008488,000186: 32,2150           24200                                    RSCALE                                
008489,000187: 32,2151           53212                           VSL8     VAD                                   #  AGAIN THIS SECTION ROUNDS.  TWO VECTORS
008490,000188: 32,2152           24204                                    AGSRND1                               #  ARE ADDED TO DEFEAT ALSIGNAG IN THE
008491,000189: 32,2153           47055                           VAD      RTB                                   #  CASE OF A HIGH-ORDER ZERO COUPLED WITH
008492,000190: 32,2154           24212                                    AGSRND2                               #  A LOW ORDER NEGATIVE PART.
008493,000191: 32,2155           21773                                    VECSGNAG                              
008494,000192: 32,2156           77750                           LXA,1                                          
008495,000193: 32,2157           00024                                    VATT1                                 
008496,000194: 32,2160           72130                           SXA,1    LXA,1                                 
008497,000195: 32,2161           00155                                    MPAC       +1                         
008498,000196: 32,2162           00026                                    VATT1      +2                         
008499,000197: 32,2163           72130                           SXA,1    LXA,1                                 
008500,000198: 32,2164           00160                                    MPAC       +4                         
008501,000199: 32,2165           00030                                    VATT1      +4                         
008502,000200: 32,2166           43530                           SXA,1    RVQ                                   
008503,000201: 32,2167           00162                                    MPAC       +6                         
008504,000202: 
008505,000203: 32,2170     4753               LAGSLIST           =        ONE                                   
008506,000204: 32,2170           00216        V01N14             VN       0114                                  
008507,000205: 32,2171           14400        V50N00A            VN       5000                                  
008508,000206: 32,2172     6010               V00N25             EQUALS   OCT31                                 
008509,000207: 32,2172           01420        V06N16             VN       0616                                  
008510,000208: 32,2173     4242               V00N34             EQUALS   34DEC                                 
008511,000209: 32,2173           14420        V50N16             VN       5016                                  
008512,000210: 32,2174           03100 00000  TSCALE             2DEC     100        B-10                       #  CSEC TO SEC SCALE FACTOR
008513,000211: 32,2176           03720        20SEC              DEC      2000       B-14                       
008514,000212: 32,2177           15077 05041  RSCALE             2DEC     3.280839   B-3                        #  METERS TO FEET SCALE FACTOR
008515,000213: 32,2201           24402 25724  VSCALE             2DEC     3.280839   E2         B-9             #  METERS/CS TO FEET/SEC SCALE FACTOR
008516,000214: 32,2203           00000 60000  AGSRND1            2OCT     0000060000                            
008517,000215: 32,2205           00000 60000                     2OCT     0000060000                            
008518,000216: 32,2207           00000 60000                     2OCT     0000060000                            
008519,000217: 32,2211           00000 37777  AGSRND2            2OCT     0000037777                            
008520,000218: 32,2213           00000 37777                     2OCT     0000037777                            

Page 212

008522,000220: 32,2215           00000 37777                     2OCT     0000037777                            
008523,000221: 
008524,000222: 32,2217  30,2000                                  SBANK=   LOWSUPER                              #  FOR SUBSEQUENT LOW 2CADRS.
008525,000223: 

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