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.

050991,000002:                                                                                                  ## Copyright:   Public domain.
050992,000003:                                                                                                  ## Filename:    RESTARTS_ROUTINE.agc
050993,000004:                                                                                                  ## Purpose:     A section of a reconstructed, mixed version of Sundance
050994,000005:                                                                                                  ##              It is part of the reconstructed source code for the Lunar
050995,000006:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
050996,000007:                                                                                                  ##              No original listings of this program are available;
050997,000008:                                                                                                  ##              instead, this file was created via disassembly of dumps
050998,000009:                                                                                                  ##              of various revisions of Sundance core rope modules.
050999,000010:                                                                                                  ## Assembler:   yaYUL
051000,000011:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
051001,000012:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
051002,000013:                                                                                                  ## Mod history: 2020-06-17 MAS  Created from Luminary 69.
051003,000014: 
051004,000015:                                                                                                  ## Sundance 292
051005,000016: 
051006,000017: 01,3314                                           BANK     01                                    
051007,000018: 01,2000                                           SETLOC   RESTART                               
051008,000019: 01,2000                                           BANK                                           
051009,000020: 
051010,000021: 01,3314  E3,1436                                  EBANK=   PHSNAME1                              #  GOPROG MUST SWITCH TO THIS EBANK
051011,000022: 
051012,000023: 01,3314                                           COUNT*   $$/RSROU                              
051013,000024: 01,3314           30161        RESTARTS           CA       MPAC       +5                         #  GET GROUP NUMBER -1
051014,000025: 01,3315           60000                           DOUBLE                                         #  SAVE FOR INDEXING
051015,000026: 01,3316           54155                           TS       TEMP2G                                
051016,000027: 
051017,000028: 01,3317           33556                           CA       PHS2CADR                              #  SET UP EXIT IN CASE IT IS AN EVEN
051018,000029: 01,3320           54157                           TS       TEMPSWCH                              #  TABLE PHASE
051019,000030: 
051020,000031: 01,3321           33353                           CA       RTRNCADR                              #  TO SAVE TIME ASSUME IT WILL GET NEXT
051021,000032: 01,3322           54707                           TS       GOLOC      +2                         #  GROUP AFTER THIS
051022,000033: 
051023,000034: 01,3323           30154                           CA       TEMPPHS                               
051024,000035: 01,3324           75057                           MASK     OCT1400                               
051025,000036: 01,3325           10000                           CCS      A                                     #  IS IT A VARIABLE OR TABLE RESTART
051026,000037: 01,3326           13337                           TCF      ITSAVAR                               #  IT:S A VARIABLE RESTART
051027,000038: 
051028,000039: 01,3327           10154        GETPART2           CCS      TEMPPHS                               #  IS IT AN X.1 RESTART
051029,000040: 01,3330           10000                           CCS      A                                     
051030,000041: 01,3331           13437                           TCF      ITSATBL                               #  NO, ITS A TABLE RESTART
051031,000042: 
051032,000043: 01,3332           35074                           CA       PRIO14                                #  IT IS AN X.1 RESTART, THEREFORE START
051033,000044: 01,3333           05155                           TC       FINDVAC                               #  THE DISPLAY RESTART JOB
051034,000045: 01,3334  E3,1400                                  EBANK=   LST1                                  
051035,000046: 01,3334           02735 20103                     2CADR    INITDSP                               
051036,000047: 
051037,000048: 01,3336           03353                           TC       RTRNCADR                              #  FINISHED WITH THIS GROUP, GET NEXT ONE
051038,000049: 
051039,000050: 01,3337           75057        ITSAVAR            MASK     OCT1400                               #  IS IT TYPE B ?
051040,000051: 01,3340           10000                           CCS      A                                     
051041,000052: 01,3341           13410                           TCF      ITSLIKEB                              #  YES, IT IS TYPE B
051042,000053: 
051043,000054: 01,3342           00006                           EXTEND                                         #  STORE THE JOB (OR TASK) 2CADR FOR EXIT
051044,000055: 01,3343           50155                           NDX      TEMP2G                                
051045,000056: 01,3344           31437                           DCA      PHSNAME1                              
051046,000057: 01,3345           52706                           DXCH     GOLOC                                 
051047,000058: 
051048,000059: 01,3346           30154                           CA       TEMPPHS                               #  SEE IF THIS IS A JOB, TASK, OR A LONGCAL
051049,000060: 01,3347           75032                           MASK     OCT7                                  
051050,000061: 01,3350           67720                           AD       MINUS2                                
051051,000062: 01,3351           10000                           CCS      A                                     
051052,000063: 01,3352           13522                           TCF      ITSLNGCL                              #  ITS A LONGCALL
051053,000064: 
051054,000065: 01,3353           04670        RTRNCADR           TC       SWRETURN                              #  CANT GET HERE
051055,000066: 01,3354           13356                           TCF      ITSAWAIT                              
051056,000067: 
051057,000068: 01,3355           13423                           TCF      ITSAJOB                               #  ITS A JOB
051058,000069: 
051059,000070: 01,3356           33562        ITSAWAIT           CA       WTLTCADR                              #  SET UP WAITLIST CALL
051060,000071: 01,3357           54704                           TS       GOLOC      -1                         
051061,000072: 
051062,000073: 01,3360           50155                           NDX      TEMP2G                                #  DIRECTLY STORED
051063,000074: 01,3361           31055                           CA       PHSPRDT1                              
051064,000075: 01,3362           10000        TIMETEST           CCS      A                                     #  IS IT AN IMMEDIATE RESTART
051065,000076: 01,3363           24000                           INCR     A                                     #  NO,
051066,000077: 01,3364           13367                           TCF      FINDTIME                              #  FIND OUT WHEN IT SHOULD BEGIN
051067,000078: 
051068,000079: 01,3365           15525                           TCF      ITSINDIR                              #  STORED INDIRECTLY
051069,000080: 
051070,000081: 01,3366           13406                           TCF      IMEDIATE                              #  IT WANTS AN IMMEDIATE RESTART
051071,000082: 
051072,000083:                                                                                                  #  ***** THIS MUST BE IN FIXED FIXED *****
051073,000084: 
051074,000085:    5525                                           BLOCK    02                                    
051075,000086:    4000                                           SETLOC   FFTAG2                                
051076,000087:    4000                                           BANK                                           
051077,000088: 
051078,000089:    5525                                           COUNT*   $$/RSROU                              
051079,000090:    5525           22706        ITSINDIR           LXCH     GOLOC      +1                         #  GET THE CORRECT E BANK IN CASE THIS IS
051080,000091:    5526           22006                           LXCH     BB                                    #  SWITCHED ERRASIBLE
051081,000092: 
051082,000093:    5527           50000                           NDX      A                                     #  GET THE TIME INDIRECTLY
051083,000094:    5530           30001                           CA       1                                     
051084,000095: 
051085,000096:    5531           22006                           LXCH     BB                                    #  RESTORE THE BB AND GOLOC
051086,000097:    5532           22706                           LXCH     GOLOC      +1                         
051087,000098: 
051088,000099:    5533           13367                           TCF      FINDTIME                              #  FIND OUT WHEN IT SHOULD BEGIN
051089,000100: 
051090,000101:                                                                                                  #  ***** YOU MAY RETURN TO SWITCHED FIXED *****
051091,000102: 
051092,000103: 01,3367                                           BANK     01                                    
051093,000104: 01,2000                                           SETLOC   RESTART                               
051094,000105: 01,2000                                           BANK                                           
051095,000106: 
051096,000107: 01,3367                                           COUNT*   $$/RSROU                              
051097,000108: 01,3367           40000        FINDTIME           COM                                            #  MAKE NEGITIVE SINCE IT WILL BE SUBTRACTD
051098,000109: 01,3370           54001                           TS       L                                     #  AND SAVE
051099,000110: 01,3371           50155                           NDX      TEMP2G                                
051100,000111: 01,3372           41054                           CS       TBASE1                                
051101,000112: 01,3373           00006                           EXTEND                                         
051102,000113: 01,3374           60025                           SU       TIME1                                 
051103,000114: 01,3375           10000                           CCS      A                                     
051104,000115: 01,3376           40000                           COM                                            
051105,000116: 01,3377           67703                           AD       OCT37776                              
051106,000117: 01,3400           65026                           AD       ONE                                   
051107,000118: 01,3401           60001                           AD       L                                     
051108,000119: 01,3402           10000                           CCS      A                                     
051109,000120: 01,3403           35030                           CA       ZERO                                  
051110,000121: 01,3404           13406                           TCF      +2                                    
051111,000122: 01,3405           13406                           TCF      +1                                    
051112,000123: 01,3406           65026        IMEDIATE           AD       ONE                                   
051113,000124: 01,3407           00704                           TC       GOLOC      -1                         
051114,000125: 01,3410           33353        ITSLIKEB           CA       RTRNCADR                              #  TYPE B,             SO STORE RETURN IN
051115,000126: 01,3411           54157                           TS       TEMPSWCH                              #  TEMPSWCH IN CASE OF AN EVEN PHASE
051116,000127: 
051117,000128: 01,3412           33557                           CA       PRT2CADR                              #  SET UP EXIT TO GET TABLE PART OF THIS
051118,000129: 01,3413           54707                           TS       GOLOC      +2                         #  VARIABLE TYPE OF PHASE
051119,000130: 
051120,000131: 01,3414           30154                           CA       TEMPPHS                               #  MAKE THE PHASE LOOK RIGHT FOR THE TABLE
051121,000132: 01,3415           76050                           MASK     OCT177                                #  PART OF THIS VARIABLE PHASE
051122,000133: 01,3416           54154                           TS       TEMPPHS                               
051123,000134: 
051124,000135: 01,3417           00006                           EXTEND                                         
051125,000136: 01,3420           50155                           NDX      TEMP2G                                #  OBTAIN THE JOB:S 2CADR
051126,000137: 01,3421           31437                           DCA      PHSNAME1                              
051127,000138: 01,3422           52706                           DXCH     GOLOC                                 
051128,000139: 
051129,000140: 01,3423           50155        ITSAJOB            NDX      TEMP2G                                #  NOW ADD THE PRIORITY AND LET:S GO
051130,000141: 01,3424           31055                           CA       PHSPRDT1                              
051131,000142: 01,3425           54704        CHKNOVAC           TS       GOLOC      -1                         #  SAVE PRIO UNTIL WE SEE IF ITS
051132,000143: 01,3426           00006                           EXTEND                                         #  A FINDVAC OR A NOVAC
051133,000144: 01,3427           63433                           BZMF     ITSNOVAC                              
051134,000145: 
051135,000146: 01,3430           33561                           CAF      FVACCADR                              #  POSITIVE, SET UP FINDVAC CALL.
051136,000147: 01,3431           56704                           XCH      GOLOC      -1                         #  PICK UP PRIO,
051137,000148: 01,3432           00704                           TC       GOLOC      -1                         #  AND GO
051138,000149: 
051139,000150: 01,3433           33563        ITSNOVAC           CAF      NOVACADR                              #  NEGATIVE,
051140,000151: 01,3434           56704                           XCH      GOLOC      -1                         #  SET UP NOVAC CALL,
051141,000152: 01,3435           40000                           COM                                            #  CORRECT PRIO,
051142,000153: 01,3436           00704                           TC       GOLOC      -1                         #  AND GO
051143,000154: 
051144,000155: 01,3437           54020        ITSATBL            TS       CYR                                   #  FIND OUT IF THE PHASE IS ODD OR EVEN
051145,000156: 01,3440           10020                           CCS      CYR                                   
051146,000157: 01,3441           13442                           TCF      +1                                    #  IT:S EVEN
051147,000158: 01,3442           13540                           TCF      ITSEVEN                               
051148,000159: 
051149,000160: 01,3443           33353                           CA       RTRNCADR                              #  IN CASE THIS IS THE SECOND PART OF A
051150,000161: 01,3444           54707                           TS       GOLOC      +2                         #  TYPE B RESTART, WE NEED PROPER EXIT
051151,000162: 
051152,000163: 01,3445           30154                           CA       TEMPPHS                               #  SET UP POINTER FOR FINDING OUR PLACE IN
051153,000164: 01,3446           54021                           TS       SR                                    #  THE RESTART TABLES
051154,000165: 01,3447           60021                           AD       SR                                    
051155,000166: 01,3450           50155                           NDX      TEMP2G                                
051156,000167: 01,3451           62001                           AD       SIZETAB    +1                         
051157,000168: 01,3452           54156                           TS       POINTER                               
051158,000169: 
051159,000170: 01,3453           00006        CONTBL2            EXTEND                                         #  FIND OUT WHAT:S IN THE TABLE
051160,000171: 01,3454           50156                           NDX      POINTER                               
051161,000172: 01,3455           32002                           DCA      CADRTAB                               #  GET THE 2CADR
051162,000173: 
051163,000174: 01,3456           22706                           LXCH     GOLOC      +1                         #  STORE THE BB INFORMATION
051164,000175: 
051165,000176: 01,3457           10000                           CCS      A                                     #  IS IT A JOB OR IS IT  TIMED
051166,000177: 01,3460           24000                           INCR     A                                     #  POSITIVE, MUST BE A JOB
051167,000178: 01,3461           13534                           TCF      ITSAJOB2                              
051168,000179: 
051169,000180: 01,3462           24000                           INCR     A                                     #  MUST BE EITHER A WAITLIST OR LONGCALL
051170,000181: 01,3463           54705                           TS       GOLOC                                 #  LET-S STORE THE CORRECT CADR
051171,000182: 
051172,000183: 01,3464           33562                           CA       WTLTCADR                              #  SET UP OUR EXIT TO WAITLIST
051173,000184: 01,3465           54704                           TS       GOLOC      -1                         
051174,000185: 
051175,000186: 01,3466           30706                           CA       GOLOC      +1                         #  NOW FIND OUT IF IT IS A WAITLIST CALL
051176,000187: 01,3467           75015                           MASK     BIT10                                 #  THIS SHOULD BE ONE IF WE HAVE -BB
051177,000188: 01,3470           10000                           CCS      A                                     #  FOR THAT MATTER SO SHOULD BE BITS 9,8,7,
051178,000189:                                                                                                  #  6,5, AND LAST BUT NOT LEAST (PERHAPS NOT
051179,000190:                                                                                                  #  IN IMPORTANCE ANYWAY.  BIT 4
051180,000191: 01,3471           13527                           TCF      ITSWTLST                              #  IT IS A WAITLIST CALL
051181,000192: 
051182,000193: 01,3472           50156                           NDX      POINTER                               #  OBTAIN THE ORIGINAL DELTA T
051183,000194: 01,3473           32000                           CA       PRDTTAB                               #  ADDRESS FOR THIS LONGCALL
051184,000195: 
051185,000196: 01,3474           15534                           TCF      ITSLGCL1                              #  NOW GO GET THE DELTA TIME
051186,000197: 
051187,000198:                                                                                                  #  ***** THIS MUST BE IN FIXED FIXED *****
051188,000199: 
051189,000200:    5534                                           BLOCK    02                                    
051190,000201:    4000                                           SETLOC   FFTAG2                                
051191,000202:    4000                                           BANK                                           
051192,000203: 
051193,000204:    5534                                           COUNT*   $$/RSROU                              
051194,000205:    5534           22706        ITSLGCL1           LXCH     GOLOC      +1                         #  OBTAIN THE CORRECT E BANK
051195,000206:    5535           22006                           LXCH     BB                                    
051196,000207:    5536           22706                           LXCH     GOLOC      +1                         #  AND PRESERVE OUR E AND F BANKS
051197,000208: 
051198,000209:    5537           00006                           EXTEND                                         #  GET THE DELTA TIME
051199,000210:    5540           50000                           NDX      A                                     
051200,000211:    5541           30001                           DCA      0                                     
051201,000212: 
051202,000213:    5542           22706                           LXCH     GOLOC      +1                         #  RESTORE OUR E AND F BANK
051203,000214:    5543           22006                           LXCH     BB                                    #  RESTORE THE TASKS E AND F BANKS
051204,000215:    5544           22706                           LXCH     GOLOC      +1                         #  AND PRESERVE OUR L
051205,000216:    5545           13475                           TCF      ITSLGCL2                              #  NOW LET:S PROCESS THIS LONGCALL
051206,000217: 
051207,000218:                                                                                                  #  ***** YOU MAY RETURN TO SWITCHED FIXED *****
051208,000219: 
051209,000220: 01,3475                                           BANK     01                                    
051210,000221: 01,2000                                           SETLOC   RESTART                               
051211,000222: 01,2000                                           BANK                                           
051212,000223: 
051213,000224: 01,3475                                           COUNT*   $$/RSROU                              
051214,000225: 01,3475           53165        ITSLGCL2           DXCH     LONGTIME                              
051215,000226: 
051216,000227: 01,3476           00006                           EXTEND                                         #  CALCULATE TIME LEFT
051217,000228: 01,3477           40025                           DCS      TIME2                                 
051218,000229: 01,3500           21165                           DAS      LONGTIME                              
051219,000230: 01,3501           00006                           EXTEND                                         
051220,000231: 01,3502           31163                           DCA      LONGBASE                              
051221,000232: 01,3503           21165                           DAS      LONGTIME                              
051222,000233: 
051223,000234: 01,3504           11164                           CCS      LONGTIME                              #  FIND OUT HOW THIS SHOULD BE RESTARTED
051224,000235: 01,3505           13515                           TCF      LONGCLCL                              
051225,000236: 01,3506           13510                           TCF      +2                                    
051226,000237: 01,3507           13403                           TCF      IMEDIATE   -3                         
051227,000238: 01,3510           11165                           CCS      LONGTIME   +1                         
051228,000239: 01,3511           13515                           TCF      LONGCLCL                              
051229,000240: 01,3512           13513                           NOOP                                           #  CAN:T GET HERE *********
051230,000241: 01,3513           13403                           TCF      IMEDIATE   -3                         
051231,000242: 01,3514           13406                           TCF      IMEDIATE                              
051232,000243: 
051233,000244: 01,3515           33560        LONGCLCL           CA       LGCLCADR                              #  WE WILL GO TO LONGCALL
051234,000245: 01,3516           54704                           TS       GOLOC      -1                         
051235,000246: 
051236,000247: 01,3517           00006                           EXTEND                                         #  PREPARE OUR ENTRY TO LONGCALL
051237,000248: 01,3520           31165                           DCA      LONGTIME                              
051238,000249: 01,3521           00704                           TC       GOLOC      -1                         
051239,000250: 
051240,000251: 01,3522           33562        ITSLNGCL           CA       WTLTCADR                              #  ASSUME IT WILL GO TO WAITLIST
051241,000252: 01,3523           54704                           TS       GOLOC      -1                         
051242,000253: 
051243,000254: 01,3524           50155                           NDX      TEMP2G                                
051244,000255: 01,3525           41055                           CS       PHSPRDT1                              #  GET THE DELTA T ADDRESS
051245,000256: 
051246,000257: 01,3526           15534                           TCF      ITSLGCL1                              #  NOW GET THE DELTA TIME
051247,000258: 
051248,000259: 01,3527           40706        ITSWTLST           CS       GOLOC      +1                         #  CORRECT THE BBCON INFORMATION
051249,000260: 01,3530           54706                           TS       GOLOC      +1                         
051250,000261: 
051251,000262: 01,3531           50156                           NDX      POINTER                               #  GET THE DT AND FIND OUT IF IT WAS STORED
051252,000263: 01,3532           32000                           CA       PRDTTAB                               #  DIRECTLY OR INDIRECTLY
051253,000264: 
051254,000265: 01,3533           13362                           TCF      TIMETEST                              #  FIND OUT HOW THE TIME IS STORED
051255,000266: 
051256,000267: 01,3534           56705        ITSAJOB2           XCH      GOLOC                                 #  STORE THE CADR
051257,000268: 
051258,000269: 01,3535           50156                           NDX      POINTER                               #  ADD THE PRIORITY AND LET:S GO
051259,000270: 01,3536           32000                           CA       PRDTTAB                               
051260,000271: 
051261,000272: 01,3537           13425                           TCF      CHKNOVAC                              
051262,000273: 
051263,000274: 01,3540           30157        ITSEVEN            CA       TEMPSWCH                              #  SET UP FOR EITHER THE SECOND PART OF THE
051264,000275: 01,3541           54707                           TS       GOLOC      +2                         #  TABLE, OR A RETURN FOR THE NEXT GROUP
051265,000276: 
051266,000277: 01,3542           50155                           NDX      TEMP2G                                #  SET UP POINTER FOR OUR LOCATION WITHIN
051267,000278: 01,3543           32000                           CA       SIZETAB                               #  THE TABLE
051268,000279: 01,3544           60154                           AD       TEMPPHS                               #  THIS MAY LOOK BAD BUT LET:S SEE YOU DO
051269,000280: 01,3545           60154                           AD       TEMPPHS                               #  BETTER IN TIME OR NUMBERR OF LOCATIONS
051270,000281: 01,3546           60154                           AD       TEMPPHS                               
051271,000282: 01,3547           54156                           TS       POINTER                               
051272,000283: 
051273,000284: 01,3550           13453                           TCF      CONTBL2                               #  NOW PROCESS WHAT IS IN THE TABLE
051274,000285: 
051275,000286: 01,3551           36221        PHSPART2           CA       THREE                                 #  SET THE POINTER FOR THE SECOND HALF OF
051276,000287: 01,3552           26156                           ADS      POINTER                               #  THE TABLE
051277,000288: 
051278,000289: 01,3553           33353                           CA       RTRNCADR                              #  THIS WILL BE OUR LAST TIME THROUGH THE
051279,000290: 01,3554           54707                           TS       GOLOC      +2                         #  EVEN TABLE, SO AFTER IT GET THE NEXT
051280,000291:                                                                                                  #  GROUP
051281,000292: 01,3555           13453                           TCF      CONTBL2                               #  SO LET:S GET THE SECOND ENTRY IN THE TBL
051282,000293: 
051283,000294: 01,3556     0154               TEMPPHS            EQUALS   MPAC                                  
051284,000295: 01,3556     0155               TEMP2G             EQUALS   MPAC       +1                         
051285,000296: 01,3556     0156               POINTER            EQUALS   MPAC       +2                         
051286,000297: 01,3556     0157               TEMPSWCH           EQUALS   MPAC       +3                         
051287,000298: 01,3556     0705               GOLOC              EQUALS   VAC5       +20D                       
051288,000299: 01,3556     7720               MINUS2             EQUALS   NEG2                                  
051289,000300: 01,3556     6050               OCT177             EQUALS   LOW7                                  
051290,000301: 
051291,000302: 01,3556           03551        PHS2CADR           GENADR   PHSPART2                              
051292,000303: 01,3557           03327        PRT2CADR           GENADR   GETPART2                              
051293,000304: 01,3560           05337        LGCLCADR           GENADR   LONGCALL                              
051294,000305: 01,3561           05155        FVACCADR           GENADR   FINDVAC                               
051295,000306: 01,3562           05252        WTLTCADR           GENADR   WAITLIST                              
051296,000307: 01,3563           05142        NOVACADR           GENADR   NOVAC                                 
051297,000308: 
051298,000309: 

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