Source Code

These source-code files are part of a reconstructed copy of LM131 revision 1, the final release of the Apollo 13 Lunar Module (LM) Apollo Guidance Computer (AGC) software.

The source reconstruction began with source code of Luminary 131 previously transcribed from a digitized copy of that program. A dump of the flight spare core rope memory module B5, part number 2010802-171, serial number RAY 411, was obtained. This module is the only module different between Luminary 131 and LM131 revision 1. The dump was disassembled and all changes were incorporated into these source files. Note that page numbers in the reconstructed code match those on the Luminary 131 printout, although the changed code would likely have changed page numbers for a real LM131 revision 1 listing.

Comments from the original source code are prefixed with a single '#' symbol, whereas comments added later are prefixed by "##" or "###". Report any errors noted by creating an issue report at the Virtual AGC project's GitHub repository.

057476,000002:                                                                                                  ## Copyright:   Public domain.
057477,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
057478,000004:                                                                                                  ## Purpose:     A section of LM131 revision 1.
057479,000005:                                                                                                  ##              It is part of the reconstructed source code for the final
057480,000006:                                                                                                  ##              release of the flight software for the Lunar Module's (LM)
057481,000007:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13. The code has
057482,000008:                                                                                                  ##              been reconstructed from a listing of Luminary 131 and a dump
057483,000009:                                                                                                  ##              of a core rope memory module B5, part number 2010802-171,
057484,000010:                                                                                                  ##              which is the only module different between LM131 revision 1
057485,000011:                                                                                                  ##              and Luminary 131. The executable generated from this source
057486,000012:                                                                                                  ##              has been verified against the module dump, so while the names,
057487,000013:                                                                                                  ##              comments, and ordering may not be exactly correct, the
057488,000014:                                                                                                  ##              resulting binary is.
057489,000015:                                                                                                  ## Reference:   pp. 1366-1372
057490,000016:                                                                                                  ## Assembler:   yaYUL
057491,000017:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
057492,000018:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
057493,000019:                                                                                                  ## Mod history: 2022-10-28 MAS  Created from Luminary 131.
057494,000020: 

Page 1366

057496,000022: 10,3545                                           BANK     10                                    
057497,000023: 10,2000                                           SETLOC   DISPLAYS                              
057498,000024: 10,2000                                           BANK                                           
057499,000025: 10,3545                                           COUNT*   $$/DSPLA                              
057500,000026: 
057501,000027: 10,3545           00004        UPENT2             INHINT                                         
057502,000028: 10,3546           75650                           MASK     OCT77770                              
057503,000029: 10,3547           54001                           TS       L                                     
057504,000030: 10,3550           40100                           CS       FLAGWRD4                              
057505,000031: 10,3551           70001                           MASK     L                                     
057506,000032: 10,3552           26100                           ADS      FLAGWRD4                              
057507,000033: 10,3553           00003        JOIN               RELINT                                         
057508,000034: 10,3554           16742                           TCF      Q+1                                   
057509,000035: 
057510,000036: 10,3555           00004        DOWNENT2           INHINT                                         
057511,000037: 10,3556           75650                           MASK     OCT77770                              
057512,000038: 10,3557           40000                           COM                                            
057513,000039: 10,3560           70100                           MASK     FLAGWRD4                              
057514,000040: 10,3561           54100                           TS       FLAGWRD4                              
057515,000041: 10,3562           13553                           TCF      JOIN                                  
057516,000042: 
057517,000043: 10,3563     4757               OCT7               EQUALS   SEVEN                                 
057518,000044: 

Page 1367

