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.

057987,000002:                                                                                                  ## Copyright:   Public domain.
057988,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
057989,000004:                                                                                                  ## Purpose:     A section of Luminary revision 116.
057990,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
057991,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 12.
057992,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
057993,000008:                                                                                                  ##              that the code format has been changed to conform to the
057994,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
057995,000010:                                                                                                  ##              original YUL assembler.
057996,000011:                                                                                                  ## Reference:   pp. 1364-1370
057997,000012:                                                                                                  ## Assembler:   yaYUL
057998,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
057999,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
058000,000015:                                                                                                  ## Mod history: 2017-01-22 MAS  Created from Luminary 99.
058001,000016:                                                                                                  ##              2017-02-03 RRB  Updated for Luminary 116.
058002,000017:                                                                                                  ##              2017-03-09 HG   Add missing statement
058003,000018:                                                                                                  ##                                  2SECDELY  CAF  2SECS
058004,000019:                                                                                                  ##              2017-03-14 RSB  Proofed comment text via 3-way diff vs
058005,000020:                                                                                                  ##                              Luminary 99 and 131.
058006,000021:                                                                                                  ##              2017-03-16 RSB  Comment-text fixes identified in 5-way
058007,000022:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
058008,000023:                                                                                                  ##              2017-03-19 HG   Fix value OCT 1104 -> OCT 31104
058009,000024: 

Page 1364

058011,000026: 10,3545                                           BANK     10                                    
058012,000027: 10,2000                                           SETLOC   DISPLAYS                              
058013,000028: 10,2000                                           BANK                                           
058014,000029: 10,3545                                           COUNT*   $$/DSPLA                              
058015,000030: 
058016,000031: 10,3545           00004        UPENT2             INHINT                                         
058017,000032: 10,3546           75650                           MASK     OCT77770                              
058018,000033: 10,3547           54001                           TS       L                                     
058019,000034: 10,3550           40100                           CS       FLAGWRD4                              
058020,000035: 10,3551           70001                           MASK     L                                     
058021,000036: 10,3552           26100                           ADS      FLAGWRD4                              
058022,000037: 10,3553           00003        JOIN               RELINT                                         
058023,000038: 10,3554           16742                           TCF      Q+1                                   
058024,000039: 
058025,000040: 10,3555           00004        DOWNENT2           INHINT                                         
058026,000041: 10,3556           75650                           MASK     OCT77770                              
058027,000042: 10,3557           40000                           COM                                            
058028,000043: 10,3560           70100                           MASK     FLAGWRD4                              
058029,000044: 10,3561           54100                           TS       FLAGWRD4                              
058030,000045: 10,3562           13553                           TCF      JOIN                                  
058031,000046: 
058032,000047: 10,3563     4757               OCT7               EQUALS   SEVEN                                 
058033,000048: 

Page 1365

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

Page 1366

058081,000096:    5533           00006                           EXTEND                                         
058082,000097:    5534           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
058083,000098:    5535           52062                           DXCH     ITEMP1                                
058084,000099:    5536           50061                           INDEX    ITEMP1                                
058085,000100:    5537           30074                           CA       FLAGWRD0                              
058086,000101:    5540           54001                           TS       L                                     #  CURRENT STATE
058087,000102:    5541           50062                           INDEX    ITEMP2                                
058088,000103:    5542           44735                           CS       BIT15                                 #  -(15 - BIT)
058089,000104:    5543           00002                           TC       Q                                     
058090,000105: 

Page 1367

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

Page 1368

058144,000159: 00,3770           57323                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE
058145,000160: 00,3771           05137                           TC       JOBWAKE                               
058146,000161: 
058147,000162: 00,3772           05261                           TC       TASKOVER                              
058148,000163: 
058149,000164: 00,3773           03760        TCSLEEP            GENADR   TCGETCAD   -2                         
058150,000165: 00,3774           03766        WAKECAD            GENADR   WAKER                                 
058151,000166: 

Page 1369

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

Page 1370

058199,000214:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
058200,000215: 
058201,000216:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
058202,000217: 
058203,000218:    5563                                           COUNT*   $$/EXTVB                              
058204,000219: 
058205,000220:    5563           44747        B5OFF              CS       BIT5                                  
058206,000221:    5564           71043                           MASK     EXTVBACT                              
058207,000222:    5565           55043                           TS       EXTVBACT                              
058208,000223:    5566           05155                           TC       ENDOFJOB                              
058209,000224: 
058210,000225: 
058211,000226: 

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