Source Code

These source-code files are part of a reconstructed copy of Luminary 96, the original release of the Apollo 11 Lunar Module (LM) Apollo Guidance Computer (AGC) software.

The reconstruction began with reconstructed source code for Luminary 97. Changes between revisions 96 and 97 were backed out, as described by anomal report LNY-59. transcribed from a digitized copy of that program. The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021152D. Note that page numbers in the reconstructed code match those on the Luminary 099 revision 001 printout, although the added code would likely have changed page numbers for a real Luminary 96 listing.

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

057660,000002:                                                                                                  ## Copyright:   Public domain.
057661,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
057662,000004:                                                                                                  ## Purpose:     A section of Luminary revision 96.
057663,000005:                                                                                                  ##              It is part of the reconstructed source code for the
057664,000006:                                                                                                  ##              original release of the flight software for the Lunar 
057665,000007:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 11.
057666,000008:                                                                                                  ##              The code has been recreated from a previously reconstructed
057667,000009:                                                                                                  ##              copy of Luminary 97 by undoing changes described in anomaly
057668,000010:                                                                                                  ##              report LNY-59. The code has been adapted such that the
057669,000011:                                                                                                  ##              resulting bugger words exactly match those specified for
057670,000012:                                                                                                  ##              Luminary 96 in NASA drawing 2021152D, which gives relatively
057671,000013:                                                                                                  ##              high confidence that the reconstruction is correct.
057672,000014:                                                                                                  ## Reference:   pp. 1374-1380
057673,000015:                                                                                                  ## Assembler:   yaYUL
057674,000016:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
057675,000017:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
057676,000018:                                                                                                  ## Mod history: 2019-08-04 MAS  Created from Luminary 97.
057677,000019: 

Page 1374

057679,000021: 10,3544                                           BANK     10                                    
057680,000022: 10,2000                                           SETLOC   DISPLAYS                              
057681,000023: 10,2000                                           BANK                                           
057682,000024: 10,3544                                           COUNT*   $$/DSPLA                              
057683,000025: 
057684,000026: 10,3544           00004        UPENT2             INHINT                                         
057685,000027: 10,3545           75660                           MASK     OCT77770                              
057686,000028: 10,3546           54001                           TS       L                                     
057687,000029: 10,3547           40100                           CS       FLAGWRD4                              
057688,000030: 10,3550           70001                           MASK     L                                     
057689,000031: 10,3551           26100                           ADS      FLAGWRD4                              
057690,000032: 10,3552           00003        JOIN               RELINT                                         
057691,000033: 10,3553           16737                           TCF      Q+1                                   
057692,000034: 
057693,000035: 10,3554           00004        DOWNENT2           INHINT                                         
057694,000036: 10,3555           75660                           MASK     OCT77770                              
057695,000037: 10,3556           40000                           COM                                            
057696,000038: 10,3557           70100                           MASK     FLAGWRD4                              
057697,000039: 10,3560           54100                           TS       FLAGWRD4                              
057698,000040: 10,3561           13552                           TCF      JOIN                                  
057699,000041: 
057700,000042: 10,3562     4757               OCT7               EQUALS   SEVEN                                 
057701,000043: 

Page 1375

057703,000045:                                                                                                  #  UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES.  USING THEM, WHETHER OR
057704,000046:                                                                                                  #  NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
057705,000047:                                                                                                  #  EBANK SETTING.  A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
057706,000048:                                                                                                  #  ASSEMBLER.
057707,000049: 
057708,000050:                                                                                                  #  AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS.  ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
057709,000051:                                                                                                  #  NAME ANY BIT IN ERASABLE MEMORY.
057710,000052: 
057711,000053:                                                                                                  #  CALLING SEQUENCES ARE AS FOLLOWS :-
057712,000054:                                                                                                  #                TC      UPFLAG                  TC      DOWNFLAG
057713,000055:                                                                                                  #                ADRES   NAME OF FLAG            ADRES   NAME OF FLAG
057714,000056: 
057715,000057:                                                                                                  #  RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
057716,000058:                                                                                                  #  UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
057717,000059: 
057718,000060:    5504                                           BLOCK    02                                    
057719,000061:    4000                                           SETLOC   FFTAG1                                
057720,000062:    4000                                           BANK                                           
057721,000063:    5504                                           COUNT*   $$/FLAG                               
057722,000064: 
057723,000065:    5504           30002        UPFLAG             CA       Q                                     
057724,000066:    5505           05522                           TC       DEBIT                                 
057725,000067:    5506           40000                           COM                                            #  +(15 - BIT)
057726,000068:    5507           00006                           EXTEND                                         
057727,000069:    5510           04001                           ROR      LCHAN                                 #  SET BIT
057728,000070:    5511           50061        COMFLAG            INDEX    ITEMP1                                
057729,000071:    5512           54074                           TS       FLAGWRD0                              
057730,000072:    5513           22063                           LXCH     ITEMP3                                
057731,000073:    5514           00003                           RELINT                                         
057732,000074:    5515           00001                           TC       L                                     
057733,000075: 
057734,000076:    5516           30002        DOWNFLAG           CA       Q                                     
057735,000077:    5517           05522                           TC       DEBIT                                 
057736,000078:    5520           70001                           MASK     L                                     #  RESET BIT
057737,000079:    5521           15511                           TCF      COMFLAG                               
057738,000080: 
057739,000081:    5522           64753        DEBIT              AD       ONE                                   #  GET DE BITS
057740,000082:    5523           00004                           INHINT                                         
057741,000083:    5524           54063                           TS       ITEMP3                                
057742,000084:    5525           34762                           CA       LOW4                                  #  DEC15
057743,000085:    5526           54061                           TS       ITEMP1                                
057744,000086:    5527           50063                           INDEX    ITEMP3                                
057745,000087:    5530           27777                           CA       0          -1                         #  ADRES
057746,000088:    5531           54001                           TS       L                                     
057747,000089:    5532           34755                           CA       ZERO                                  

