Source Code

These source code files are an attempted reconstruction of Sundance revision 306, the Apollo 9 LM (Lunar Module) AGC (Apollo Guidance Computer) flight software, created from binary dumps of original core rope program modules, as follows:
  • B1 — Revision 292
  • B2 — Revision 302
  • B3 — Revision 302
  • B4 — Revision 302
  • B5 — Revision 292
  • B6 — Revision 306
These dumps were then modified using memos, checklists, observed address changes, and the Sundance GSOPs to get the entire program to match Sundance revision 306 as closely as possible. Without more information, it is not possible to say how close it actually is; however, this code should be quite close. It is capable of flying the whole Apollo 9 mission using the original checklists and padload. Since only binary dumps (rather than listings) of Sundance are available as source material, all comments and labels are approximate. They have been taken from other AGC programs where possible, or, in some places, written from scratch to match what we believe would have been in the original listing.

007322,000002:                                                                                                  ## Copyright:   Public domain.
007323,000003:                                                                                                  ## Filename:    AGS_INITIALIZATION.agc
007324,000004:                                                                                                  ## Purpose:     A section of an attempt to reconstruct Sundance revision 306
007325,000005:                                                                                                  ##              as closely as possible with available information. Sundance
007326,000006:                                                                                                  ##              306 is the source code for the Lunar Module's (LM) Apollo
007327,000007:                                                                                                  ##              Guidance Computer (AGC) for Apollo 9. This program was created
007328,000008:                                                                                                  ##              using the mixed-revision SundanceXXX as a starting point, and
007329,000009:                                                                                                  ##              pulling back features from Luminary 69 believed to have been
007330,000010:                                                                                                  ##              added based on memos, checklists, observed address changes,
007331,000011:                                                                                                  ##              or the Sundance GSOPs.
007332,000012:                                                                                                  ## Assembler:   yaYUL
007333,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
007334,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
007335,000015:                                                                                                  ## Mod history: 2020-07-24 MAS  Created from SundanceXXX.
007336,000016: 
007337,000017: 
007338,000018: 
007339,000019:                                                                                                  #  PROGRAM NAME:   AGS INITIALIZATION (R47)
007340,000020: 
007341,000021:                                                                                                  #  WRITTEN BY  :   RHODE/KILROY/FOLLETT
007342,000022: 
007343,000023:                                                                                                  #  MOD NO. :       0
007344,000024:                                                                                                  #  DATE    :       23 MARCH 1967
007345,000025:                                                                                                  #  MOD BY  :       KILROY
007346,000026: 
007347,000027:                                                                                                  #  MOD NO. :       1
007348,000028:                                                                                                  #  DATE    :       28 OCTOBER 1967
007349,000029:                                                                                                  #  MOD BY  :       FOLLETT
007350,000030: 
007351,000031:                                                                                                  #  FUNCT. DESC.:   (1) TO PROVIDE THE AGS ABORT ELECTRONICS ASSEMBLY(AEA) WITH THE LEM AND CSM STATE VECTORS
007352,000032:                                                                                                  #                  (POSITION,VELOCITY,TIME) IN LEM IMU COORDINATES BY MEANS OF THE LGC DIGITAL DOWNLINK.
007353,000033: 
007354,000034:                                                                                                  #                  (2) TO ZERO THE ICDU, LGC AND AEA GIMBAL ANGLE COUNTERS SIMULTANEOUSLY IN ORDER TO ESTABLISH A
007355,000035:                                                                                                  #                  COMMON ZERO REFERENCE FOR THE MEASUREMENT OF GIMBAL(EULER) ANGLES WHICH DEFINE LEM ATTITUDE
007356,000036:                                                                                                  #                  (3) TO ESTABLISH THE GROUND ELAPSED TIME OF AEA CLOCK ZERO.(IF AN AEA CLOCK ZERO IS
007357,000037:                                                                                                  #                  REQUESTED DURING THIS PROGRAM
007358,000038: 
007359,000039:                                                                                                  #  LOG SECTION :   AGS INITIALIZATION
007360,000040: 
007361,000041:                                                                                                  #  CALLING SEQ :   PROGRAM IS ENTERED WHEN ASTRONAUT KEYS V47E ON DSKY.
007362,000042:                                                                                                  #                  R47 MAY BE CALLED AT ANY TIME EXCEPT WHEN ANOTHER EXTENDED VERB IS IN PROGRESS
007363,000043: 
007364,000044:                                                                                                  #  SUBROUTINES
007365,000045:                                                                                                  #  CALLED      :
007366,000046: 
007367,000047:                                                                                                  #  NORMAL EXIT :   ENDEXT
007368,000048: 
007369,000049:                                                                                                  #  ALARM/ABORT :   ALARM - BAD REFSMMAT - CODE:220
007370,000050:                                                                                                  #                  OPERATOR ERROR IF V47 SELECTED DURING ANOTHER EXTENDED VERB.
007371,000051: 
007372,000052:                                                                                                  #  ERASABLES
007373,000053:                                                                                                  #  USED        :   SAMPTIME    (2) TIME OF :ENTER: KEYSTROKE
007374,000054:                                                                                                  #                  AGSK        (2) GROUND ELAPSED TIME OF THE AEA CLOCK :ZERO:
007375,000055:                                                                                                  #                  AGSBUFF   (140) CONTAINS AGS INITIALIZATION DATA (SEE :OUTPUT: BELOW)
007376,000056:                                                                                                  #                  AGSWORD     (1) PREVIOUS DOWNLIST SAVED HERE
007377,000057: 
007378,000058: 05,2264  E4,1606                                  EBANK=   AGSBUFF                               
007379,000059: 
007380,000060: 40,2000                                           BANK     40                                    
007381,000061: 40,2000                                           SETLOC   R47                                   
007382,000062: 40,2000                                           BANK                                           
007383,000063: 
007384,000064: 40,2000                                           COUNT*   $$/R47                                
007385,000065: 
007386,000066: 40,2000           35012        AGSINIT            CAF      REFSMBIT                              
007387,000067: 40,2001           70077                           MASK     FLAGWRD3                              #  CHECK REFSMFLG.
007388,000068: 40,2002           10000                           CCS      A                                     
007389,000069: 
007390,000070: 40,2003           02012                           TC       REDSPTEM                              #  REFSMMAT IS OK
007391,000071: 40,2004           05651                           TC       ALARM                                 #  REFSMMAT IS BAD
007392,000072: 40,2005           00220                           OCT      220                                   
007393,000073: 40,2006           05564                           TC       ENDEXT                                
007394,000074: 
007395,000075: 40,2007           00006        NEWAGS             EXTEND                                         
007396,000076: 40,2010           30014                           DCA      SAMPTIME                              #  TIME OF THE :ENTER: KEYSTROKE
007397,000077: 40,2011           53417                           DXCH     AGSK                                  #  BECOMES NEW AEA CLOCK :ZERO:
007398,000078: 
007399,000079: 40,2012           00006        REDSPTEM           EXTEND                                         
007400,000080: 40,2013           31417                           DCA      AGSK                                  
007401,000081: 40,2014           53053                           DXCH     DSPTEMX                               
007402,000082: 40,2015           32165        AGSDISPK           CAF      V06N16                                
007403,000083: 40,2016           04655                           TC       BANKCALL                              #  R1 = 00XXX. HRS., R2 = 000XX MIN.,
007404,000084: 40,2017           20226                           CADR     GOMARKF                               #  R3 = 0XX.XX SEC.
007405,000085: 40,2020           05564                           TC       ENDEXT                                #  TERMINATE RETURN
007406,000086: 40,2021           02031                           TC       AGSVCALC                              #  PROCEED   RETURN
007407,000087: 40,2022           45021                           CS       BIT6                                  #  IS ENTER VIA A V32
007408,000088: 40,2023           60154                           AD       MPAC                                  
007409,000089: 40,2024           00006                           EXTEND                                         
007410,000090: 40,2025           12007                           BZF      NEWAGS                                #  YES, USE KEYSTROKE TIME FOR NEW AGSK
007411,000091: 
007412,000092: 40,2026           00006                           EXTEND                                         #  NO, NEW AGSK LOADED VIA V25
007413,000093: 40,2027           31053                           DCA      DSPTEMX                               #  LOADED INTO DSPTEMX BY KEYING
007414,000094: 40,2030           02011                           TC       REDSPTEM   -1                         #  V25E FOLLOWED BY HRS.,MINS.,SECS.
007415,000095:                                                                                                  #  DISPLAY THE NEW K
007416,000096: 
007417,000097: 40,2031           06014        AGSVCALC           TC       INTPRET                               
007418,000098: 40,2032           77614                           SET                                            
007419,000099: 40,2033           01076                                    NODOFLAG                              #  DONT ALLOW V37
007420,000100: 40,2034           77414                           SET      EXIT                                  
007421,000101: 40,2035           02076                                    XDSPFLAG                              
007422,000102: 
007423,000103: 40,2036           32165                           CAF      V06N16                                
007424,000104: 40,2037           04655                           TC       BANKCALL                              
007425,000105: 40,2040           20527                           CADR     EXDSPRET                              
007426,000106: 
007427,000107: 40,2041           06014                           TC       INTPRET                               #  EXTRAPOLATE LEM AND CSM STATE VECTORS
007428,000108: 40,2042           77634                           RTB                                            #  TO THE PRESENT TIME
007429,000109: 40,2043           21454                                    LOADTIME                              #  LOAD MPAC WITH TIME2,TIME1
007430,000110: 40,2044           34041                           STCALL   TDEC1                                 #  CALCULATE LEM STATE VECTOR
007431,000111: 40,2045           27030                                    LEMPREC                               
007432,000112: 40,2046           77624                           CALL                                           #  CALL ROUTINE TO CONVERT TO SM COORDS AND
007433,000113: 40,2047           60125                                    SCALEVEC                              #  PROVIDE PROPER SCALING
007434,000114: 40,2050           16207                           STODL    AGSBUFF                               #  (LEMPREC AND CSMPREC LEAVE TDEC1 IN TAT)
007435,000115: 40,2051           00015                                    TAT                                   #  TAT = TIME TO WHICH RATT1 AND VATT1 ARE
007436,000116: 40,2052           34041                           STCALL   TDEC1                                 #  COMPUTED(CSEC SINCE CLOCK START B-28).
007437,000117: 40,2053           27014                                    CSMPREC                               #  CALCULATE CSM STATE VECTOR FOR SAME TIME
007438,000118: 40,2054           77624                           CALL                                           
007439,000119: 40,2055           60125                                    SCALEVEC                              
007440,000120: 
007441,000121: 40,2056           16215                           STODL    AGSBUFF    +6                         
007442,000122: 40,2057           00015                                    TAT                                   
007443,000123: 40,2060           56225                           DSU      DDV                                   #  CALCULATE AND STORE THE TIME
007444,000124: 40,2061           02017                                    AGSK                                  
007445,000125: 40,2062           20170                                    TSCALE                                
007446,000126: 40,2063           02223                           STORE    AGSBUFF    +12D                       
007447,000127: 40,2064           77776                           EXIT                                           
007448,000128: 
007449,000129: 40,2065           35026                           CAF      LAGSLIST                              
007450,000130: 40,2066           54332                           TS       DNLSTCOD                              
007451,000131: 
007452,000132: 40,2067           32171                           CAF      20SEC                                 #  DELAY FOR 20 SEC WHILE THE AGS
007453,000133: 40,2070           04655                           TC       BANKCALL                              #  DOWNLIST IS TRANSMITTED
007454,000134: 40,2071           01732                           CADR     DELAYJOB                              
007455,000135: 
007456,000136: 40,2072           31330                           CA       AGSWORD                               
007457,000137: 40,2073           54332                           TS       DNLSTCOD                              #  RETURN TO THE OLD DOWNLIST
007458,000138: 40,2074           35017                           CAF      IMUSEBIT                              
007459,000139: 40,2075           70074                           MASK     FLAGWRD0                              #  CHECK IMUSE FLAG.
007460,000140: 40,2076           10000                           CCS      A                                     
007461,000141: 40,2077           02115                           TC       AGSEND                                #  IMU IS BEING USED - DO NOT ZERO
007462,000142: 40,2100           11306        CKSTALL            CCS      IMUCADR                               #  CHECK FOR IMU USAGE WHICH AVOIDS THE
007463,000143: 40,2101           12104                           TCF      +3                                    #  IMUSE BIT:  I.E., IMU COMPENSATION.
007464,000144: 40,2102           12110                           TCF      +6                                    #  FREE.  GO AHEAD WITH THE IMU ZERO.
007465,000145: 40,2103           12104                           TCF      +1                                    
007466,000146: 40,2104           34375                 +3        CAF      TEN                                   #  WAIT .1 SEC AND TRY AGAIN.
007467,000147: 40,2105           04655                           TC       BANKCALL                              
007468,000148: 40,2106           01732                           CADR     DELAYJOB                              
007469,000149: 40,2107           12100                           TCF      CKSTALL                               
007470,000150: 
007471,000151: 40,2110           04655                 +6        TC       BANKCALL                              #  IMU IS NOT IN USE
007472,000152: 40,2111           16622                           CADR     IMUZERO                               #  SET IMU ZERO DISCRETE FOR 320MSECS
007473,000153: 40,2112           04655                           TC       BANKCALL                              #  WAIT 3 SEC FOR COUNTERS TO INCREMENT
007474,000154: 40,2113           17625                           CADR     IMUSTALL                              
007475,000155: 40,2114           02115                           TC       AGSEND                                
007476,000156: 40,2115           05600        AGSEND             TC       DOWNFLAG                              #  ALLOW V37
007477,000157: 40,2116           00054                           ADRES    NODOFLAG                              
007478,000158: 
007479,000159: 40,2117           32166                           CAF      V50N16                                
007480,000160: 40,2120           04655                           TC       BANKCALL                              
007481,000161: 40,2121           20234                           CADR     GOMARK3                               
007482,000162: 40,2122           15564                           TCF      ENDEXT                                
007483,000163: 40,2123           15564                           TCF      ENDEXT                                
007484,000164: 40,2124           05564                           TC       ENDEXT                                
007485,000165: 
007486,000166: 40,2125           64375        SCALEVEC           VLOAD    MXV                                   
007487,000167: 40,2126           00025                                    VATT1                                 
007488,000168: 40,2127           01736                                    REFSMMAT                              
007489,000169: 40,2130           72561                           VXSC     VSL2                                  
007490,000170: 40,2131           20175                                    VSCALE                                
007491,000171: 
007492,000172: 40,2132           53255                           VAD      VAD                                   #  THIS SECTION ROUNDS THE VECTOR, AND
007493,000173: 40,2133           20177                                    AGSRND1                               #  CORRECTS FOR THE FACT THAT THE AGS
007494,000174: 40,2134           20205                                    AGSRND2                               #  IS A 2 S COMPLIMENT MACHINE WHILE THE
007495,000175: 40,2135           77634                           RTB                                            #  LGC IS A 1 S COMPLIMENT MACHINE.
007496,000176: 40,2136           21736                                    VECSGNAG                              
007497,000177: 40,2137           24025                           STOVL    VATT1                                 
007498,000178: 40,2140           00017                                    RATT1                                 
007499,000179: 40,2141           74321                           MXV      VXSC                                  
007500,000180: 40,2142           01736                                    REFSMMAT                              
007501,000181: 40,2143           20173                                    RSCALE                                
007502,000182: 40,2144           53212                           VSL8     VAD                                   #  AGAIN THIS SECTION ROUNDS.  TWO VECTORS
007503,000183: 40,2145           20177                                    AGSRND1                               #  ARE ADDED TO DEFEAT ALSIGNAG IN THE
007504,000184: 40,2146           47055                           VAD      RTB                                   #  CASE OF A HIGH-ORDER ZERO COUPLED WITH
007505,000185: 40,2147           20205                                    AGSRND2                               #  A LOW ORDER NEGATIVE PART.
007506,000186: 40,2150           21736                                    VECSGNAG                              
007507,000187: 40,2151           77750                           LXA,1                                          
007508,000188: 40,2152           00024                                    VATT1                                 
007509,000189: 40,2153           72130                           SXA,1    LXA,1                                 
007510,000190: 40,2154           00155                                    MPAC       +1                         
007511,000191: 40,2155           00026                                    VATT1      +2                         
007512,000192: 40,2156           72130                           SXA,1    LXA,1                                 
007513,000193: 40,2157           00160                                    MPAC       +4                         
007514,000194: 40,2160           00030                                    VATT1      +4                         
007515,000195: 40,2161           43530                           SXA,1    RVQ                                   
007516,000196: 40,2162           00162                                    MPAC       +6                         
007517,000197: 
007518,000198: 40,2163     5026               LAGSLIST           =        ONE                                   
007519,000199: 40,2163           00216        V01N14             VN       0114                                  
007520,000200: 40,2164           14400        V50N00A            VN       5000                                  
007521,000201: 40,2165     4113               V00N25             EQUALS   OCT31                                 
007522,000202: 40,2165           01420        V06N16             VN       0616                                  
007523,000203: 40,2166     4254               V00N34             EQUALS   34DEC                                 
007524,000204: 40,2166           14420        V50N16             VN       5016                                  
007525,000205: 40,2167           03100 00000  TSCALE             2DEC     100        B-10                       #  CSEC TO SEC SCALE FACTOR
007526,000206: 40,2171           03720        20SEC              DEC      2000       B-14                       
007527,000207: 40,2172           15077 04530  RSCALE             2DEC     3.280833   B-3                        #  METERS TO FEET SCALE FACTOR
007528,000208: 40,2174           24402 25231  VSCALE             2DEC     3.280833   E2         B-9             #  METERS/CS TO FEET/SEC SCALE FACTOR
007529,000209: 40,2176           00000 60000  AGSRND1            2OCT     0000060000                            
007530,000210: 40,2200           00000 60000                     2OCT     0000060000                            
007531,000211: 40,2202           00000 60000                     2OCT     0000060000                            
007532,000212: 40,2204           00000 37777  AGSRND2            2OCT     0000037777                            
007533,000213: 40,2206           00000 37777                     2OCT     0000037777                            
007534,000214: 
007535,000215: 40,2210           00000 37777                     2OCT     0000037777                            
007536,000216: 
007537,000217: 40,2212  30,2000                                  SBANK=   LOWSUPER                              #  FOR SUBSEQUENT LOW 2CADRS.

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