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.

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

Page 1371

059262,000021: 10,3554                                           BANK     10                                    
059263,000022: 10,2000                                           SETLOC   DISPLAYS                              
059264,000023: 10,2000                                           BANK                                           
059265,000024: 10,3554                                           COUNT*   $$/DSPLA                              
059266,000025: 
059267,000026: 10,3554           00004        UPENT2             INHINT                                         
059268,000027: 10,3555           75652                           MASK     OCT77770                              
059269,000028: 10,3556           54001                           TS       L                                     
059270,000029: 10,3557           40100                           CS       FLAGWRD4                              
059271,000030: 10,3560           70001                           MASK     L                                     
059272,000031: 10,3561           26100                           ADS      FLAGWRD4                              
059273,000032: 10,3562           00003        JOIN               RELINT                                         
059274,000033: 10,3563           16760                           TCF      Q+1                                   
059275,000034: 
059276,000035: 10,3564           00004        DOWNENT2           INHINT                                         
059277,000036: 10,3565           75652                           MASK     OCT77770                              
059278,000037: 10,3566           40000                           COM                                            
059279,000038: 10,3567           70100                           MASK     FLAGWRD4                              
059280,000039: 10,3570           54100                           TS       FLAGWRD4                              
059281,000040: 10,3571           13562                           TCF      JOIN                                  
059282,000041: 
059283,000042: 10,3572     4750               OCT7               EQUALS   SEVEN                                 
059284,000043: 

Page 1372

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

Page 1373

059334,000093:    5535           00006                           EXTEND                                         
059335,000094:    5536           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
059336,000095:    5537           52062                           DXCH     ITEMP1                                
059337,000096:    5540           50061                           INDEX    ITEMP1                                
059338,000097:    5541           30074                           CA       FLAGWRD0                              
059339,000098:    5542           54001                           TS       L                                     #  CURRENT STATE
059340,000099:    5543           50062                           INDEX    ITEMP2                                
059341,000100:    5544           44726                           CS       BIT15                                 #  -(15 - BIT)
059342,000101:    5545           00002                           TC       Q                                     
059343,000102: 

Page 1374

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

Page 1375

059398,000157: 00,3770           57323                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE
059399,000158: 00,3771           05130                           TC       JOBWAKE                               
059400,000159: 
059401,000160: 00,3772           05263                           TC       TASKOVER                              
059402,000161: 
059403,000162: 00,3773           03760        TCSLEEP            GENADR   TCGETCAD   -2                         
059404,000163: 00,3774           03766        WAKECAD            GENADR   WAKER                                 
059405,000164: 

Page 1376

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

Page 1377

059450,000209:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
059451,000210:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
059452,000211: 
059453,000212:    5565                                           COUNT*   $$/EXTVB                              
059454,000213: 
059455,000214:    5565           44740        B5OFF              CS       BIT5                                  
059456,000215:    5566           71043                           MASK     EXTVBACT                              
059457,000216:    5567           55043                           TS       EXTVBACT                              
059458,000217:    5570           05146                           TC       ENDOFJOB                              
059459,000218: 
059460,000219: 
059461,000220: 

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