Page 1376

057749,000091:    5533           00006                           EXTEND                                         
057750,000092:    5534           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
057751,000093:    5535           52062                           DXCH     ITEMP1                                
057752,000094:    5536           50061                           INDEX    ITEMP1                                
057753,000095:    5537           30074                           CA       FLAGWRD0                              
057754,000096:    5540           54001                           TS       L                                     #  CURRENT STATE
057755,000097:    5541           50062                           INDEX    ITEMP2                                
057756,000098:    5542           44735                           CS       BIT15                                 #  -(15 - BIT)
057757,000099:    5543           00002                           TC       Q                                     
057758,000100: 

Page 1377

057760,000102:                                                                                                  #  DELAYJOB - A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
057761,000103: 
057762,000104:                                                                                                  #  ENTRANCE REQUIREMENTS ...
057763,000105:                                                                                                  #                CAF     DT              DELAY JOB FOR DT CENTISECS
057764,000106:                                                                                                  #                TC      BANKCALL
057765,000107:                                                                                                  #                CADR    DELAYJOB
057766,000108: 
057767,000109: 06,3764                                           BANK     06                                    
057768,000110: 00,2000                                           SETLOC   DLAYJOB                               
057769,000111: 00,2000                                           BANK                                           
057770,000112: 
057771,000113:                                                                                                  #  THIS MUST REMAIN IN BANK 0 *****************************************
057772,000114: 
057773,000115: 00,3735                                           COUNT*   $$/DELAY                              
057774,000116: 00,3735           00004        DELAYJOB           INHINT                                         
057775,000117: 00,3736           54002                           TS       Q                                     #  STORE DELAY DT IN Q FOR DLY -1 IN
057776,000118: 00,3737           34752                           CAF      DELAYNUM                              #  WAITLIST
057777,000119: 00,3740           54070        DELLOOP            TS       RUPTREG1                              
057778,000120: 00,3741           50000                           INDEX    A                                     
057779,000121: 00,3742           31326                           CA       DELAYLOC                              #  IS THIS DELAYLOC AVAILABLE
057780,000122: 00,3743           00006                           EXTEND                                         
057781,000123: 00,3744           13752                           BZF      OK2DELAY                              #  YES
057782,000124: 
057783,000125: 00,3745           10070                           CCS      RUPTREG1                              #  NO, TRY NEXT DELAYLOC
057784,000126: 00,3746           13740                           TCF      DELLOOP                               
057785,000127: 
057786,000128: 00,3747           52134                           DXCH     BUF2                                  
057787,000129: 00,3750           05716                           TC       BAILOUT1                              #  NO AVAILABLE LOCS.
057788,000130: 00,3751           01104                           OCT      1104                                  
057789,000131: 
057790,000132: 00,3752           33772        OK2DELAY           CA       TCSLEEP                               #  SET WAITLIST IMMEDIATE RETURN
057791,000133: 00,3753           54061                           TS       WAITEXIT                              
057792,000134: 
057793,000135: 00,3754           30004                           CA       FBANK                                 
057794,000136: 00,3755           60070                           AD       RUPTREG1                              #  STORE BBANK FOR TASK CALL
057795,000137: 00,3756           54001                           TS       L                                     
057796,000138: 
057797,000139: 00,3757           33773                           CAF      WAKECAD                               #  STORE CADR FOR TASK CALL
057798,000140: 00,3760           15211                           TCF      DLY2       -1                         #  DLY IS IN WAITLIST ROUTINE
057799,000141: 
057800,000142: 00,3761           04645        TCGETCAD           TC       MAKECADR                              #  GET CALLERS FCADR
057801,000143: 
057802,000144: 00,3762           50070                           INDEX    RUPTREG1                              
057803,000145: 00,3763           55326                           TS       DELAYLOC                              #  SAVE DELAY CADRS
057804,000146: 
057805,000147: 00,3764           05133                           TC       JOBSLEEP                              
057806,000148: 
057807,000149: 00,3765           34755        WAKER              CAF      ZERO                                  
057808,000150: 00,3766           50006                           INDEX    BBANK                                 
057809,000151: 00,3767           57326                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE

