Source Code

These source-code files derive from a printout of Luminary 116 (the Apollo 12 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Ron Burkey, and transcribed to source code by a team of volunteers. This colorized, syntax-highlighted form was created by assembling that transcribed source code. Note that the full page images are available on the Virtual AGC project page at archive.org, while reduced-size images are presented at the VirtualAGC project website. Report or fix any transcription errors at the Virtual AGC project code repository.

Notations on the program listing read, in part:

	GAP:  ASSEMBLE REVISION 116 OF AGC PROGRAM LUMINARY BY NASA 2021112-071
	19:09 AUG. 11,1969
Note that the date is the date of the printout, not the date of the program revision.

054934,000002:                                                                                                  ## Copyright:   Public domain.
054935,000003:                                                                                                  ## Filename:    RESTARTS_ROUTINE.agc
054936,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
054937,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM) 
054938,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
054939,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
054940,000008:                                                                                                  ##              that the code format has been changed to conform to the
054941,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
054942,000010:                                                                                                  ##              original YUL assembler.
054943,000011:                                                                                                  ## Reference:   pp. 1293-1298
054944,000012:                                                                                                  ## Assembler:   yaYUL
054945,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
054946,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
054947,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
054948,000016:                                                                                                  ##              2017-03-06 RRB  Updated for Luminary 116.
054949,000017:                                                                                                  ##              2017-03-14 RSB  Proofed comment text via 3-way diff vs
054950,000018:                                                                                                  ##                              Luminary 99 and 131.
054951,000019:                                                                                                  ##              2017-03-16 RSB  Comment-text fixes identified in 5-way
054952,000020:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
054953,000021: 

Page 1293

054955,000023: 01,3527                                           BANK     01                                    
054956,000024: 01,2000                                           SETLOC   RESTART                               
054957,000025: 01,2000                                           BANK                                           
054958,000026: 
054959,000027: 01,3527  E3,1436                                  EBANK=   PHSNAME1                              #  GOPROG MUST SWITCH TO THIS EBANK
054960,000028: 
054961,000029: 01,3527                                           COUNT*   $$/RSROU                              
054962,000030: 01,3527           30161        RESTARTS           CA       MPAC       +5                         #  GET GROUP NUMBER -1
054963,000031: 01,3530           60000                           DOUBLE                                         #  SAVE FOR INDEXING
054964,000032: 01,3531           54155                           TS       TEMP2G                                
054965,000033: 
054966,000034: 01,3532           33771                           CA       PHS2CADR                              #  SET UP EXIT IN CASE IT IS AN EVEN
054967,000035: 01,3533           54157                           TS       TEMPSWCH                              #  TABLE PHASE
054968,000036: 
054969,000037: 01,3534           33566                           CA       RTRNCADR                              #  TO SAVE TIME ASSUME IT WILL GET NEXT
054970,000038: 01,3535           54707                           TS       GOLOC      +2                         #  GROUP AFTER THIS
054971,000039: 
054972,000040: 01,3536           30154                           CA       TEMPPHS                               
054973,000041: 01,3537           75007                           MASK     OCT1400                               
054974,000042: 01,3540           10000                           CCS      A                                     #  IS IT A VARIABLE OR TABLE RESTART
054975,000043: 01,3541           13552                           TCF      ITSAVAR                               #  IT:S A VARIABLE RESTART
054976,000044: 
054977,000045: 01,3542           10154        GETPART2           CCS      TEMPPHS                               #  IS IT AN X.1 RESTART
054978,000046: 01,3543           10000                           CCS      A                                     
054979,000047: 01,3544           13652                           TCF      ITSATBL                               #  NO, ITS A TABLE RESTART
054980,000048: 
054981,000049: 01,3545           35024                           CA       PRIO14                                #  IT IS AN X.1 RESTART, THEREFORE START
054982,000050: 01,3546           05105                           TC       FINDVAC                               #  THE DISPLAY RESTART JOB
054983,000051: 01,3547  E3,1400                                  EBANK=   LST1                                  
054984,000052: 01,3547           03040 20103                     2CADR    INITDSP                               
054985,000053: 
054986,000054: 01,3551           03566                           TC       RTRNCADR                              #  FINISHED WITH THIS GROUP, GET NEXT ONE
054987,000055: 
054988,000056: 01,3552           75007        ITSAVAR            MASK     OCT1400                               #  IS IT TYPE B ?
054989,000057: 01,3553           10000                           CCS      A                                     
054990,000058: 01,3554           13623                           TCF      ITSLIKEB                              #  YES,IT IS TYPE B
054991,000059: 
054992,000060: 01,3555           00006                           EXTEND                                         #  STORE THE JOB (OR TASK) 2CADR FOR EXIT
054993,000061: 01,3556           50155                           NDX      TEMP2G                                
054994,000062: 01,3557           31437                           DCA      PHSNAME1                              
054995,000063: 01,3560           52706                           DXCH     GOLOC                                 
054996,000064: 
054997,000065: 01,3561           30154                           CA       TEMPPHS                               #  SEE IF THIS IS A JOB, TASK, OR A LONGCAL
054998,000066: 01,3562           74757                           MASK     OCT7                                  
054999,000067: 01,3563           67751                           AD       MINUS2                                
055000,000068: 01,3564           10000                           CCS      A                                     
055001,000069: 01,3565           13735                           TCF      ITSLNGCL                              #  ITS A LONGCALL
055002,000070: 
055003,000071: 01,3566           04631        RTRNCADR           TC       SWRETURN                              #  CANT GET HERE

