Source Code

These source-code files derive from a printout of Luminary 116 (the Apollo 12 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Ron Burkey, and transcribed to source code by a team of volunteers. This colorized, syntax-highlighted form was created by assembling that transcribed source code. Note that the full page images are available on the Virtual AGC project page at archive.org, while reduced-size images are presented at the VirtualAGC project website. Report or fix any transcription errors at the Virtual AGC project code repository.

Notations on the program listing read, in part:

	GAP:  ASSEMBLE REVISION 116 OF AGC PROGRAM LUMINARY BY NASA 2021112-071
	19:09 AUG. 11,1969
Note that the date is the date of the printout, not the date of the program revision.

057965,000002:                                                                                                  ## Copyright:   Public domain.
057966,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
057967,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
057968,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
057969,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
057970,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
057971,000008:                                                                                                  ##              that the code format has been changed to conform to the
057972,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
057973,000010:                                                                                                  ##              original YUL assembler.
057974,000011:                                                                                                  ## Reference:   pp. 1364-1370
057975,000012:                                                                                                  ## Assembler:   yaYUL
057976,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
057977,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
057978,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
057979,000016:                                                                                                  ##              2017-02-03 RRB  Updated for Luminary 116.
057980,000017:                                                                                                  ##              2017-03-09 HG   Add missing statement
057981,000018:                                                                                                  ##                                  2SECDELY  CAF  2SECS
057982,000019:                                                                                                  ##              2017-03-14 RSB  Proofed comment text via 3-way diff vs
057983,000020:                                                                                                  ##                              Luminary 99 and 131.
057984,000021:                                                                                                  ##              2017-03-16 RSB  Comment-text fixes identified in 5-way
057985,000022:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
057986,000023:                                                                                                  ##              2017-03-19 HG   Fix value OCT 1104 -> OCT 31104
057987,000024: 

Page 1364

057989,000026: 10,3545                                           BANK     10                                    
057990,000027: 10,2000                                           SETLOC   DISPLAYS                              
057991,000028: 10,2000                                           BANK                                           
057992,000029: 10,3545                                           COUNT*   $$/DSPLA                              
057993,000030: 
057994,000031: 10,3545           00004        UPENT2             INHINT                                         
057995,000032: 10,3546           75650                           MASK     OCT77770                              
057996,000033: 10,3547           54001                           TS       L                                     
057997,000034: 10,3550           40100                           CS       FLAGWRD4                              
057998,000035: 10,3551           70001                           MASK     L                                     
057999,000036: 10,3552           26100                           ADS      FLAGWRD4                              
058000,000037: 10,3553           00003        JOIN               RELINT                                         
058001,000038: 10,3554           16742                           TCF      Q+1                                   
058002,000039: 
058003,000040: 10,3555           00004        DOWNENT2           INHINT                                         
058004,000041: 10,3556           75650                           MASK     OCT77770                              
058005,000042: 10,3557           40000                           COM                                            
058006,000043: 10,3560           70100                           MASK     FLAGWRD4                              
058007,000044: 10,3561           54100                           TS       FLAGWRD4                              
058008,000045: 10,3562           13553                           TCF      JOIN                                  
058009,000046: 
058010,000047: 10,3563     4757               OCT7               EQUALS   SEVEN                                 
058011,000048: 

Page 1365

058013,000050:                                                                                                  #      UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES.  USING THEM, WHETHER OR
058014,000051:                                                                                                  #  NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
058015,000052:                                                                                                  #  EBANK SETTING.   A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
058016,000053:                                                                                                  #  ASSEMBLER.
058017,000054: 
058018,000055:                                                                                                  #      AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS.  ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
058019,000056:                                                                                                  #  NAME ANY BIT IN ERASABLE MEMORY.
058020,000057: 
058021,000058:                                                                                                  #      CALLING SEQUENCES ARE AS FOLLOWS:-
058022,000059:                                                                                                  #                TC      UPFLAG                  TC      DOWNFLAG
058023,000060:                                                                                                  #                ADRES   NAME OF FLAG            ADRES   NAME OF FLAG
058024,000061: 
058025,000062:                                                                                                  #      RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
058026,000063:                                                                                                  #      UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
058027,000064: 
058028,000065:    5504                                           BLOCK    02                                    
058029,000066:    4000                                           SETLOC   FFTAG1                                
058030,000067:    4000                                           BANK                                           
058031,000068:    5504                                           COUNT*   $$/FLAG                               
058032,000069: 
058033,000070:    5504           30002        UPFLAG             CA       Q                                     
058034,000071:    5505           05522                           TC       DEBIT                                 
058035,000072:    5506           40000                           COM                                            #  +(15 - BIT)
058036,000073:    5507           00006                           EXTEND                                         
058037,000074:    5510           04001                           ROR      LCHAN                                 #  SET BIT
058038,000075:    5511           50061        COMFLAG            INDEX    ITEMP1                                
058039,000076:    5512           54074                           TS       FLAGWRD0                              
058040,000077:    5513           22063                           LXCH     ITEMP3                                
058041,000078:    5514           00003                           RELINT                                         
058042,000079:    5515           00001                           TC       L                                     
058043,000080: 
058044,000081:    5516           30002        DOWNFLAG           CA       Q                                     
058045,000082:    5517           05522                           TC       DEBIT                                 
058046,000083:    5520           70001                           MASK     L                                     #  RESET BIT
058047,000084:    5521           15511                           TCF      COMFLAG                               
058048,000085: 
058049,000086:    5522           64753        DEBIT              AD       ONE                                   #  GET DE BITS
058050,000087:    5523           00004                           INHINT                                         
058051,000088:    5524           54063                           TS       ITEMP3                                
058052,000089:    5525           34762                           CA       LOW4                                  #  DEC15
058053,000090:    5526           54061                           TS       ITEMP1                                
058054,000091:    5527           50063                           INDEX    ITEMP3                                
058055,000092:    5530           27777                           CA       0          -1                         #  ADRES
058056,000093:    5531           54001                           TS       L                                     
058057,000094:    5532           34755                           CA       ZERO                                  

Page 1366

058059,000096:    5533           00006                           EXTEND                                         
058060,000097:    5534           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
058061,000098:    5535           52062                           DXCH     ITEMP1                                
058062,000099:    5536           50061                           INDEX    ITEMP1                                
058063,000100:    5537           30074                           CA       FLAGWRD0                              
058064,000101:    5540           54001                           TS       L                                     #  CURRENT STATE
058065,000102:    5541           50062                           INDEX    ITEMP2                                
058066,000103:    5542           44735                           CS       BIT15                                 #  -(15 - BIT)
058067,000104:    5543           00002                           TC       Q                                     
058068,000105: 

Page 1367

058070,000107:                                                                                                  #  DELAYJOB- A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
058071,000108: 
058072,000109:                                                                                                  #  ENTRANCE REQUIREMENTS ...
058073,000110:                                                                                                  #                CAF     DT              DELAY JOB FOR DT CENTISECS
058074,000111:                                                                                                  #                TC      BANKCALL
058075,000112:                                                                                                  #                CADR    DELAYJOB
058076,000113: 
058077,000114: 06,3772                                           BANK     06                                    
058078,000115: 00,2000                                           SETLOC   DLAYJOB                               
058079,000116: 00,2000                                           BANK                                           
058080,000117: 
058081,000118:                                                                                                  #  THIS MUST REMAIN IN BANK 0 *****************************************
058082,000119: 
058083,000120: 00,3735                                           COUNT*   $$/DELAY                              
058084,000121: 00,3735           35000        2SECDELY           CAF      2SECS                                 
058085,000122: 00,3736           00004        DELAYJOB           INHINT                                         
058086,000123: 00,3737           54002                           TS       Q                                     #  STORE DELAY DT IN Q FOR DLY -1 IN
058087,000124: 
058088,000125: 00,3740           34752                           CAF      DELAYNUM                              #  WAITLIST
058089,000126: 00,3741           54070        DELLOOP            TS       RUPTREG1                              
058090,000127: 00,3742           50000                           INDEX    A                                     
058091,000128: 00,3743           31323                           CA       DELAYLOC                              #  IS THIS DELAYLOC AVAILABLE
058092,000129: 00,3744           00006                           EXTEND                                         
058093,000130: 00,3745           13753                           BZF      OK2DELAY                              #  YES
058094,000131: 
058095,000132: 00,3746           10070                           CCS      RUPTREG1                              #  NO, TRY NEXT DELAYLOC
058096,000133: 00,3747           13741                           TCF      DELLOOP                               
058097,000134: 
058098,000135: 00,3750           52134                           DXCH     BUF2                                  
058099,000136: 00,3751           05706                           TC       BAILOUT1                              #  NO AVAILABLE LOCS.
058100,000137: 00,3752           31104                           OCT      31104                                 
058101,000138: 
058102,000139: 00,3753           33773        OK2DELAY           CA       TCSLEEP                               #  SET WAITLIST IMMEDIATE RETURN
058103,000140: 00,3754           54061                           TS       WAITEXIT                              
058104,000141: 
058105,000142: 00,3755           30004                           CA       FBANK                                 
058106,000143: 00,3756           60070                           AD       RUPTREG1                              #  STORE BBANK FOR TASK CALL
058107,000144: 00,3757           54001                           TS       L                                     
058108,000145: 
058109,000146: 00,3760           33774                           CAF      WAKECAD                               #  STORE CADR FOR TASK CALL
058110,000147: 00,3761           15211                           TCF      DLY2       -1                         #  DLY IS IN WAITLIST ROUTINE
058111,000148: 
058112,000149: 00,3762           04645        TCGETCAD           TC       MAKECADR                              #  GET CALLERS FCADR
058113,000150: 
058114,000151: 00,3763           50070                           INDEX    RUPTREG1                              
058115,000152: 00,3764           55323                           TS       DELAYLOC                              #  SAVE DELAY CADRS
058116,000153: 
058117,000154: 00,3765           05133                           TC       JOBSLEEP                              
058118,000155: 
058119,000156: 00,3766           34755        WAKER              CAF      ZERO                                  
058120,000157: 00,3767           50006                           INDEX    BBANK                                 

Page 1368

058122,000159: 00,3770           57323                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE
058123,000160: 00,3771           05137                           TC       JOBWAKE                               
058124,000161: 
058125,000162: 00,3772           05261                           TC       TASKOVER                              
058126,000163: 
058127,000164: 00,3773           03760        TCSLEEP            GENADR   TCGETCAD   -2                         
058128,000165: 00,3774           03766        WAKECAD            GENADR   WAKER                                 
058129,000166: 

Page 1369

058131,000168:                                                                                                  #  GENTRAN, A BLOCK TRANSFER ROUTINE.
058132,000169: 
058133,000170:                                                                                                  #  WRITTEN BY D. EYLES
058134,000171:                                                                                                  #  MOD 1 BY KERNAN                               UTILITYM REV 17 11/18/67
058135,000172: 
058136,000173:                                                                                                  #  MOD 2 BY SCHULENBERG (REMOVE RELINT) SKIPPER REV 4 2/28/68
058137,000174: 
058138,000175:                                                                                                  #  THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
058139,000176:                                                                                                  #  CONSECUTIVE ERASABLE LOCATIONS.  IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
058140,000177: 
058141,000178:                                                                                                  #  GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT.  THE CALLING SEQUENCE IS:
058142,000179:                                                                                                  #        I       CA      N-1             # OF QUANTITIES MINUS ONE.
058143,000180:                                                                                                  #        I +1    TC      GENTRAN         IN FIXED-FIXED.
058144,000181:                                                                                                  #        I +2    ADRES   L               STARTING ADRES OF DATA TO BE MOVED.
058145,000182:                                                                                                  #        I +3    ADRES   M               STARTING ADRES OF DUPLICATION BLOCK.
058146,000183:                                                                                                  #        I +4                            RETURNS HERE.
058147,000184: 
058148,000185:                                                                                                  #  GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
058149,000186: 
058150,000187:                                                                                                  #  A, L AND ITEMP1 ARE NOT PRESERVED.
058151,000188: 
058152,000189:    5544                                           BLOCK    02                                    
058153,000190:    4000                                           SETLOC   FFTAG4                                
058154,000191:    4000                                           BANK                                           
058155,000192: 
058156,000193:    5544     0061                                  EBANK=   ITEMP1                                
058157,000194: 
058158,000195:    5544                                           COUNT*   $$/TRAN                               
058159,000196: 
058160,000197:    5544           00004        GENTRAN            INHINT                                         
058161,000198:    5545           54061                           TS       ITEMP1                                #  SAVE N-1.
058162,000199:    5546           50002                           INDEX    Q                                     #  C(Q) = ADRES L.
058163,000200:    5547           60000                           AD       0                                     #  ADRES (L + N - 1).
058164,000201:    5550           50000                           INDEX    A                                     
058165,000202:    5551           30000                           CA       0                                     #  C(ABOVE).
058166,000203:    5552           54001                           TS       L                                     #  SAVE DATA.
058167,000204:    5553           30061                           CA       ITEMP1                                
058168,000205:    5554           50002                           INDEX    Q                                     
058169,000206:    5555           60001                           AD       1                                     #  ADRES (M + N - 1).
058170,000207:    5556           50000                           INDEX    A                                     
058171,000208:    5557           22000                           LXCH     0                                     #  STUFF IT.
058172,000209:    5560           10061                           CCS      ITEMP1                                #  LOOP UNTIL N-1 = 0.
058173,000210:    5561           15545                           TCF      GENTRAN    +1                         
058174,000211:    5562           16744                           TCF      Q+2                                   #  RETURN TO CALLER.
058175,000212: 

Page 1370

058177,000214:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
058178,000215: 
058179,000216:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
058180,000217: 
058181,000218:    5563                                           COUNT*   $$/EXTVB                              
058182,000219: 
058183,000220:    5563           44747        B5OFF              CS       BIT5                                  
058184,000221:    5564           71043                           MASK     EXTVBACT                              
058185,000222:    5565           55043                           TS       EXTVBACT                              
058186,000223:    5566           05155                           TC       ENDOFJOB                              
058187,000224: 
058188,000225: 
058189,000226: 

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