057520,000046:                                                                                                  #  UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES.  USING THEM, WHETHER OR
057521,000047:                                                                                                  #  NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
057522,000048:                                                                                                  #  EBANK SETTING.  A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
057523,000049:                                                                                                  #  ASSEMBLER.
057524,000050: 
057525,000051:                                                                                                  #  AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS.  ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
057526,000052:                                                                                                  #  NAME ANY BIT IN ERASABLE MEMORY.
057527,000053: 
057528,000054:                                                                                                  #  CALLING SEQUENCES ARE AS FOLLOWS:-
057529,000055:                                                                                                  #                TC      UPFLAG                  TC      DOWNFLAG
057530,000056:                                                                                                  #                ADRES   NAME OF FLAG            ADRES   NAME OF FLAG
057531,000057: 
057532,000058:                                                                                                  #  RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
057533,000059:                                                                                                  #  UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
057534,000060: 
057535,000061:    5504                                           BLOCK    02                                    
057536,000062:    4000                                           SETLOC   FFTAG1                                
057537,000063:    4000                                           BANK                                           
057538,000064:    5504                                           COUNT*   $$/FLAG                               
057539,000065: 
057540,000066:    5504           30002        UPFLAG             CA       Q                                     
057541,000067:    5505           05522                           TC       DEBIT                                 
057542,000068:    5506           40000                           COM                                            #  +(15 - BIT)
057543,000069:    5507           00006                           EXTEND                                         
057544,000070:    5510           04001                           ROR      LCHAN                                 #  SET BIT
057545,000071:    5511           50061        COMFLAG            INDEX    ITEMP1                                
057546,000072:    5512           54074                           TS       FLAGWRD0                              
057547,000073:    5513           22063                           LXCH     ITEMP3                                
057548,000074:    5514           00003                           RELINT                                         
057549,000075:    5515           00001                           TC       L                                     
057550,000076: 
057551,000077:    5516           30002        DOWNFLAG           CA       Q                                     
057552,000078:    5517           05522                           TC       DEBIT                                 
057553,000079:    5520           70001                           MASK     L                                     #  RESET BIT
057554,000080:    5521           15511                           TCF      COMFLAG                               
057555,000081: 
057556,000082:    5522           64753        DEBIT              AD       ONE                                   #  GET DE BITS
057557,000083:    5523           00004                           INHINT                                         
057558,000084:    5524           54063                           TS       ITEMP3                                
057559,000085:    5525           34762                           CA       LOW4                                  #  DEC15
057560,000086:    5526           54061                           TS       ITEMP1                                
057561,000087:    5527           50063                           INDEX    ITEMP3                                
057562,000088:    5530           27777                           CA       0          -1                         #  ADRES
057563,000089:    5531           54001                           TS       L                                     
057564,000090:    5532           34755                           CA       ZERO                                  

Page 1368

057566,000092:    5533           00006                           EXTEND                                         
057567,000093:    5534           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
057568,000094:    5535           52062                           DXCH     ITEMP1                                
057569,000095:    5536           50061                           INDEX    ITEMP1                                
057570,000096:    5537           30074                           CA       FLAGWRD0                              
057571,000097:    5540           54001                           TS       L                                     #  CURRENT STATE
057572,000098:    5541           50062                           INDEX    ITEMP2                                
057573,000099:    5542           44735                           CS       BIT15                                 #  -(15 - BIT)
057574,000100:    5543           00002                           TC       Q                                     
057575,000101: 

Page 1369

057577,000103:                                                                                                  #  DELAYJOB - A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
057578,000104: 
057579,000105:                                                                                                  #  ENTRANCE REQUIREMENTS ...
057580,000106:                                                                                                  #                CAF     DT              DELAY JOB FOR DT CENTISECS
057581,000107:                                                                                                  #                TC      BANKCALL
057582,000108:                                                                                                  #                CADR    DELAYJOB
057583,000109: 
057584,000110: 06,3772                                           BANK     06                                    
057585,000111: 00,2000                                           SETLOC   DLAYJOB                               
057586,000112: 00,2000                                           BANK                                           
057587,000113: 
057588,000114:                                                                                                  #  THIS MUST REMAIN IN BANK 0 *****************************************
057589,000115: 
057590,000116: 00,3735                                           COUNT*   $$/DELAY                              
057591,000117: 00,3735           35000        2SECDELY           CAF      2SECS                                 
057592,000118: 00,3736           00004        DELAYJOB           INHINT                                         
057593,000119: 00,3737           54002                           TS       Q                                     #  STORE DELAY DT IN Q FOR DLY -1 IN
057594,000120: 00,3740           34752                           CAF      DELAYNUM                              #  WAITLIST
057595,000121: 00,3741           54070        DELLOOP            TS       RUPTREG1                              
057596,000122: 00,3742           50000                           INDEX    A                                     
057597,000123: 00,3743           31323                           CA       DELAYLOC                              #  IS THIS DELAYLOC AVAILABLE
057598,000124: 00,3744           00006                           EXTEND                                         
057599,000125: 00,3745           13753                           BZF      OK2DELAY                              #  YES
057600,000126: 
057601,000127: 00,3746           10070                           CCS      RUPTREG1                              #  NO, TRY NEXT DELAYLOC
057602,000128: 00,3747           13741                           TCF      DELLOOP                               
057603,000129: 
057604,000130: 00,3750           52134                           DXCH     BUF2                                  
057605,000131: 00,3751           05706                           TC       BAILOUT1                              #  NO AVAILABLE LOCS.
057606,000132: 00,3752           31104                           OCT      31104                                 
057607,000133: 
057608,000134: 00,3753           33773        OK2DELAY           CA       TCSLEEP                               #  SET WAITLIST IMMEDIATE RETURN
057609,000135: 00,3754           54061                           TS       WAITEXIT                              
057610,000136: 
057611,000137: 00,3755           30004                           CA       FBANK                                 
057612,000138: 00,3756           60070                           AD       RUPTREG1                              #  STORE BBANK FOR TASK CALL
057613,000139: 00,3757           54001                           TS       L                                     
057614,000140: 
057615,000141: 00,3760           33774                           CAF      WAKECAD                               #  STORE CADR FOR TASK CALL
057616,000142: 00,3761           15211                           TCF      DLY2       -1                         #  DLY IS IN WAITLIST ROUTINE
057617,000143: 
057618,000144: 00,3762           04645        TCGETCAD           TC       MAKECADR                              #  GET CALLERS FCADR
057619,000145: 
057620,000146: 00,3763           50070                           INDEX    RUPTREG1                              
057621,000147: 00,3764           55323                           TS       DELAYLOC                              #  SAVE DELAY CADRS
057622,000148: 
057623,000149: 00,3765           05133                           TC       JOBSLEEP                              
057624,000150: 
057625,000151: 00,3766           34755        WAKER              CAF      ZERO                                  
057626,000152: 00,3767           50006                           INDEX    BBANK                                 