Page 1378

057811,000153: 00,3770           05137                           TC       JOBWAKE                               
057812,000154: 
057813,000155: 00,3771           05261                           TC       TASKOVER                              
057814,000156: 
057815,000157: 00,3772           03757        TCSLEEP            GENADR   TCGETCAD   -2                         
057816,000158: 00,3773           03765        WAKECAD            GENADR   WAKER                                 
057817,000159: 

Page 1379

057819,000161:                                                                                                  #  GENTRAN, A BLOCK TRANSFER ROUTINE.
057820,000162:                                                                                                  #  WRITTEN BY D. EYLES
057821,000163:                                                                                                  #  MOD 1 BY KERNAN                               UTILITYM REV 17 11/18/67
057822,000164:                                                                                                  #  MOD 2 BY SCHULENBERG (REMOVE RELINT) SKIPPER REV 4 2/28/68
057823,000165: 
057824,000166:                                                                                                  #  THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
057825,000167:                                                                                                  #  CONSECUTIVE ERASABLE LOCATIONS.  IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
057826,000168: 
057827,000169:                                                                                                  #  GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT.  THE CALLING SEQUENCE IS:
057828,000170:                                                                                                  #        I       CA      N-1             # OF QUANTITIES MINUS ONE.
057829,000171:                                                                                                  #        I +1    TC      GENTRAN         IN FIXED-FIXED.
057830,000172:                                                                                                  #        I +2    ADRES   L               STARTING ADRES OF DATA TO BE MOVED.
057831,000173:                                                                                                  #        I +3    ADRES   M               STARTING ADRES OF DUPLICATION BLOCK.
057832,000174:                                                                                                  #        I +4                            RETURNS HERE.
057833,000175: 
057834,000176:                                                                                                  #  GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
057835,000177:                                                                                                  #  A, L AND ITEMP1 ARE NOT PRESERVED.
057836,000178: 
057837,000179:    5544                                           BLOCK    02                                    
057838,000180:    4000                                           SETLOC   FFTAG4                                
057839,000181:    4000                                           BANK                                           
057840,000182: 
057841,000183:    5544     0061                                  EBANK=   ITEMP1                                
057842,000184: 
057843,000185:    5544                                           COUNT*   $$/TRAN                               
057844,000186: 
057845,000187:    5544           00004        GENTRAN            INHINT                                         
057846,000188:    5545           54061                           TS       ITEMP1                                #  SAVE N-1.
057847,000189:    5546           50002                           INDEX    Q                                     #  C(Q) = ADRES L.
057848,000190:    5547           60000                           AD       0                                     #  ADRES (L + N - 1).
057849,000191:    5550           50000                           INDEX    A                                     
057850,000192:    5551           30000                           CA       0                                     #  C(ABOVE).
057851,000193:    5552           54001                           TS       L                                     #  SAVE DATA.
057852,000194:    5553           30061                           CA       ITEMP1                                
057853,000195:    5554           50002                           INDEX    Q                                     
057854,000196:    5555           60001                           AD       1                                     #  ADRES (M + N - 1).
057855,000197:    5556           50000                           INDEX    A                                     
057856,000198:    5557           22000                           LXCH     0                                     #  STUFF IT.
057857,000199:    5560           10061                           CCS      ITEMP1                                #  LOOP UNTIL N-1 = 0.
057858,000200:    5561           15545                           TCF      GENTRAN    +1                         
057859,000201:    5562           16741                           TCF      Q+2                                   #  RETURN TO CALLER.
057860,000202: 

Page 1380

057862,000204:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
057863,000205:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
057864,000206: 
057865,000207:    5563                                           COUNT*   $$/EXTVB                              
057866,000208: 
057867,000209:    5563           44747        B5OFF              CS       BIT5                                  
057868,000210:    5564           71044                           MASK     EXTVBACT                              
057869,000211:    5565           55044                           TS       EXTVBACT                              
057870,000212:    5566           05155                           TC       ENDOFJOB                              
057871,000213: 
057872,000214: 
057873,000215: 

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