Page 1294

055005,000073: 01,3567           13571                           TCF      ITSAWAIT                              
055006,000074: 
055007,000075: 01,3570           13636                           TCF      ITSAJOB                               #  ITS A JOB
055008,000076: 
055009,000077: 01,3571           33775        ITSAWAIT           CA       WTLTCADR                              #  SET UP WAITLIST CALL
055010,000078: 01,3572           54704                           TS       GOLOC      -1                         
055011,000079: 
055012,000080: 01,3573           50155                           NDX      TEMP2G                                #  DIRECTLY STORED
055013,000081: 01,3574           31053                           CA       PHSPRDT1                              
055014,000082: 01,3575           10000        TIMETEST           CCS      A                                     #  IS IT AN IMMEDIATE RESTART
055015,000083: 01,3576           24000                           INCR     A                                     #  NO,
055016,000084: 01,3577           13602                           TCF      FINDTIME                              #  FIND OUT WHEN IT SHOULD BEGIN
055017,000085: 
055018,000086: 01,3600           15436                           TCF      ITSINDIR                              #  STORED INDIRECTLY
055019,000087: 
055020,000088: 01,3601           13621                           TCF      IMEDIATE                              #  IT WANTS AN IMMEDIATE RESTART
055021,000089: 
055022,000090:                                                                                                  #  ***** THIS MUST BE IN FIXED FIXED *****
055023,000091: 
055024,000092:    5436                                           BLOCK    02                                    
055025,000093:    4000                                           SETLOC   FFTAG2                                
055026,000094:    4000                                           BANK                                           
055027,000095: 
055028,000096:    5436                                           COUNT*   $$/RSROU                              
055029,000097:    5436           22706        ITSINDIR           LXCH     GOLOC      +1                         #  GET THE CORRECT E BANK IN CASE THIS IS
055030,000098:    5437           22006                           LXCH     BB                                    #  SWITCHED ERRASIBLE
055031,000099: 
055032,000100:    5440           50000                           NDX      A                                     #  GET THE TIME INDIRECTLY
055033,000101:    5441           30001                           CA       1                                     
055034,000102: 
055035,000103:    5442           22006                           LXCH     BB                                    #  RESTORE THE BB AND GOLOC
055036,000104:    5443           22706                           LXCH     GOLOC      +1                         
055037,000105: 
055038,000106:    5444           13602                           TCF      FINDTIME                              #  FIND OUT WHEN IT SHOULD BEGIN
055039,000107: 
055040,000108:                                                                                                  #  ***** YOU MAY RETURN TO SWITCHED FIXED *****
055041,000109: 
055042,000110: 01,3602                                           BANK     01                                    
055043,000111: 01,2000                                           SETLOC   RESTART                               
055044,000112: 01,2000                                           BANK                                           
055045,000113: 
055046,000114: 01,3602                                           COUNT*   $$/RSROU                              
055047,000115: 01,3602           40000        FINDTIME           COM                                            #  MAKE NEGITIVE SINCE IT WILL BE SUBTRACTD
055048,000116: 01,3603           54001                           TS       L                                     #  AND SAVE
055049,000117: 01,3604           50155                           NDX      TEMP2G                                
055050,000118: 01,3605           41052                           CS       TBASE1                                
055051,000119: 01,3606           00006                           EXTEND                                         
055052,000120: 01,3607           60025                           SU       TIME1                                 
055053,000121: 01,3610           10000                           CCS      A                                     
055054,000122: 01,3611           40000                           COM                                            

