Source Code

These source code files are a reconstruction of Sundance, 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
This means that source code does not represent a specific historical revision of Sundance, but rather a mixture of the three released versions. Nonetheless, it is capable of flying the whole Apollo 9 mission. This source code matches the binary dumps, as closely as feasible, but 100% match is not possible, due mostly to changes in memory addresses at which code and variables were allocated in different revisions of Sundance. Refer to this list of explanations for each binary mismatch.

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.

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

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