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.

054915,000002:                                                                                                  ## Copyright:   Public domain.
054916,000003:                                                                                                  ## Filename:    RESTARTS_ROUTINE.agc
054917,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
054918,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM) 
054919,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
054920,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
054921,000008:                                                                                                  ##              that the code format has been changed to conform to the
054922,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
054923,000010:                                                                                                  ##              original YUL assembler.
054924,000011:                                                                                                  ## Reference:   pp. 1293-1298
054925,000012:                                                                                                  ## Assembler:   yaYUL
054926,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
054927,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
054928,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
054929,000016:                                                                                                  ##              2017-03-06 RRB  Updated for Luminary 116.
054930,000017:                                                                                                  ##              2017-03-14 RSB  Proofed comment text via 3-way diff vs
054931,000018:                                                                                                  ##                              Luminary 99 and 131.
054932,000019:                                                                                                  ##              2017-03-16 RSB  Comment-text fixes identified in 5-way
054933,000020:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
054934,000021: 

Page 1293

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

Page 1294

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

Page 1295

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

Page 1296

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

Page 1297

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

Page 1298

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

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