Page 1295

055056,000124: 01,3612           67734                           AD       OCT37776                              
055057,000125: 01,3613           64753                           AD       ONE                                   
055058,000126: 01,3614           60001                           AD       L                                     
055059,000127: 01,3615           10000                           CCS      A                                     
055060,000128: 01,3616           34755                           CA       ZERO                                  
055061,000129: 01,3617           13621                           TCF      +2                                    
055062,000130: 01,3620           13621                           TCF      +1                                    
055063,000131: 01,3621           64753        IMEDIATE           AD       ONE                                   
055064,000132: 01,3622           00704                           TC       GOLOC      -1                         
055065,000133: 01,3623           33566        ITSLIKEB           CA       RTRNCADR                              #  TYPE B,             SO STORE RETURN IN
055066,000134: 01,3624           54157                           TS       TEMPSWCH                              #  TEMPSWCH IN CASE OF AN EVEN PHASE
055067,000135: 
055068,000136: 01,3625           33772                           CA       PRT2CADR                              #  SET UP EXIT TO GET TABLE PART OF THIS
055069,000137: 01,3626           54707                           TS       GOLOC      +2                         #  VARIABLE TYPE OF PHASE
055070,000138: 
055071,000139: 01,3627           30154                           CA       TEMPPHS                               #  MAKE THE PHASE LOOK RIGHT FOR THE TABLE
055072,000140: 01,3630           76077                           MASK     OCT177                                #  PART OF THIS VARIABLE PHASE
055073,000141: 01,3631           54154                           TS       TEMPPHS                               
055074,000142: 
055075,000143: 01,3632           00006                           EXTEND                                         
055076,000144: 01,3633           50155                           NDX      TEMP2G                                #  OBTAIN THE JOB:S 2CADR
055077,000145: 01,3634           31437                           DCA      PHSNAME1                              
055078,000146: 01,3635           52706                           DXCH     GOLOC                                 
055079,000147: 
055080,000148: 01,3636           50155        ITSAJOB            NDX      TEMP2G                                #  NOW ADD THE PRIORITY AND LET:S GO
055081,000149: 01,3637           31053                           CA       PHSPRDT1                              
055082,000150: 01,3640           54704        CHKNOVAC           TS       GOLOC      -1                         #  SAVE PRIO UNTIL WE SEE IF ITS
055083,000151: 01,3641           00006                           EXTEND                                         #  A FINDVAC OR A NOVAC
055084,000152: 01,3642           63646                           BZMF     ITSNOVAC                              
055085,000153: 
055086,000154: 01,3643           33774                           CAF      FVACCADR                              #  POSITIVE, SET UP FINDVAC CALL.
055087,000155: 01,3644           56704                           XCH      GOLOC      -1                         #  PICK UP PRIO,
055088,000156: 01,3645           00704                           TC       GOLOC      -1                         #  AND GO
055089,000157: 
055090,000158: 01,3646           33776        ITSNOVAC           CAF      NOVACADR                              #  NEGATIVE,
055091,000159: 01,3647           56704                           XCH      GOLOC      -1                         #  SET UP NOVAC CALL,
055092,000160: 01,3650           40000                           COM                                            #  CORRECT PRIO,
055093,000161: 01,3651           00704                           TC       GOLOC      -1                         #  AND GO
055094,000162: 
055095,000163: 01,3652           54020        ITSATBL            TS       CYR                                   #  FIND OUT IF THE PHASE IS ODD OR EVEN
055096,000164: 01,3653           10020                           CCS      CYR                                   
055097,000165: 01,3654           13655                           TCF      +1                                    #  IT:S EVEN
055098,000166: 01,3655           13753                           TCF      ITSEVEN                               
055099,000167: 
055100,000168: 01,3656           33566                           CA       RTRNCADR                              #  IN CASE THIS IS THE SECOND PART OF A
055101,000169: 01,3657           54707                           TS       GOLOC      +2                         #  TYPE B RESTART, WE NEED PROPER EXIT
055102,000170: 
055103,000171: 01,3660           30154                           CA       TEMPPHS                               #  SET UP POINTER FOR FINDING OUR PLACE IN
055104,000172: 01,3661           54021                           TS       SR                                    #  THE RESTART TABLES
055105,000173: 01,3662           60021                           AD       SR                                    

