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. |
057648,000002: ## Copyright: Public domain.
057649,000003: ## Filename: SERVICE_ROUTINES.agc
057650,000004: ## Purpose: A section of Luminary 1C, revision 131.
057651,000005: ## It is part of the source code for the Lunar Module's (LM)
057652,000006: ## Apollo Guidance Computer (AGC) for Apollo 13.
057653,000007: ## This file is intended to be a faithful transcription, except
057654,000008: ## that the code format has been changed to conform to the
057655,000009: ## requirements of the yaYUL assembler rather than the
057656,000010: ## original YUL assembler.
057657,000011: ## Reference: pp. 1366-1372
057658,000012: ## Contact: Ron Burkey <info@sandroid.org>.
057659,000013: ## Website: www.ibiblio.org/apollo/index.html
057660,000014: ## Mod history: 06/06/03 RSB. Began transcribing.
057661,000015: ## 05/14/05 RSB Corrected website references above.
057662,000016: ## 2017-01-06 RSB Page numbers now agree with those on the
057663,000017: ## original hardcopy, as opposed to the PDF page
057664,000018: ## numbers in 1701.pdf.
057665,000019: ## 2017-02-28 RSB Proofed comment text using octopus/ProoferComments.
057666,000020: ## 2017-03-01 RSB Fixed lingering comment-text typos.
057667,000021: ## 2017-03-14 RSB Comment-text fixes noted in proofing Luminary 116.
057668,000022: ## 2017-03-16 RSB Comment-text fixes identified in 5-way
057669,000023: ## side-by-side diff of Luminary 69/99/116/131/210.
057670,000024:
Page 1366 |
057672,000026: 10,3545 BANK 10
057673,000027: 10,2000 SETLOC DISPLAYS
057674,000028: 10,2000 BANK
057675,000029: 10,3545 COUNT* $$/DSPLA
057676,000030:
057677,000031: 10,3545 00004 UPENT2 INHINT
057678,000032: 10,3546 75650 MASK OCT77770
057679,000033: 10,3547 54001 TS L
057680,000034: 10,3550 40100 CS FLAGWRD4
057681,000035: 10,3551 70001 MASK L
057682,000036: 10,3552 26100 ADS FLAGWRD4
057683,000037: 10,3553 00003 JOIN RELINT
057684,000038: 10,3554 16742 TCF Q+1
057685,000039:
057686,000040: 10,3555 00004 DOWNENT2 INHINT
057687,000041: 10,3556 75650 MASK OCT77770
057688,000042: 10,3557 40000 COM
057689,000043: 10,3560 70100 MASK FLAGWRD4
057690,000044: 10,3561 54100 TS FLAGWRD4
057691,000045: 10,3562 13553 TCF JOIN
057692,000046:
057693,000047: 10,3563 4757 OCT7 EQUALS SEVEN
057694,000048:
Page 1367 |
057696,000050: # UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES. USING THEM, WHETHER OR
057697,000051: # NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
057698,000052: # EBANK SETTING. A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
057699,000053: # ASSEMBLER.
057700,000054:
057701,000055: # AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS. ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
057702,000056: # NAME ANY BIT IN ERASABLE MEMORY.
057703,000057:
057704,000058: # CALLING SEQUENCES ARE AS FOLLOWS:-
057705,000059: # TC UPFLAG TC DOWNFLAG
057706,000060: # ADRES NAME OF FLAG ADRES NAME OF FLAG
057707,000061:
057708,000062: # RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
057709,000063: # UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
057710,000064:
057711,000065: 5504 BLOCK 02
057712,000066: 4000 SETLOC FFTAG1
057713,000067: 4000 BANK
057714,000068: 5504 COUNT* $$/FLAG
057715,000069:
057716,000070: 5504 30002 UPFLAG CA Q
057717,000071: 5505 05522 TC DEBIT
057718,000072: 5506 40000 COM # +(15 - BIT)
057719,000073: 5507 00006 EXTEND
057720,000074: 5510 04001 ROR LCHAN # SET BIT
057721,000075: 5511 50061 COMFLAG INDEX ITEMP1
057722,000076: 5512 54074 TS FLAGWRD0
057723,000077: 5513 22063 LXCH ITEMP3
057724,000078: 5514 00003 RELINT
057725,000079: 5515 00001 TC L
057726,000080:
057727,000081: 5516 30002 DOWNFLAG CA Q
057728,000082: 5517 05522 TC DEBIT
057729,000083: 5520 70001 MASK L # RESET BIT
057730,000084: 5521 15511 TCF COMFLAG
057731,000085:
057732,000086: 5522 64753 DEBIT AD ONE # GET DE BITS
057733,000087: 5523 00004 INHINT
057734,000088: 5524 54063 TS ITEMP3
057735,000089: 5525 34762 CA LOW4 # DEC15
057736,000090: 5526 54061 TS ITEMP1
057737,000091: 5527 50063 INDEX ITEMP3
057738,000092: 5530 27777 CA 0 -1 # ADRES
057739,000093: 5531 54001 TS L
057740,000094: 5532 34755 CA ZERO
Page 1368 |
057742,000096: 5533 00006 EXTEND
057743,000097: 5534 10061 DV ITEMP1 # A = FLAGWRD, L = (15 - BIT)
057744,000098: 5535 52062 DXCH ITEMP1
057745,000099: 5536 50061 INDEX ITEMP1
057746,000100: 5537 30074 CA FLAGWRD0
057747,000101: 5540 54001 TS L # CURRENT STATE
057748,000102: 5541 50062 INDEX ITEMP2
057749,000103: 5542 44735 CS BIT15 # -(15 - BIT)
057750,000104: 5543 00002 TC Q
057751,000105:
Page 1369 |
057753,000107: # DELAYJOB - A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
057754,000108:
057755,000109: # ENTRANCE REQUIREMENTS ...
057756,000110: # CAF DT DELAY JOB FOR DT CENTISECS
057757,000111: # TC BANKCALL
057758,000112: # CADR DELAYJOB
057759,000113:
057760,000114: 06,3772 BANK 06
057761,000115: 00,2000 SETLOC DLAYJOB
057762,000116: 00,2000 BANK
057763,000117:
057764,000118: # THIS MUST REMAIN IN BANK 0 *****************************************
057765,000119:
057766,000120: 00,3735 COUNT* $$/DELAY
057767,000121: 00,3735 35000 2SECDELY CAF 2SECS
057768,000122: 00,3736 00004 DELAYJOB INHINT
057769,000123: 00,3737 54002 TS Q # STORE DELAY DT IN Q FOR DLY -1 IN
057770,000124: 00,3740 34752 CAF DELAYNUM # WAITLIST
057771,000125: 00,3741 54070 DELLOOP TS RUPTREG1
057772,000126: 00,3742 50000 INDEX A
057773,000127: 00,3743 31323 CA DELAYLOC # IS THIS DELAYLOC AVAILABLE
057774,000128: 00,3744 00006 EXTEND
057775,000129: 00,3745 13753 BZF OK2DELAY # YES
057776,000130:
057777,000131: 00,3746 10070 CCS RUPTREG1 # NO, TRY NEXT DELAYLOC
057778,000132: 00,3747 13741 TCF DELLOOP
057779,000133:
057780,000134: 00,3750 52134 DXCH BUF2
057781,000135: 00,3751 05706 TC BAILOUT1 # NO AVAILABLE LOCS.
057782,000136: 00,3752 31104 OCT 31104
057783,000137:
057784,000138: 00,3753 33773 OK2DELAY CA TCSLEEP # SET WAITLIST IMMEDIATE RETURN
057785,000139: 00,3754 54061 TS WAITEXIT
057786,000140:
057787,000141: 00,3755 30004 CA FBANK
057788,000142: 00,3756 60070 AD RUPTREG1 # STORE BBANK FOR TASK CALL
057789,000143: 00,3757 54001 TS L
057790,000144:
057791,000145: 00,3760 33774 CAF WAKECAD # STORE CADR FOR TASK CALL
057792,000146: 00,3761 15211 TCF DLY2 -1 # DLY IS IN WAITLIST ROUTINE
057793,000147:
057794,000148: 00,3762 04645 TCGETCAD TC MAKECADR # GET CALLERS FCADR
057795,000149:
057796,000150: 00,3763 50070 INDEX RUPTREG1
057797,000151: 00,3764 55323 TS DELAYLOC # SAVE DELAY CADRS
057798,000152:
057799,000153: 00,3765 05133 TC JOBSLEEP
057800,000154:
057801,000155: 00,3766 34755 WAKER CAF ZERO
057802,000156: 00,3767 50006 INDEX BBANK
Page 1370 |
057804,000158: 00,3770 57323 XCH DELAYLOC # MAKE DELAYLOC AVAILABLE
057805,000159: 00,3771 05137 TC JOBWAKE
057806,000160:
057807,000161: 00,3772 05261 TC TASKOVER
057808,000162:
057809,000163: 00,3773 03760 TCSLEEP GENADR TCGETCAD -2
057810,000164: 00,3774 03766 WAKECAD GENADR WAKER
057811,000165:
Page 1371 |
057813,000167: # GENTRAN, A BLOCK TRANSFER ROUTINE.
057814,000168: # WRITTEN BY D. EYLES
057815,000169: # MOD 1 BY KERNAN UTILITYM REV 17 11/18/67
057816,000170: # MOD 2 BY SCHULENBERG (REMOVE RELINT) SKIPPER REV 4 2/28/68
057817,000171:
057818,000172: # THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
057819,000173: # CONSECUTIVE ERASABLE LOCATIONS. IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
057820,000174:
057821,000175: # GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT. THE CALLING SEQUENCE IS:
057822,000176: # I CA N-1 # OF QUANTITIES MINUS ONE.
057823,000177: # I +1 TC GENTRAN IN FIXED-FIXED.
057824,000178: # I +2 ADRES L STARTING ADRES OF DATA TO BE MOVED.
057825,000179: # I +3 ADRES M STARTING ADRES OF DUPLICATION BLOCK.
057826,000180: # I +4 RETURNS HERE.
057827,000181:
057828,000182: # GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
057829,000183: # A, L AND ITEMP1 ARE NOT PRESERVED.
057830,000184:
057831,000185: 5544 BLOCK 02
057832,000186: 4000 SETLOC FFTAG4
057833,000187: 4000 BANK
057834,000188:
057835,000189: 5544 0061 EBANK= ITEMP1
057836,000190:
057837,000191: 5544 COUNT* $$/TRAN
057838,000192:
057839,000193: 5544 00004 GENTRAN INHINT
057840,000194: 5545 54061 TS ITEMP1 # SAVE N-1.
057841,000195: 5546 50002 INDEX Q # C(Q) = ADRES L.
057842,000196: 5547 60000 AD 0 # ADRES (L + N - 1).
057843,000197: 5550 50000 INDEX A
057844,000198: 5551 30000 CA 0 # C(ABOVE).
057845,000199: 5552 54001 TS L # SAVE DATA.
057846,000200: 5553 30061 CA ITEMP1
057847,000201: 5554 50002 INDEX Q
057848,000202: 5555 60001 AD 1 # ADRES (M + N - 1).
057849,000203: 5556 50000 INDEX A
057850,000204: 5557 22000 LXCH 0 # STUFF IT.
057851,000205: 5560 10061 CCS ITEMP1 # LOOP UNTIL N-1 = 0.
057852,000206: 5561 15545 TCF GENTRAN +1
057853,000207: 5562 16744 TCF Q+2 # RETURN TO CALLER.
057854,000208:
Page 1372 |
057856,000210: # B5OFF ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
057857,000211: # MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
057858,000212:
057859,000213: 5563 COUNT* $$/EXTVB
057860,000214:
057861,000215: 5563 44747 B5OFF CS BIT5
057862,000216: 5564 71043 MASK EXTVBACT
057863,000217: 5565 55043 TS EXTVBACT
057864,000218: 5566 05155 TC ENDOFJOB
057865,000219:
057866,000220:
057867,000221:
End of include-file SERVICE_ROUTINES.agc. Parent file is MAIN.agc