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, 1969
Note 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.

057619,000002:                                                                                                  ## Copyright:   Public domain.
057620,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
057621,000004:                                                                                                  ## Purpose:     A section of Luminary 1C, revision 131.
057622,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
057623,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13.
057624,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
057625,000008:                                                                                                  ##              that the code format has been changed to conform to the
057626,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
057627,000010:                                                                                                  ##              original YUL assembler.
057628,000011:                                                                                                  ## Reference:   pp. 1366-1372
057629,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
057630,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
057631,000014:                                                                                                  ## Mod history: 06/06/03 RSB.   Began transcribing.
057632,000015:                                                                                                  ##              05/14/05 RSB    Corrected website references above.
057633,000016:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
057634,000017:                                                                                                  ##                              original hardcopy, as opposed to the PDF page
057635,000018:                                                                                                  ##                              numbers in 1701.pdf.
057636,000019:                                                                                                  ##              2017-02-28 RSB  Proofed comment text using octopus/ProoferComments.
057637,000020:                                                                                                  ##              2017-03-01 RSB  Fixed lingering comment-text typos.
057638,000021:                                                                                                  ##              2017-03-14 RSB  Comment-text fixes noted in proofing Luminary 116.
057639,000022:                                                                                                  ##              2017-03-16 RSB  Comment-text fixes identified in 5-way
057640,000023:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
057641,000024: 

Page 1366

057643,000026: 10,3545                                           BANK     10                                    
057644,000027: 10,2000                                           SETLOC   DISPLAYS                              
057645,000028: 10,2000                                           BANK                                           
057646,000029: 10,3545                                           COUNT*   $$/DSPLA                              
057647,000030: 
057648,000031: 10,3545           00004        UPENT2             INHINT                                         
057649,000032: 10,3546           75650                           MASK     OCT77770                              
057650,000033: 10,3547           54001                           TS       L                                     
057651,000034: 10,3550           40100                           CS       FLAGWRD4                              
057652,000035: 10,3551           70001                           MASK     L                                     
057653,000036: 10,3552           26100                           ADS      FLAGWRD4                              
057654,000037: 10,3553           00003        JOIN               RELINT                                         
057655,000038: 10,3554           16742                           TCF      Q+1                                   
057656,000039: 
057657,000040: 10,3555           00004        DOWNENT2           INHINT                                         
057658,000041: 10,3556           75650                           MASK     OCT77770                              
057659,000042: 10,3557           40000                           COM                                            
057660,000043: 10,3560           70100                           MASK     FLAGWRD4                              
057661,000044: 10,3561           54100                           TS       FLAGWRD4                              
057662,000045: 10,3562           13553                           TCF      JOIN                                  
057663,000046: 
057664,000047: 10,3563     4757               OCT7               EQUALS   SEVEN                                 
057665,000048: 

Page 1367

057667,000050:                                                                                                  #  UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES.  USING THEM, WHETHER OR
057668,000051:                                                                                                  #  NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
057669,000052:                                                                                                  #  EBANK SETTING.  A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
057670,000053:                                                                                                  #  ASSEMBLER.
057671,000054: 
057672,000055:                                                                                                  #  AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS.  ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
057673,000056:                                                                                                  #  NAME ANY BIT IN ERASABLE MEMORY.
057674,000057: 
057675,000058:                                                                                                  #  CALLING SEQUENCES ARE AS FOLLOWS:-
057676,000059:                                                                                                  #                TC      UPFLAG                  TC      DOWNFLAG
057677,000060:                                                                                                  #                ADRES   NAME OF FLAG            ADRES   NAME OF FLAG
057678,000061: 
057679,000062:                                                                                                  #  RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
057680,000063:                                                                                                  #  UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
057681,000064: 
057682,000065:    5504                                           BLOCK    02                                    
057683,000066:    4000                                           SETLOC   FFTAG1                                
057684,000067:    4000                                           BANK                                           
057685,000068:    5504                                           COUNT*   $$/FLAG                               
057686,000069: 
057687,000070:    5504           30002        UPFLAG             CA       Q                                     
057688,000071:    5505           05522                           TC       DEBIT                                 
057689,000072:    5506           40000                           COM                                            #  +(15 - BIT)
057690,000073:    5507           00006                           EXTEND                                         
057691,000074:    5510           04001                           ROR      LCHAN                                 #  SET BIT
057692,000075:    5511           50061        COMFLAG            INDEX    ITEMP1                                
057693,000076:    5512           54074                           TS       FLAGWRD0                              
057694,000077:    5513           22063                           LXCH     ITEMP3                                
057695,000078:    5514           00003                           RELINT                                         
057696,000079:    5515           00001                           TC       L                                     
057697,000080: 
057698,000081:    5516           30002        DOWNFLAG           CA       Q                                     
057699,000082:    5517           05522                           TC       DEBIT                                 
057700,000083:    5520           70001                           MASK     L                                     #  RESET BIT
057701,000084:    5521           15511                           TCF      COMFLAG                               
057702,000085: 
057703,000086:    5522           64753        DEBIT              AD       ONE                                   #  GET DE BITS
057704,000087:    5523           00004                           INHINT                                         
057705,000088:    5524           54063                           TS       ITEMP3                                
057706,000089:    5525           34762                           CA       LOW4                                  #  DEC15
057707,000090:    5526           54061                           TS       ITEMP1                                
057708,000091:    5527           50063                           INDEX    ITEMP3                                
057709,000092:    5530           27777                           CA       0          -1                         #  ADRES
057710,000093:    5531           54001                           TS       L                                     
057711,000094:    5532           34755                           CA       ZERO                                  