Page 1296

055107,000175: 01,3663           50155                           NDX      TEMP2G                                
055108,000176: 01,3664           62003                           AD       SIZETAB    +1                         
055109,000177: 01,3665           54156                           TS       POINTER                               
055110,000178: 
055111,000179: 01,3666           00006        CONTBL2            EXTEND                                         #  FIND OUT WHAT:S IN THE TABLE
055112,000180: 01,3667           50156                           NDX      POINTER                               
055113,000181: 01,3670           32002                           DCA      CADRTAB                               #  GET THE 2CADR
055114,000182: 
055115,000183: 01,3671           22706                           LXCH     GOLOC      +1                         #  STORE THE BB INFORMATION
055116,000184: 
055117,000185: 01,3672           10000                           CCS      A                                     #  IS IT A JOB OR IS IT TIMED
055118,000186: 01,3673           24000                           INCR     A                                     #  POSITIVE, MUST BE A JOB
055119,000187: 01,3674           13747                           TCF      ITSAJOB2                              
055120,000188: 
055121,000189: 01,3675           24000                           INCR     A                                     #  MUST BE EITHER A WAITLIST OR LONGCALL
055122,000190: 01,3676           54705                           TS       GOLOC                                 #  LET-S STORE THE CORRECT CADR
055123,000191: 
055124,000192: 01,3677           33775                           CA       WTLTCADR                              #  SET UP OUR EXIT TO WAITLIST
055125,000193: 01,3700           54704                           TS       GOLOC      -1                         
055126,000194: 
055127,000195: 01,3701           30706                           CA       GOLOC      +1                         #  NOW FIND OUT IF IT IS A WAITLIST CALL
055128,000196: 01,3702           74742                           MASK     BIT10                                 #  THIS SHOULD BE ONE IF WE HAVE -BB
055129,000197: 01,3703           10000                           CCS      A                                     #  FOR THAT MATTER SO SHOULD BE BITS 9,8,7,
055130,000198:                                                                                                  #  6,5, AND LAST BUT NOT LEAST (PERHAPS NOT
055131,000199:                                                                                                  #  IN IMPORTANCE ANYWAY. BIT 4
055132,000200: 01,3704           13742                           TCF      ITSWTLST                              #  IT IS A WAITLIST CALL
055133,000201: 
055134,000202: 01,3705           50156                           NDX      POINTER                               #  OBTAIN THE ORIGINAL DELTA T
055135,000203: 01,3706           32000                           CA       PRDTTAB                               #  ADDRESS FOR THIS LONGCALL
055136,000204: 
055137,000205: 01,3707           15445                           TCF      ITSLGCL1                              #  NOW GO GET THE DELTA TIME
055138,000206: 
055139,000207:                                                                                                  #  ***** THIS MUST BE IN FIXED FIXED *****
055140,000208: 
055141,000209:    5445                                           BLOCK    02                                    
055142,000210:    4000                                           SETLOC   FFTAG2                                
055143,000211:    4000                                           BANK                                           
055144,000212: 
055145,000213:    5445                                           COUNT*   $$/RSROU                              
055146,000214:    5445           22706        ITSLGCL1           LXCH     GOLOC      +1                         #  OBTAIN THE CORRECT E BANK
055147,000215:    5446           22006                           LXCH     BB                                    
055148,000216:    5447           22706                           LXCH     GOLOC      +1                         #  AND PRESERVE OUR E AND F BANKS
055149,000217: 
055150,000218:    5450           00006                           EXTEND                                         #  GET THE DELTA TIME
055151,000219:    5451           50000                           NDX      A                                     
055152,000220:    5452           30001                           DCA      0                                     
055153,000221: 
055154,000222:    5453           22706                           LXCH     GOLOC      +1                         #  RESTORE OUR E AND F BANK
055155,000223:    5454           22006                           LXCH     BB                                    #  RESTORE THE TASKS E AND F BANKS
055156,000224:    5455           22706                           LXCH     GOLOC      +1                         #  AND PRESERVE OUR L