Page 1370

057628,000154: 00,3770           57323                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE
057629,000155: 00,3771           05137                           TC       JOBWAKE                               
057630,000156: 
057631,000157: 00,3772           05261                           TC       TASKOVER                              
057632,000158: 
057633,000159: 00,3773           03760        TCSLEEP            GENADR   TCGETCAD   -2                         
057634,000160: 00,3774           03766        WAKECAD            GENADR   WAKER                                 
057635,000161: 

Page 1371

057637,000163:                                                                                                  #  GENTRAN, A BLOCK TRANSFER ROUTINE.
057638,000164:                                                                                                  #  WRITTEN BY D. EYLES
057639,000165:                                                                                                  #  MOD 1 BY KERNAN                               UTILITYM REV 17 11/18/67
057640,000166:                                                                                                  #  MOD 2 BY SCHULENBERG    (REMOVE RELINT)    SKIPPER REV 4 2/28/68
057641,000167: 
057642,000168:                                                                                                  #  THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
057643,000169:                                                                                                  #  CONSECUTIVE ERASABLE LOCATIONS.  IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
057644,000170: 
057645,000171:                                                                                                  #  GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT.  THE CALLING SEQUENCE IS:
057646,000172:                                                                                                  #        I       CA      N-1             # OF QUANTITIES MINUS ONE.
057647,000173:                                                                                                  #        I +1    TC      GENTRAN         IN FIXED-FIXED.
057648,000174:                                                                                                  #        I +2    ADRES   L               STARTING ADRES OF DATA TO BE MOVED.
057649,000175:                                                                                                  #        I +3    ADRES   M               STARTING ADRES OF DUPLICATION BLOCK.
057650,000176:                                                                                                  #        I +4                            RETURNS HERE.
057651,000177: 
057652,000178:                                                                                                  #  GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
057653,000179:                                                                                                  #  A, L AND ITEMP1 ARE NOT PRESERVED.
057654,000180: 
057655,000181:    5544                                           BLOCK    02                                    
057656,000182:    4000                                           SETLOC   FFTAG4                                
057657,000183:    4000                                           BANK                                           
057658,000184: 
057659,000185:    5544     0061                                  EBANK=   ITEMP1                                
057660,000186: 
057661,000187:    5544                                           COUNT*   $$/TRAN                               
057662,000188: 
057663,000189:    5544           00004        GENTRAN            INHINT                                         
057664,000190:    5545           54061                           TS       ITEMP1                                #  SAVE N-1.
057665,000191:    5546           50002                           INDEX    Q                                     #  C(Q) = ADRES L.
057666,000192:    5547           60000                           AD       0                                     #  ADRES (L + N - 1).
057667,000193:    5550           50000                           INDEX    A                                     
057668,000194:    5551           30000                           CA       0                                     #  C(ABOVE).
057669,000195:    5552           54001                           TS       L                                     #  SAVE DATA.
057670,000196:    5553           30061                           CA       ITEMP1                                
057671,000197:    5554           50002                           INDEX    Q                                     
057672,000198:    5555           60001                           AD       1                                     #  ADRES (M + N - 1).
057673,000199:    5556           50000                           INDEX    A                                     
057674,000200:    5557           22000                           LXCH     0                                     #  STUFF IT.
057675,000201:    5560           10061                           CCS      ITEMP1                                #  LOOP UNTIL N-1 = 0.
057676,000202:    5561           15545                           TCF      GENTRAN    +1                         
057677,000203:    5562           16744                           TCF      Q+2                                   #  RETURN TO CALLER.
057678,000204: 

Page 1372

057680,000206:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
057681,000207:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
057682,000208: 
057683,000209:    5563                                           COUNT*   $$/EXTVB                              
057684,000210: 
057685,000211:    5563           44747        B5OFF              CS       BIT5                                  
057686,000212:    5564           71043                           MASK     EXTVBACT                              
057687,000213:    5565           55043                           TS       EXTVBACT                              
057688,000214:    5566           05155                           TC       ENDOFJOB                              
057689,000215: 
057690,000216: 
057691,000217: 

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