Source Code
This source code is very close to the Apollo Guidance Computer software for the
Apollo 13 Lunar module. This revision of the Luminary 131 program is from December
of 1969, whereas there was a later revision in January of 1970, and still another
revision in February, which is the code that flew on the mission.
As far as this transcription is concerned, it was originally from a copy made in 1991 of
a printout from the collection of AGC developer Don Eyles for collector David Craig.
It was subsequently scanned by Gary Neff, reprocessed for online
presentation at the now-discontinued History of Recent Science and Technology (HRST) website
of MIT's Dibner Institute (the full-quality scans being discarded in the process),
and finally transcribed by Ron Burkey for the Virtual AGC Project. Although a
high-quality replacement scan for a completely illegible page was later provided by Gary
Neff, the reduced legibility of the reprocessed HRST posting nevertheless caused many
errors to be introduced into the transcription. Accordingly, a second scan of the same physical
printout was made in 2017 for the Virtual AGC Project's collection at the Internet Archive,
and used to correct the transcription errors. All of the scanned materials mentioned,
as well as other Luminary 131 related material, are available online.
Don Eyles apprently made additional hand-written notes in printout between 1991 and 2017,
so the two scans are not identical in that respect. The page-headings in the printout read, in part:GAP: ASSEMBLE REVISION 131 OF AGC PROGRAM LUMINARY BY NASA 2021112-091 17:53 DEC. 19, 1969Note that the date is the date the printout was made, not the date on which the program revision was released, although these happen to be very close together. |
054660,000002: ## Copyright: Public domain.
054661,000003: ## Filename: RESTARTS_ROUTINE.agc
054662,000004: ## Purpose: A section of Luminary 1C, revision 131.
054663,000005: ## It is part of the source code for the Lunar Module's (LM)
054664,000006: ## Apollo Guidance Computer (AGC) for Apollo 13.
054665,000007: ## This file is intended to be a faithful transcription, except
054666,000008: ## that the code format has been changed to conform to the
054667,000009: ## requirements of the yaYUL assembler rather than the
054668,000010: ## original YUL assembler.
054669,000011: ## Reference: pp. 1295-1300
054670,000012: ## Contact: Ron Burkey <info@sandroid.org>.
054671,000013: ## Website: www.ibiblio.org/apollo/index.html
054672,000014: ## Mod history: 06/05/03 RSB. Began transcribing.
054673,000015: ## 05/14/05 RSB Corrected website references above.
054674,000016: ## 2010-10-25 JL Added missing # in comment.
054675,000017: ## 2017-01-06 RSB Page numbers now agree with those on the
054676,000018: ## original hardcopy, as opposed to the PDF page
054677,000019: ## numbers in 1701.pdf.
054678,000020: ## 2017-02-27 RSB Proofed comment text using octopus/ProoferComments.
054679,000021: ## 2017-03-01 RSB Fixed lingering comment-text typos.
054680,000022: ## 2017-03-14 RSB Comment-text fixes noted in proofing Luminary 116.
054681,000023: ## 2017-03-16 RSB Comment-text fixes identified in 5-way
054682,000024: ## side-by-side diff of Luminary 69/99/116/131/210.
054683,000025:
Page 1295 |
054685,000027: 01,3527 BANK 01
054686,000028: 01,2000 SETLOC RESTART
054687,000029: 01,2000 BANK
054688,000030:
054689,000031: 01,3527 E3,1436 EBANK= PHSNAME1 # GOPROG MUST SWITCH TO THIS EBANK
054690,000032:
054691,000033: 01,3527 COUNT* $$/RSROU
054692,000034: 01,3527 30161 RESTARTS CA MPAC +5 # GET GROUP NUMBER -1
054693,000035: 01,3530 60000 DOUBLE # SAVE FOR INDEXING
054694,000036: 01,3531 54155 TS TEMP2G
054695,000037:
054696,000038: 01,3532 33771 CA PHS2CADR # SET UP EXIT IN CASE IT IS AN EVEN
054697,000039: 01,3533 54157 TS TEMPSWCH # TABLE PHASE
054698,000040:
054699,000041: 01,3534 33566 CA RTRNCADR # TO SAVE TIME ASSUME IT WILL GET NEXT
054700,000042: 01,3535 54707 TS GOLOC +2 # GROUP AFTER THIS
054701,000043:
054702,000044: 01,3536 30154 CA TEMPPHS
054703,000045: 01,3537 75007 MASK OCT1400
054704,000046: 01,3540 10000 CCS A # IS IT A VARIABLE OR TABLE RESTART
054705,000047: 01,3541 13552 TCF ITSAVAR # IT:S A VARIABLE RESTART
054706,000048:
054707,000049: 01,3542 10154 GETPART2 CCS TEMPPHS # IS IT AN X.1 RESTART
054708,000050: 01,3543 10000 CCS A
054709,000051: 01,3544 13652 TCF ITSATBL # NO, ITS A TABLE RESTART
054710,000052:
054711,000053: 01,3545 35024 CA PRIO14 # IT IS AN X.1 RESTART, THEREFORE START
054712,000054: 01,3546 05105 TC FINDVAC # THE DISPLAY RESTART JOB
054713,000055: 01,3547 E3,1400 EBANK= LST1
054714,000056: 01,3547 03040 20103 2CADR INITDSP
054715,000057:
054716,000058: 01,3551 03566 TC RTRNCADR # FINISHED WITH THIS GROUP, GET NEXT ONE
054717,000059:
054718,000060: 01,3552 75007 ITSAVAR MASK OCT1400 # IS IT TYPE B ?
054719,000061: 01,3553 10000 CCS A
054720,000062: 01,3554 13623 TCF ITSLIKEB # YES, IT IS TYPE B
054721,000063:
054722,000064: 01,3555 00006 EXTEND # STORE THE JOB (OR TASK) 2CADR FOR EXIT
054723,000065: 01,3556 50155 NDX TEMP2G
054724,000066: 01,3557 31437 DCA PHSNAME1
054725,000067: 01,3560 52706 DXCH GOLOC
054726,000068:
054727,000069: 01,3561 30154 CA TEMPPHS # SEE IF THIS IS A JOB, TASK, OR A LONGCAL
054728,000070: 01,3562 74757 MASK OCT7
054729,000071: 01,3563 67751 AD MINUS2
054730,000072: 01,3564 10000 CCS A
054731,000073: 01,3565 13735 TCF ITSLNGCL # ITS A LONGCALL
054732,000074:
054733,000075: 01,3566 04631 RTRNCADR TC SWRETURN # CANT GET HERE
Page 1296 |
054735,000077: 01,3567 13571 TCF ITSAWAIT
054736,000078:
054737,000079: 01,3570 13636 TCF ITSAJOB # ITS A JOB
054738,000080:
054739,000081: 01,3571 33775 ITSAWAIT CA WTLTCADR # SET UP WAITLIST CALL
054740,000082: 01,3572 54704 TS GOLOC -1
054741,000083:
054742,000084: 01,3573 50155 NDX TEMP2G # DIRECTLY STORED
054743,000085: 01,3574 31053 CA PHSPRDT1
054744,000086: 01,3575 10000 TIMETEST CCS A # IS IT AN IMMEDIATE RESTART
054745,000087: 01,3576 24000 INCR A # NO,
054746,000088: 01,3577 13602 TCF FINDTIME # FIND OUT WHEN IT SHOULD BEGIN
054747,000089:
054748,000090: 01,3600 15436 TCF ITSINDIR # STORED INDIRECTLY
054749,000091:
054750,000092: 01,3601 13621 TCF IMEDIATE # IT WANTS AN IMMEDIATE RESTART
054751,000093:
054752,000094: # ***** THIS MUST BE IN FIXED FIXED *****
054753,000095:
054754,000096: 5436 BLOCK 02
054755,000097: 4000 SETLOC FFTAG2
054756,000098: 4000 BANK
054757,000099:
054758,000100: 5436 COUNT* $$/RSROU
054759,000101: 5436 22706 ITSINDIR LXCH GOLOC +1 # GET THE CORRECT E BANK IN CASE THIS IS
054760,000102: 5437 22006 LXCH BB # SWITCHED ERRASIBLE
054761,000103:
054762,000104: 5440 50000 NDX A # GET THE TIME INDIRECTLY
054763,000105: 5441 30001 CA 1
054764,000106:
054765,000107: 5442 22006 LXCH BB # RESTORE THE BB AND GOLOC
054766,000108: 5443 22706 LXCH GOLOC +1
054767,000109:
054768,000110: 5444 13602 TCF FINDTIME # FIND OUT WHEN IT SHOULD BEGIN
054769,000111:
054770,000112: # ***** YOU MAY RETURN TO SWITCHED FIXED *****
054771,000113:
054772,000114: 01,3602 BANK 01
054773,000115: 01,2000 SETLOC RESTART
054774,000116: 01,2000 BANK
054775,000117:
054776,000118: 01,3602 COUNT* $$/RSROU
054777,000119: 01,3602 40000 FINDTIME COM # MAKE NEGITIVE SINCE IT WILL BE SUBTRACTD
054778,000120: 01,3603 54001 TS L # AND SAVE
054779,000121: 01,3604 50155 NDX TEMP2G
054780,000122: 01,3605 41052 CS TBASE1
054781,000123: 01,3606 00006 EXTEND
054782,000124: 01,3607 60025 SU TIME1
054783,000125: 01,3610 10000 CCS A
054784,000126: 01,3611 40000 COM
Page 1297 |
054786,000128: 01,3612 67734 AD OCT37776
054787,000129: 01,3613 64753 AD ONE
054788,000130: 01,3614 60001 AD L
054789,000131: 01,3615 10000 CCS A
054790,000132: 01,3616 34755 CA ZERO
054791,000133: 01,3617 13621 TCF +2
054792,000134: 01,3620 13621 TCF +1
054793,000135: 01,3621 64753 IMEDIATE AD ONE
054794,000136: 01,3622 00704 TC GOLOC -1
054795,000137: 01,3623 33566 ITSLIKEB CA RTRNCADR # TYPE B, SO STORE RETURN IN
054796,000138: 01,3624 54157 TS TEMPSWCH # TEMPSWCH IN CASE OF AN EVEN PHASE
054797,000139:
054798,000140: 01,3625 33772 CA PRT2CADR # SET UP EXIT TO GET TABLE PART OF THIS
054799,000141: 01,3626 54707 TS GOLOC +2 # VARIABLE TYPE OF PHASE
054800,000142:
054801,000143: 01,3627 30154 CA TEMPPHS # MAKE THE PHASE LOOK RIGHT FOR THE TABLE
054802,000144: 01,3630 76077 MASK OCT177 # PART OF THIS VARIABLE PHASE
054803,000145: 01,3631 54154 TS TEMPPHS
054804,000146:
054805,000147: 01,3632 00006 EXTEND
054806,000148: 01,3633 50155 NDX TEMP2G # OBTAIN THE JOB:S 2CADR
054807,000149: 01,3634 31437 DCA PHSNAME1
054808,000150: 01,3635 52706 DXCH GOLOC
054809,000151:
054810,000152: 01,3636 50155 ITSAJOB NDX TEMP2G # NOW ADD THE PRIORITY AND LET:S GO
054811,000153: 01,3637 31053 CA PHSPRDT1
054812,000154: 01,3640 54704 CHKNOVAC TS GOLOC -1 # SAVE PRIO UNTIL WE SEE IF ITS
054813,000155: 01,3641 00006 EXTEND # A FINDVAC OR A NOVAC
054814,000156: 01,3642 63646 BZMF ITSNOVAC
054815,000157:
054816,000158: 01,3643 33774 CAF FVACCADR # POSITIVE, SET UP FINDVAC CALL.
054817,000159: 01,3644 56704 XCH GOLOC -1 # PICK UP PRIO,
054818,000160: 01,3645 00704 TC GOLOC -1 # AND GO
054819,000161:
054820,000162: 01,3646 33776 ITSNOVAC CAF NOVACADR # NEGATIVE,
054821,000163: 01,3647 56704 XCH GOLOC -1 # SET UP NOVAC CALL,
054822,000164: 01,3650 40000 COM # CORRECT PRIO,
054823,000165: 01,3651 00704 TC GOLOC -1 # AND GO
054824,000166:
054825,000167: 01,3652 54020 ITSATBL TS CYR # FIND OUT IF THE PHASE IS ODD OR EVEN
054826,000168: 01,3653 10020 CCS CYR
054827,000169: 01,3654 13655 TCF +1 # IT:S EVEN
054828,000170: 01,3655 13753 TCF ITSEVEN
054829,000171:
054830,000172: 01,3656 33566 CA RTRNCADR # IN CASE THIS IS THE SECOND PART OF A
054831,000173: 01,3657 54707 TS GOLOC +2 # TYPE B RESTART, WE NEED PROPER EXIT
054832,000174:
054833,000175: 01,3660 30154 CA TEMPPHS # SET UP POINTER FOR FINDING OUR PLACE IN
054834,000176: 01,3661 54021 TS SR # THE RESTART TABLES
054835,000177: 01,3662 60021 AD SR
Page 1298 |
054837,000179: 01,3663 50155 NDX TEMP2G
054838,000180: 01,3664 62003 AD SIZETAB +1
054839,000181: 01,3665 54156 TS POINTER
054840,000182:
054841,000183: 01,3666 00006 CONTBL2 EXTEND # FIND OUT WHAT:S IN THE TABLE
054842,000184: 01,3667 50156 NDX POINTER
054843,000185: 01,3670 32002 DCA CADRTAB # GET THE 2CADR
054844,000186:
054845,000187: 01,3671 22706 LXCH GOLOC +1 # STORE THE BB INFORMATION
054846,000188:
054847,000189: 01,3672 10000 CCS A # IS IT A JOB OR IS IT TIMED
054848,000190: 01,3673 24000 INCR A # POSITIVE, MUST BE A JOB
054849,000191: 01,3674 13747 TCF ITSAJOB2
054850,000192:
054851,000193: 01,3675 24000 INCR A # MUST BE EITHER A WAITLIST OR LONGCALL
054852,000194: 01,3676 54705 TS GOLOC # LET-S STORE THE CORRECT CADR
054853,000195:
054854,000196: 01,3677 33775 CA WTLTCADR # SET UP OUR EXIT TO WAITLIST
054855,000197: 01,3700 54704 TS GOLOC -1
054856,000198:
054857,000199: 01,3701 30706 CA GOLOC +1 # NOW FIND OUT IF IT IS A WAITLIST CALL
054858,000200: 01,3702 74742 MASK BIT10 # THIS SHOULD BE ONE IF WE HAVE -BB
054859,000201: 01,3703 10000 CCS A # FOR THAT MATTER SO SHOULD BE BITS 9,8,7,
054860,000202: # 6,5, AND LAST BUT NOT LEAST (PERHAPS NOT
054861,000203: # IN IMPORTANCE ANYWAY. BIT 4
054862,000204: 01,3704 13742 TCF ITSWTLST # IT IS A WAITLIST CALL
054863,000205:
054864,000206: 01,3705 50156 NDX POINTER # OBTAIN THE ORIGINAL DELTA T
054865,000207: 01,3706 32000 CA PRDTTAB # ADDRESS FOR THIS LONGCALL
054866,000208:
054867,000209: 01,3707 15445 TCF ITSLGCL1 # NOW GO GET THE DELTA TIME
054868,000210:
054869,000211: # ***** THIS MUST BE IN FIXED FIXED *****
054870,000212:
054871,000213: 5445 BLOCK 02
054872,000214: 4000 SETLOC FFTAG2
054873,000215: 4000 BANK
054874,000216:
054875,000217: 5445 COUNT* $$/RSROU
054876,000218: 5445 22706 ITSLGCL1 LXCH GOLOC +1 # OBTAIN THE CORRECT E BANK
054877,000219: 5446 22006 LXCH BB
054878,000220: 5447 22706 LXCH GOLOC +1 # AND PRESERVE OUR E AND F BANKS
054879,000221:
054880,000222: 5450 00006 EXTEND # GET THE DELTA TIME
054881,000223: 5451 50000 NDX A
054882,000224: 5452 30001 DCA 0
054883,000225:
054884,000226: 5453 22706 LXCH GOLOC +1 # RESTORE OUR E AND F BANK
054885,000227: 5454 22006 LXCH BB # RESTORE THE TASKS E AND F BANKS
054886,000228: 5455 22706 LXCH GOLOC +1 # AND PRESERVE OUR L
Page 1299 |
054888,000230: 5456 13710 TCF ITSLGCL2 # NOW LET:S PROCESS THIS LONGCALL
054889,000231:
054890,000232: # ***** YOU MAY RETURN TO SWITCHED FIXED *****
054891,000233:
054892,000234: 01,3710 BANK 01
054893,000235: 01,2000 SETLOC RESTART
054894,000236: 01,2000 BANK
054895,000237:
054896,000238: 01,3710 COUNT* $$/RSROU
054897,000239: 01,3710 53153 ITSLGCL2 DXCH LONGTIME
054898,000240:
054899,000241: 01,3711 00006 EXTEND # CALCULATE TIME LEFT
054900,000242: 01,3712 40025 DCS TIME2
054901,000243: 01,3713 21153 DAS LONGTIME
054902,000244: 01,3714 00006 EXTEND
054903,000245: 01,3715 31151 DCA LONGBASE
054904,000246: 01,3716 21153 DAS LONGTIME
054905,000247:
054906,000248: 01,3717 11152 CCS LONGTIME # FIND OUT HOW THIS SHOULD BE RESTARTED
054907,000249: 01,3720 13730 TCF LONGCLCL
054908,000250: 01,3721 13723 TCF +2
054909,000251: 01,3722 13616 TCF IMEDIATE -3
054910,000252: 01,3723 11153 CCS LONGTIME +1
054911,000253: 01,3724 13730 TCF LONGCLCL
054912,000254: 01,3725 13726 NOOP # CAN:T GET HERE *********
054913,000255: 01,3726 13616 TCF IMEDIATE -3
054914,000256: 01,3727 13621 TCF IMEDIATE
054915,000257:
054916,000258: 01,3730 33773 LONGCLCL CA LGCLCADR # WE WILL GO TO LONGCALL
054917,000259: 01,3731 54704 TS GOLOC -1
054918,000260:
054919,000261: 01,3732 00006 EXTEND # PREPARE OUR ENTRY TO LONGCALL
054920,000262: 01,3733 31153 DCA LONGTIME
054921,000263: 01,3734 00704 TC GOLOC -1
054922,000264:
054923,000265: 01,3735 33775 ITSLNGCL CA WTLTCADR # ASSUME IT WILL GO TO WAITLIST
054924,000266: 01,3736 54704 TS GOLOC -1
054925,000267:
054926,000268: 01,3737 50155 NDX TEMP2G
054927,000269: 01,3740 41053 CS PHSPRDT1 # GET THE DELTA T ADDRESS
054928,000270:
054929,000271: 01,3741 15445 TCF ITSLGCL1 # NOW GET THE DELTA TIME
054930,000272:
054931,000273: 01,3742 40706 ITSWTLST CS GOLOC +1 # CORRECT THE BBCON INFORMATION
054932,000274: 01,3743 54706 TS GOLOC +1
054933,000275:
054934,000276: 01,3744 50156 NDX POINTER # GET THE DT AND FIND OUT IF IT WAS STORED
054935,000277: 01,3745 32000 CA PRDTTAB # DIRECTLY OR INDIRECTLY
054936,000278:
054937,000279: 01,3746 13575 TCF TIMETEST # FIND OUT HOW THE TIME IS STORED
054938,000280:
Page 1300 |
054940,000282: 01,3747 56705 ITSAJOB2 XCH GOLOC # STORE THE CADR
054941,000283:
054942,000284: 01,3750 50156 NDX POINTER # ADD THE PRIORITY AND LET:S GO
054943,000285: 01,3751 32000 CA PRDTTAB
054944,000286:
054945,000287: 01,3752 13640 TCF CHKNOVAC
054946,000288:
054947,000289: 01,3753 30157 ITSEVEN CA TEMPSWCH # SET UP FOR EITHER THE SECOND PART OF THE
054948,000290: 01,3754 54707 TS GOLOC +2 # TABLE, OR A RETURN FOR THE NEXT GROUP
054949,000291:
054950,000292: 01,3755 50155 NDX TEMP2G # SET UP POINTER FOR OUR LOCATION WITHIN
054951,000293: 01,3756 32002 CA SIZETAB # THE TABLE
054952,000294: 01,3757 60154 AD TEMPPHS # THIS MAY LOOK BAD BUT LET:S SEE YOU DO
054953,000295: 01,3760 60154 AD TEMPPHS # BETTER IN TIME OR NUMBERR OF LOCATIONS
054954,000296: 01,3761 60154 AD TEMPPHS
054955,000297: 01,3762 54156 TS POINTER
054956,000298:
054957,000299: 01,3763 13666 TCF CONTBL2 # NOW PROCESS WHAT IS IN THE TABLE
054958,000300:
054959,000301: 01,3764 36250 PHSPART2 CA THREE # SET THE POINTER FOR THE SECOND HALF OF
054960,000302: 01,3765 26156 ADS POINTER # THE TABLE
054961,000303:
054962,000304: 01,3766 33566 CA RTRNCADR # THIS WILL BE OUR LAST TIME THROUGH THE
054963,000305: 01,3767 54707 TS GOLOC +2 # EVEN TABLE, SO AFTER IT GET THE NEXT
054964,000306: # GROUP
054965,000307: 01,3770 13666 TCF CONTBL2 # SO LET:S GET THE SECOND ENTRY IN THE TBL
054966,000308:
054967,000309: 01,3771 0154 TEMPPHS EQUALS MPAC
054968,000310: 01,3771 0155 TEMP2G EQUALS MPAC +1
054969,000311: 01,3771 0156 POINTER EQUALS MPAC +2
054970,000312: 01,3771 0157 TEMPSWCH EQUALS MPAC +3
054971,000313: 01,3771 0705 GOLOC EQUALS VAC5 +20D
054972,000314: 01,3771 7751 MINUS2 EQUALS NEG2
054973,000315: 01,3771 6077 OCT177 EQUALS LOW7
054974,000316:
054975,000317: 01,3771 03764 PHS2CADR GENADR PHSPART2
054976,000318: 01,3772 03542 PRT2CADR GENADR GETPART2
054977,000319: 01,3773 05277 LGCLCADR GENADR LONGCALL
054978,000320: 01,3774 05105 FVACCADR GENADR FINDVAC
054979,000321: 01,3775 05203 WTLTCADR GENADR WAITLIST
054980,000322: 01,3776 05072 NOVACADR GENADR NOVAC
054981,000323:
054982,000324:
End of include-file RESTARTS_ROUTINE.agc. Parent file is MAIN.agc