Page 1297

055158,000226:    5456           13710                           TCF      ITSLGCL2                              #  NOW LET:S PROCESS THIS LONGCALL
055159,000227: 
055160,000228:                                                                                                  #  ***** YOU MAY RETURN TO SWITCHED FIXED *****
055161,000229: 
055162,000230: 01,3710                                           BANK     01                                    
055163,000231: 01,2000                                           SETLOC   RESTART                               
055164,000232: 01,2000                                           BANK                                           
055165,000233: 
055166,000234: 01,3710                                           COUNT*   $$/RSROU                              
055167,000235: 01,3710           53153        ITSLGCL2           DXCH     LONGTIME                              
055168,000236: 
055169,000237: 01,3711           00006                           EXTEND                                         #  CALCULATE TIME LEFT
055170,000238: 01,3712           40025                           DCS      TIME2                                 
055171,000239: 01,3713           21153                           DAS      LONGTIME                              
055172,000240: 01,3714           00006                           EXTEND                                         
055173,000241: 01,3715           31151                           DCA      LONGBASE                              
055174,000242: 01,3716           21153                           DAS      LONGTIME                              
055175,000243: 
055176,000244: 01,3717           11152                           CCS      LONGTIME                              #  FIND OUT HOW THIS SHOULD BE RESTARTED
055177,000245: 01,3720           13730                           TCF      LONGCLCL                              
055178,000246: 01,3721           13723                           TCF      +2                                    
055179,000247: 01,3722           13616                           TCF      IMEDIATE   -3                         
055180,000248: 01,3723           11153                           CCS      LONGTIME   +1                         
055181,000249: 01,3724           13730                           TCF      LONGCLCL                              
055182,000250: 01,3725           13726                           NOOP                                           #  CAN:T GET HERE    *********
055183,000251: 01,3726           13616                           TCF      IMEDIATE   -3                         
055184,000252: 01,3727           13621                           TCF      IMEDIATE                              
055185,000253: 
055186,000254: 01,3730           33773        LONGCLCL           CA       LGCLCADR                              #  WE WILL GO TO LONGCALL
055187,000255: 01,3731           54704                           TS       GOLOC      -1                         
055188,000256: 
055189,000257: 01,3732           00006                           EXTEND                                         #  PREPARE OUR ENTRY TO LONGCALL
055190,000258: 01,3733           31153                           DCA      LONGTIME                              
055191,000259: 01,3734           00704                           TC       GOLOC      -1                         
055192,000260: 
055193,000261: 01,3735           33775        ITSLNGCL           CA       WTLTCADR                              #  ASSUME IT WILL GO TO WAITLIST
055194,000262: 01,3736           54704                           TS       GOLOC      -1                         
055195,000263: 
055196,000264: 01,3737           50155                           NDX      TEMP2G                                
055197,000265: 01,3740           41053                           CS       PHSPRDT1                              #  GET THE DELTA T ADDRESS
055198,000266: 
055199,000267: 01,3741           15445                           TCF      ITSLGCL1                              #  NOW GET THE DELTA TIME
055200,000268: 
055201,000269: 01,3742           40706        ITSWTLST           CS       GOLOC      +1                         #  CORRECT THE BBCON INFORMATION
055202,000270: 01,3743           54706                           TS       GOLOC      +1                         
055203,000271: 
055204,000272: 01,3744           50156                           NDX      POINTER                               #  GET THE DT AND FIND OUT IF IT WAS STORED
055205,000273: 01,3745           32000                           CA       PRDTTAB                               #  DIRECTLY OR INDIRECTLY
055206,000274: 
055207,000275: 01,3746           13575                           TCF      TIMETEST                              #  FIND OUT HOW THE TIME IS STORED
055208,000276: 

