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