Page 1368

057713,000096:    5533           00006                           EXTEND                                         
057714,000097:    5534           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
057715,000098:    5535           52062                           DXCH     ITEMP1                                
057716,000099:    5536           50061                           INDEX    ITEMP1                                
057717,000100:    5537           30074                           CA       FLAGWRD0                              
057718,000101:    5540           54001                           TS       L                                     #  CURRENT STATE
057719,000102:    5541           50062                           INDEX    ITEMP2                                
057720,000103:    5542           44735                           CS       BIT15                                 #  -(15 - BIT)
057721,000104:    5543           00002                           TC       Q                                     
057722,000105: 

Page 1369

057724,000107:                                                                                                  #  DELAYJOB - A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
057725,000108: 
057726,000109:                                                                                                  #  ENTRANCE REQUIREMENTS ...
057727,000110:                                                                                                  #                CAF     DT              DELAY JOB FOR DT CENTISECS
057728,000111:                                                                                                  #                TC      BANKCALL
057729,000112:                                                                                                  #                CADR    DELAYJOB
057730,000113: 
057731,000114: 06,3772                                           BANK     06                                    
057732,000115: 00,2000                                           SETLOC   DLAYJOB                               
057733,000116: 00,2000                                           BANK                                           
057734,000117: 
057735,000118:                                                                                                  #  THIS MUST REMAIN IN BANK 0 *****************************************
057736,000119: 
057737,000120: 00,3735                                           COUNT*   $$/DELAY                              
057738,000121: 00,3735           35000        2SECDELY           CAF      2SECS                                 
057739,000122: 00,3736           00004        DELAYJOB           INHINT                                         
057740,000123: 00,3737           54002                           TS       Q                                     #  STORE DELAY DT IN Q FOR DLY -1 IN
057741,000124: 00,3740           34752                           CAF      DELAYNUM                              #  WAITLIST
057742,000125: 00,3741           54070        DELLOOP            TS       RUPTREG1                              
057743,000126: 00,3742           50000                           INDEX    A                                     
057744,000127: 00,3743           31323                           CA       DELAYLOC                              #  IS THIS DELAYLOC AVAILABLE
057745,000128: 00,3744           00006                           EXTEND                                         
057746,000129: 00,3745           13753                           BZF      OK2DELAY                              #  YES
057747,000130: 
057748,000131: 00,3746           10070                           CCS      RUPTREG1                              #  NO, TRY NEXT DELAYLOC
057749,000132: 00,3747           13741                           TCF      DELLOOP                               
057750,000133: 
057751,000134: 00,3750           52134                           DXCH     BUF2                                  
057752,000135: 00,3751           05706                           TC       BAILOUT1                              #  NO AVAILABLE LOCS.
057753,000136: 00,3752           31104                           OCT      31104                                 
057754,000137: 
057755,000138: 00,3753           33773        OK2DELAY           CA       TCSLEEP                               #  SET WAITLIST IMMEDIATE RETURN
057756,000139: 00,3754           54061                           TS       WAITEXIT                              
057757,000140: 
057758,000141: 00,3755           30004                           CA       FBANK                                 
057759,000142: 00,3756           60070                           AD       RUPTREG1                              #  STORE BBANK FOR TASK CALL
057760,000143: 00,3757           54001                           TS       L                                     
057761,000144: 
057762,000145: 00,3760           33774                           CAF      WAKECAD                               #  STORE CADR FOR TASK CALL
057763,000146: 00,3761           15211                           TCF      DLY2       -1                         #  DLY IS IN WAITLIST ROUTINE
057764,000147: 
057765,000148: 00,3762           04645        TCGETCAD           TC       MAKECADR                              #  GET CALLERS FCADR
057766,000149: 
057767,000150: 00,3763           50070                           INDEX    RUPTREG1                              
057768,000151: 00,3764           55323                           TS       DELAYLOC                              #  SAVE DELAY CADRS
057769,000152: 
057770,000153: 00,3765           05133                           TC       JOBSLEEP                              
057771,000154: 
057772,000155: 00,3766           34755        WAKER              CAF      ZERO                                  
057773,000156: 00,3767           50006                           INDEX    BBANK                                 