Page 1298

055210,000278: 01,3747           56705        ITSAJOB2           XCH      GOLOC                                 #  STORE THE CADR
055211,000279: 
055212,000280: 01,3750           50156                           NDX      POINTER                               #  ADD THE PRIORITY AND LET:S GO
055213,000281: 01,3751           32000                           CA       PRDTTAB                               
055214,000282: 
055215,000283: 01,3752           13640                           TCF      CHKNOVAC                              
055216,000284: 
055217,000285: 01,3753           30157        ITSEVEN            CA       TEMPSWCH                              #  SET UP FOR EITHER THE SECOND PART OF THE
055218,000286: 01,3754           54707                           TS       GOLOC      +2                         #  TABLE, OR A RETURN FOR THE NEXT GROUP
055219,000287: 
055220,000288: 01,3755           50155                           NDX      TEMP2G                                #  SET UP POINTER FOR OUR LOCATION WITHIN
055221,000289: 01,3756           32002                           CA       SIZETAB                               #  THE TABLE
055222,000290: 01,3757           60154                           AD       TEMPPHS                               #  THIS MAY LOOK BAD BUT LET:S SEE YOU DO
055223,000291: 01,3760           60154                           AD       TEMPPHS                               #  BETTER IN TIME OR NUMBERR OF LOCATIONS
055224,000292: 01,3761           60154                           AD       TEMPPHS                               
055225,000293: 01,3762           54156                           TS       POINTER                               
055226,000294: 
055227,000295: 01,3763           13666                           TCF      CONTBL2                               #  NOW PROCESS WHAT IS IN THE TABLE
055228,000296: 
055229,000297: 01,3764           36250        PHSPART2           CA       THREE                                 #  SET THE POINTER FOR THE SECOND HALF OF
055230,000298: 01,3765           26156                           ADS      POINTER                               #  THE TABLE
055231,000299: 
055232,000300: 01,3766           33566                           CA       RTRNCADR                              #  THIS WILL BE OUR LAST TIME THROUGH THE
055233,000301: 01,3767           54707                           TS       GOLOC      +2                         #  EVEN TABLE, SO AFTER IT GET THE NEXT
055234,000302:                                                                                                  #  GROUP
055235,000303: 01,3770           13666                           TCF      CONTBL2                               #  SO LET:S GET THE SECOND ENTRY IN THE TBL
055236,000304: 
055237,000305: 01,3771     0154               TEMPPHS            EQUALS   MPAC                                  
055238,000306: 01,3771     0155               TEMP2G             EQUALS   MPAC       +1                         
055239,000307: 01,3771     0156               POINTER            EQUALS   MPAC       +2                         
055240,000308: 01,3771     0157               TEMPSWCH           EQUALS   MPAC       +3                         
055241,000309: 01,3771     0705               GOLOC              EQUALS   VAC5       +20D                       
055242,000310: 01,3771     7751               MINUS2             EQUALS   NEG2                                  
055243,000311: 01,3771     6077               OCT177             EQUALS   LOW7                                  
055244,000312: 
055245,000313: 01,3771           03764        PHS2CADR           GENADR   PHSPART2                              
055246,000314: 01,3772           03542        PRT2CADR           GENADR   GETPART2                              
055247,000315: 01,3773           05277        LGCLCADR           GENADR   LONGCALL                              
055248,000316: 01,3774           05105        FVACCADR           GENADR   FINDVAC                               
055249,000317: 01,3775           05203        WTLTCADR           GENADR   WAITLIST                              
055250,000318: 01,3776           05072        NOVACADR           GENADR   NOVAC                                 
055251,000319: 
055252,000320: 

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