Source Code

These source-code files derive from a printout of Luminary 210 (Apollo 15-17 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Jim Lawton, 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 210 OF AGC PROGRAM LUMINARY 
	BY NASA 2021112-161 17:11 MAR. 19,1971
Note that the date is the date of the printout, not the date of the program revision.

059256,000002:                                                                                                  ## Copyright:   Public domain.
059257,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
059258,000004:                                                                                                  ## Purpose:     A section of Luminary revision 210.
059259,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
059260,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 15-17.
059261,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
059262,000008:                                                                                                  ##              that the code format has been changed to conform to the
059263,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
059264,000010:                                                                                                  ##              original YUL assembler.
059265,000011:                                                                                                  ## Reference:   pp. 1371-1377
059266,000012:                                                                                                  ## Assembler:   yaYUL
059267,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
059268,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
059269,000015:                                                                                                  ## Mod history: 2016-11-17 JL   Created from Luminary131 version.
059270,000016:                                                                                                  ##              2016-11-29 TB   Transcribed
059271,000017:                                                                                                  ##              2016-12-26 RSB  Comment-text proofed using ProoferComments
059272,000018:                                                                                                  ##                              and corrected errors found.
059273,000019: 

Page 1371

059275,000021: 10,3554                                           BANK     10                                    
059276,000022: 10,2000                                           SETLOC   DISPLAYS                              
059277,000023: 10,2000                                           BANK                                           
059278,000024: 10,3554                                           COUNT*   $$/DSPLA                              
059279,000025: 
059280,000026: 10,3554           00004        UPENT2             INHINT                                         
059281,000027: 10,3555           75652                           MASK     OCT77770                              
059282,000028: 10,3556           54001                           TS       L                                     
059283,000029: 10,3557           40100                           CS       FLAGWRD4                              
059284,000030: 10,3560           70001                           MASK     L                                     
059285,000031: 10,3561           26100                           ADS      FLAGWRD4                              
059286,000032: 10,3562           00003        JOIN               RELINT                                         
059287,000033: 10,3563           16760                           TCF      Q+1                                   
059288,000034: 
059289,000035: 10,3564           00004        DOWNENT2           INHINT                                         
059290,000036: 10,3565           75652                           MASK     OCT77770                              
059291,000037: 10,3566           40000                           COM                                            
059292,000038: 10,3567           70100                           MASK     FLAGWRD4                              
059293,000039: 10,3570           54100                           TS       FLAGWRD4                              
059294,000040: 10,3571           13562                           TCF      JOIN                                  
059295,000041: 
059296,000042: 10,3572     4750               OCT7               EQUALS   SEVEN                                 
059297,000043: 

Page 1372

059299,000045:                                                                                                  #  UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES.  USING THEM, WHETHER OR
059300,000046:                                                                                                  #  NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
059301,000047:                                                                                                  #  EBANK SETTING.  A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
059302,000048:                                                                                                  #  ASSEMBLER.
059303,000049: 
059304,000050:                                                                                                  #  AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS.  ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
059305,000051:                                                                                                  #  NAME ANY BIT IN ERASABLE MEMORY.
059306,000052: 
059307,000053:                                                                                                  #  CALLING SEQUENCES ARE AS FOLLOWS:-
059308,000054:                                                                                                  #                TC      UPFLAG                  TC      DOWNFLAG
059309,000055:                                                                                                  #                ADRES   NAME OF FLAG            ADRES   NAME OF FLAG
059310,000056: 
059311,000057:                                                                                                  #  RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
059312,000058: 
059313,000059:                                                                                                  #  UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
059314,000060: 
059315,000061:    5506                                           BLOCK    02                                    
059316,000062:    4000                                           SETLOC   FFTAG1                                
059317,000063:    4000                                           BANK                                           
059318,000064:    5506                                           COUNT*   $$/FLAG                               
059319,000065: 
059320,000066:    5506           30002        UPFLAG             CA       Q                                     
059321,000067:    5507           05524                           TC       DEBIT                                 
059322,000068:    5510           40000                           COM                                            #  +(15 - BIT)
059323,000069:    5511           00006                           EXTEND                                         
059324,000070:    5512           04001                           ROR      LCHAN                                 #  SET BIT
059325,000071:    5513           50061        COMFLAG            INDEX    ITEMP1                                
059326,000072:    5514           54074                           TS       FLAGWRD0                              
059327,000073:    5515           22063                           LXCH     ITEMP3                                
059328,000074:    5516           00003                           RELINT                                         
059329,000075:    5517           00001                           TC       L                                     
059330,000076: 
059331,000077:    5520           30002        DOWNFLAG           CA       Q                                     
059332,000078:    5521           05524                           TC       DEBIT                                 
059333,000079:    5522           70001                           MASK     L                                     #  RESET BIT
059334,000080:    5523           15513                           TCF      COMFLAG                               
059335,000081: 
059336,000082:    5524           64744        DEBIT              AD       ONE                                   #  GET DE BITS
059337,000083:    5525           00004                           INHINT                                         
059338,000084:    5526           54063                           TS       ITEMP3                                
059339,000085:    5527           34753                           CA       LOW4                                  #  DEC15
059340,000086:    5530           54061                           TS       ITEMP1                                
059341,000087:    5531           50063                           INDEX    ITEMP3                                
059342,000088:    5532           27777                           CA       0          -1                         #  ADRES
059343,000089:    5533           54001                           TS       L                                     
059344,000090:    5534           34746                           CA       ZERO                                  
059345,000091: 

Page 1373

059347,000093:    5535           00006                           EXTEND                                         
059348,000094:    5536           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
059349,000095:    5537           52062                           DXCH     ITEMP1                                
059350,000096:    5540           50061                           INDEX    ITEMP1                                
059351,000097:    5541           30074                           CA       FLAGWRD0                              
059352,000098:    5542           54001                           TS       L                                     #  CURRENT STATE
059353,000099:    5543           50062                           INDEX    ITEMP2                                
059354,000100:    5544           44726                           CS       BIT15                                 #  -(15 - BIT)
059355,000101:    5545           00002                           TC       Q                                     
059356,000102: 

Page 1374

059358,000104:                                                                                                  #  DELAYJOB- A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
059359,000105: 
059360,000106:                                                                                                  #  ENTRANCE REQUIREMENTS...
059361,000107:                                                                                                  #                CAF     DT              DELAY JOB FOR DT CENTISECS
059362,000108:                                                                                                  #                TC      BANKCALL
059363,000109:                                                                                                  #                CADR    DELAYJOB
059364,000110: 
059365,000111: 06,3776                                           BANK     06                                    
059366,000112: 00,2000                                           SETLOC   DLAYJOB                               
059367,000113: 00,2000                                           BANK                                           
059368,000114: 
059369,000115:                                                                                                  #  THIS MUST REMAIN IN BANK 0 *****************************************
059370,000116: 
059371,000117: 00,3735                                           COUNT*   $$/DELAY                              
059372,000118: 00,3735           34771        2SECDELY           CAF      2SECS                                 
059373,000119: 00,3736           00004        DELAYJOB           INHINT                                         
059374,000120: 00,3737           54002                           TS       Q                                     #  STORE DELAY DT IN Q FOR DLY -1 IN
059375,000121: 
059376,000122: 00,3740           34743                           CAF      DELAYNUM                              #  WAITLIST
059377,000123: 00,3741           54070        DELLOOP            TS       RUPTREG1                              
059378,000124: 00,3742           50000                           INDEX    A                                     
059379,000125: 00,3743           31323                           CA       DELAYLOC                              #  IS THIS DELAYLOC AVAILABLE
059380,000126: 00,3744           00006                           EXTEND                                         
059381,000127: 00,3745           13753                           BZF      OK2DELAY                              #  YES
059382,000128: 
059383,000129: 00,3746           10070                           CCS      RUPTREG1                              #  NO, TRY NEXT DELAYLOC
059384,000130: 00,3747           13741                           TCF      DELLOOP                               
059385,000131: 
059386,000132: 00,3750           52134                           DXCH     BUF2                                  
059387,000133: 00,3751           05712                           TC       BAILOUT1                              #  NO AVAILABLE LOCS.
059388,000134: 00,3752           31104                           OCT      31104                                 
059389,000135: 
059390,000136: 00,3753           33773        OK2DELAY           CA       TCSLEEP                               #  SET WAITLIST IMMEDIATE RETURN
059391,000137: 00,3754           54061                           TS       WAITEXIT                              
059392,000138: 
059393,000139: 00,3755           30004                           CA       FBANK                                 
059394,000140: 00,3756           60070                           AD       RUPTREG1                              #  STORE BBANK FOR TASK CALL
059395,000141: 00,3757           54001                           TS       L                                     
059396,000142: 
059397,000143: 00,3760           33774                           CAF      WAKECAD                               #  STORE CADR FOR TASK CALL
059398,000144: 00,3761           15213                           TCF      DLY2       -1                         #  DLY IS IN WAITLIST ROUTINE
059399,000145: 
059400,000146: 00,3762           04636        TCGETCAD           TC       MAKECADR                              #  GET CALLERS FCADR
059401,000147: 
059402,000148: 00,3763           50070                           INDEX    RUPTREG1                              
059403,000149: 00,3764           55323                           TS       DELAYLOC                              #  SAVE DELAY CADRS
059404,000150: 
059405,000151: 00,3765           05124                           TC       JOBSLEEP                              
059406,000152: 
059407,000153: 00,3766           34746        WAKER              CAF      ZERO                                  
059408,000154: 00,3767           50006                           INDEX    BBANK                                 
059409,000155: 

Page 1375

059411,000157: 00,3770           57323                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE
059412,000158: 00,3771           05130                           TC       JOBWAKE                               
059413,000159: 
059414,000160: 00,3772           05263                           TC       TASKOVER                              
059415,000161: 
059416,000162: 00,3773           03760        TCSLEEP            GENADR   TCGETCAD   -2                         
059417,000163: 00,3774           03766        WAKECAD            GENADR   WAKER                                 
059418,000164: 

Page 1376

059420,000166:                                                                                                  #  GENTRAN, A BLOCK TRANSFER ROUTINE.
059421,000167:                                                                                                  #  WRITTEN BY D. EYLES
059422,000168:                                                                                                  #  MOD 1 BY KERNAN                               UTILITYM REV 17 11/18/67
059423,000169:                                                                                                  #  MOD 2 BY SCHULENBERG (REMOVE RELINT)  SKIPPER REV 4 2/28/68
059424,000170: 
059425,000171:                                                                                                  #  THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
059426,000172:                                                                                                  #  CONSECUTIVE ERASABLE LOCATIONS.  IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
059427,000173: 
059428,000174:                                                                                                  #  GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT.  THE CALLING SEQUENCE IS:
059429,000175:                                                                                                  #        I       CA      N-1             # OF QUANTITIES MINUS ONE.
059430,000176:                                                                                                  #        I +1    TC      GENTRAN         IN FIXED-FIXED.
059431,000177:                                                                                                  #        I +2    ADRES   L               STARTING ADRES OF DATA TO BE MOVED.
059432,000178:                                                                                                  #        I +3    ADRES   M               STARTING ADRES OF DUPLICATION BLOCK.
059433,000179:                                                                                                  #        I +4                            RETURNS HERE.
059434,000180: 
059435,000181:                                                                                                  #  GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
059436,000182:                                                                                                  #  A, L AND ITEMP1 ARE NOT PRESERVED.
059437,000183: 
059438,000184:    5546                                           BLOCK    02                                    
059439,000185:    4000                                           SETLOC   FFTAG4                                
059440,000186:    4000                                           BANK                                           
059441,000187: 
059442,000188:    5546     0061                                  EBANK=   ITEMP1                                
059443,000189: 
059444,000190:    5546                                           COUNT*   $$/TRAN                               
059445,000191: 
059446,000192:    5546           00004        GENTRAN            INHINT                                         
059447,000193:    5547           54061                           TS       ITEMP1                                #  SAVE N-1.
059448,000194:    5550           50002                           INDEX    Q                                     #  C(Q) = ADRES L.
059449,000195:    5551           60000                           AD       0                                     #  ADRES (L + N - 1).
059450,000196:    5552           50000                           INDEX    A                                     
059451,000197:    5553           30000                           CA       0                                     #  C(ABOVE).
059452,000198:    5554           54001                           TS       L                                     #  SAVE DATA.
059453,000199:    5555           30061                           CA       ITEMP1                                
059454,000200:    5556           50002                           INDEX    Q                                     
059455,000201:    5557           60001                           AD       1                                     #  ADRES (M + N - 1).
059456,000202:    5560           50000                           INDEX    A                                     
059457,000203:    5561           22000                           LXCH     0                                     #  STUFF IT.
059458,000204:    5562           10061                           CCS      ITEMP1                                #  LOOP UNTIL N-1 = 0.
059459,000205:    5563           15547                           TCF      GENTRAN    +1                         
059460,000206:    5564           16762                           TCF      Q+2                                   #  RETURN TO CALLER.
059461,000207: 

Page 1377

059463,000209:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
059464,000210:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
059465,000211: 
059466,000212:    5565                                           COUNT*   $$/EXTVB                              
059467,000213: 
059468,000214:    5565           44740        B5OFF              CS       BIT5                                  
059469,000215:    5566           71043                           MASK     EXTVBACT                              
059470,000216:    5567           55043                           TS       EXTVBACT                              
059471,000217:    5570           05146                           TC       ENDOFJOB                              
059472,000218: 
059473,000219: 
059474,000220: 

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