Page 1370

057775,000158: 00,3770           57323                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE
057776,000159: 00,3771           05137                           TC       JOBWAKE                               
057777,000160: 
057778,000161: 00,3772           05261                           TC       TASKOVER                              
057779,000162: 
057780,000163: 00,3773           03760        TCSLEEP            GENADR   TCGETCAD   -2                         
057781,000164: 00,3774           03766        WAKECAD            GENADR   WAKER                                 
057782,000165: 

Page 1371

057784,000167:                                                                                                  #  GENTRAN, A BLOCK TRANSFER ROUTINE.
057785,000168:                                                                                                  #  WRITTEN BY D. EYLES
057786,000169:                                                                                                  #  MOD 1 BY KERNAN                               UTILITYM REV 17 11/18/67
057787,000170:                                                                                                  #  MOD 2 BY SCHULENBERG    (REMOVE RELINT)    SKIPPER REV 4 2/28/68
057788,000171: 
057789,000172:                                                                                                  #  THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
057790,000173:                                                                                                  #  CONSECUTIVE ERASABLE LOCATIONS.  IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
057791,000174: 
057792,000175:                                                                                                  #  GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT.  THE CALLING SEQUENCE IS:
057793,000176:                                                                                                  #        I       CA      N-1             # OF QUANTITIES MINUS ONE.
057794,000177:                                                                                                  #        I +1    TC      GENTRAN         IN FIXED-FIXED.
057795,000178:                                                                                                  #        I +2    ADRES   L               STARTING ADRES OF DATA TO BE MOVED.
057796,000179:                                                                                                  #        I +3    ADRES   M               STARTING ADRES OF DUPLICATION BLOCK.
057797,000180:                                                                                                  #        I +4                            RETURNS HERE.
057798,000181: 
057799,000182:                                                                                                  #  GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
057800,000183:                                                                                                  #  A, L AND ITEMP1 ARE NOT PRESERVED.
057801,000184: 
057802,000185:    5544                                           BLOCK    02                                    
057803,000186:    4000                                           SETLOC   FFTAG4                                
057804,000187:    4000                                           BANK                                           
057805,000188: 
057806,000189:    5544     0061                                  EBANK=   ITEMP1                                
057807,000190: 
057808,000191:    5544                                           COUNT*   $$/TRAN                               
057809,000192: 
057810,000193:    5544           00004        GENTRAN            INHINT                                         
057811,000194:    5545           54061                           TS       ITEMP1                                #  SAVE N-1.
057812,000195:    5546           50002                           INDEX    Q                                     #  C(Q) = ADRES L.
057813,000196:    5547           60000                           AD       0                                     #  ADRES (L + N - 1).
057814,000197:    5550           50000                           INDEX    A                                     
057815,000198:    5551           30000                           CA       0                                     #  C(ABOVE).
057816,000199:    5552           54001                           TS       L                                     #  SAVE DATA.
057817,000200:    5553           30061                           CA       ITEMP1                                
057818,000201:    5554           50002                           INDEX    Q                                     
057819,000202:    5555           60001                           AD       1                                     #  ADRES (M + N - 1).
057820,000203:    5556           50000                           INDEX    A                                     
057821,000204:    5557           22000                           LXCH     0                                     #  STUFF IT.
057822,000205:    5560           10061                           CCS      ITEMP1                                #  LOOP UNTIL N-1 = 0.
057823,000206:    5561           15545                           TCF      GENTRAN    +1                         
057824,000207:    5562           16744                           TCF      Q+2                                   #  RETURN TO CALLER.
057825,000208: 

Page 1372

057827,000210:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
057828,000211:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
057829,000212: 
057830,000213:    5563                                           COUNT*   $$/EXTVB                              
057831,000214: 
057832,000215:    5563           44747        B5OFF              CS       BIT5                                  
057833,000216:    5564           71043                           MASK     EXTVBACT                              
057834,000217:    5565           55043                           TS       EXTVBACT                              
057835,000218:    5566           05155                           TC       ENDOFJOB                              
057836,000219: 
057837,000220: 
057838,000221: 

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