Source Code

These source-code files are part of a reconstructed copy of Comanche 51, the initial release (though not the final mission release) of the Apollo 11 Command Module (CM) Apollo Guidance Computer (AGC) software. The flown, final release was Comanche 55. The reconstruction is believed to be exactly accurate, but in the absence of an actual Apollo-era listing of Comanche 51, some explanation of the reconstruction process is needed to insure confidence in that accuracy.

The starting point was the source code of Comanche 55, whose original source code is available. Comanche 55 source code was then modified by undoing changes known to have been made between revisions 51 and 55. The most-significant steps involved reverting changes related to the R-2 lunar potential model, the details of which were known from the previous, separate, independent reconstruction of the Apollo 10 Lunar Module software Luminary 69/2. The now-reconstructed Comanche 51 source code was verified by assembling it and checking that the assembled code had the expected known-correct memory-bank checksums. Note that page numbers in the reconstructed code match those on the Comanche 55 or Luminary 69 printouts, although the source code would likely have different page numbers in a contemporary Comanche 51 listing.

Annotations that were not present in the contemporary source code have been added to the reconstructed code to justify each change relative to Comanche 55. Here's a guide to some of the Apollo documentation relevant to those annotations:
Among documentation not actually referenced in the annotations, there is a short writeup about the reconstruction process in our software repository that may be helpful in understanding it from a different perspective. There's also a handy table that lists what the number of memory-words should be for each routine in Comanche 51, which could make a nice double-check; however, we've not performed that double-check ourselves.

Comments expected to have been present in 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.

063128,000002:                                                                                                  ## Copyright:   Public domain.
063129,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
063130,000004:                                                                                                  ## Purpose:     A section of Comanche revision 051.
063131,000005:                                                                                                  ##              It is part of the reconstructed source code for the
063132,000006:                                                                                                  ##              original release of the flight software for the Command
063133,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 11.
063134,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
063135,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
063136,000010:                                                                                                  ##              exactly match those specified for Comanche 51 in NASA drawing
063137,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
063138,000012:                                                                                                  ##              reconstruction is correct.
063139,000013:                                                                                                  ## Reference:   pp. 1485-1492
063140,000014:                                                                                                  ## Assembler:   yaYUL
063141,000015:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
063142,000016:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
063143,000017:                                                                                                  ## Mod history: 2019-07-30 MAS  Created from Comanche 55.
063144,000018: 

Page 1485

063146,000020:    7722                                           BLOCK    3                                     
063147,000021:    6000                                           SETLOC   FFTAG6                                
063148,000022:    6000                                           BANK                                           
063149,000023:    7722                                           COUNT    03/FLAG                               
063150,000024: 
063151,000025:    7722           54001        UPENT2             TS       L                                     #  WHICH FLAGWORD IS IT
063152,000026:    7723           75023                           MASK     OCT7                                  
063153,000027:    7724           56001                           XCH      L                                     #  SAVE IN L FOR INDEXING
063154,000028: 
063155,000029:    7725           75731                           MASK     OCT77770                              #  OBTAIN THE BIT INFORMATION
063156,000030:    7726           00004                           INHINT                                         #  PREVENT INTERUPTS
063157,000031:    7727           54061                           TS       ITEMP1                                #  STORE THE BIT INFORMATION TEMPORARIALY
063158,000032: 
063159,000033:    7730           50001                           NDX      L                                     
063160,000034:    7731           40074                           CS       FLAGWRD0                              
063161,000035:    7732           70061                           MASK     ITEMP1                                
063162,000036:    7733           50001                           NDX      L                                     
063163,000037:    7734           26074                           ADS      FLAGWRD0                              
063164,000038:    7735           00003                           RELINT                                         #  RELEASE INTERUPT INHIBIT
063165,000039: 
063166,000040:    7736           24002                           INCR     Q                                     #  OBTAIN THE CORRECT RETURN ADDRESS
063167,000041:    7737           00002                           TC       Q                                     #  RETURN
063168,000042: 
063169,000043:    7740           54001        DOWNENT2           TS       L                                     #  WHICH FLAGWORD IS IT
063170,000044:    7741           75023                           MASK     OCT7                                  
063171,000045:    7742           56001                           XCH      L                                     #  SAVE IN L FOR INDEXING
063172,000046: 
063173,000047:    7743           75731                           MASK     OCT77770                              #  OBTAIN THE BIT INFORMATION
063174,000048:    7744           40000                           COM                                            #  START TO PROCESS THE INFORMATION
063175,000049: 
063176,000050:    7745           00004                           INHINT                                         #  PREVENT INTERUPTS
063177,000051:    7746           50001                           NDX      L                                     
063178,000052:    7747           70074                           MASK     FLAGWRD0                              
063179,000053:    7750           50001                           NDX      L                                     
063180,000054:    7751           54074                           TS       FLAGWRD0                              
063181,000055:    7752           00003                           RELINT                                         #  RELEASE INTERUPT INHIBIT
063182,000056: 
063183,000057:    7753           24002                           INCR     Q                                     #  OBTAIN THE CORRECT RETURN ADDRESS
063184,000058:    7754           00002                           TC       Q                                     #  RETURN
063185,000059: 
063186,000060:    7755     5023               OCT7               EQUALS   SEVEN                                 
063187,000061: 10,3766                                           BANK     10                                    
063188,000062: 

Page 1486

063190,000064:                                                                                                  #  UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES.  USING THEM, WHETHER OR
063191,000065:                                                                                                  #  NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
063192,000066:                                                                                                  #  EBANK SETTING.  A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
063193,000067:                                                                                                  #  ASSEMBLER.
063194,000068: 
063195,000069:                                                                                                  #  AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS.  ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
063196,000070:                                                                                                  #  NAME ANY BIT IN ERASABLE MEMORY.
063197,000071: 
063198,000072:                                                                                                  #  CALLING SEQUENCES ARE AS FOLLOWS:-
063199,000073:                                                                                                  #                TC      UPFLAG                  TC      DOWNFLAG
063200,000074:                                                                                                  #                ADRES   NAME OF FLAG            ADRES   NAME OF FLAG
063201,000075: 
063202,000076:                                                                                                  #  RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
063203,000077:                                                                                                  #  UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
063204,000078: 
063205,000079:    5546                                           BLOCK    02                                    
063206,000080:    4000                                           SETLOC   FFTAG1                                
063207,000081:    4000                                           BANK                                           
063208,000082:    5546                                           COUNT*   $$/FLAG                               
063209,000083: 
063210,000084:    5546           30002        UPFLAG             CA       Q                                     
063211,000085:    5547           05564                           TC       DEBIT                                 
063212,000086:    5550           40000                           COM                                            #  +(15 - BIT)
063213,000087:    5551           00006                           EXTEND                                         
063214,000088:    5552           04001                           ROR      LCHAN                                 #  SET BIT
063215,000089:    5553           50061        COMFLAG            INDEX    ITEMP1                                
063216,000090:    5554           54074                           TS       FLAGWRD0                              
063217,000091:    5555           22063                           LXCH     ITEMP3                                
063218,000092:    5556           00003                           RELINT                                         
063219,000093:    5557           00001                           TC       L                                     
063220,000094: 
063221,000095:    5560           30002        DOWNFLAG           CA       Q                                     
063222,000096:    5561           05564                           TC       DEBIT                                 
063223,000097:    5562           70001                           MASK     L                                     #  RESET BIT
063224,000098:    5563           15553                           TCF      COMFLAG                               
063225,000099: 
063226,000100:    5564           65017        DEBIT              AD       ONE                                   #  GET DE BITS
063227,000101:    5565           00004                           INHINT                                         
063228,000102:    5566           54063                           TS       ITEMP3                                
063229,000103:    5567           35026                           CA       LOW4                                  #  DEC15
063230,000104:    5570           54061                           TS       ITEMP1                                
063231,000105:    5571           50063                           INDEX    ITEMP3                                
063232,000106:    5572           27777                           CA       0          -1                         #  ADRES
063233,000107:    5573           54001                           TS       L                                     
063234,000108:    5574           35021                           CA       ZERO                                  

Page 1487

063236,000110:    5575           00006                           EXTEND                                         
063237,000111:    5576           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
063238,000112:    5577           52062                           DXCH     ITEMP1                                
063239,000113:    5600           50061                           INDEX    ITEMP1                                
063240,000114:    5601           30074                           CA       FLAGWRD0                              
063241,000115:    5602           54001                           TS       L                                     #  CURRENT STATE
063242,000116:    5603           50062                           INDEX    ITEMP2                                
063243,000117:    5604           45001                           CS       BIT15                                 #  -(15 - BIT)
063244,000118:    5605           00002                           TC       Q                                     
063245,000119: 

Page 1488

063247,000121:                                                                                                  #  DELAYJOB- A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
063248,000122: 
063249,000123:                                                                                                  #  ENTRANCE REQUIREMENTS...
063250,000124:                                                                                                  #                CAF     DT              DELAY JOB FOR DT CENTISECS
063251,000125:                                                                                                  #                TC      BANKCALL
063252,000126:                                                                                                  #                CADR    DELAYJOB
063253,000127: 
063254,000128: 06,3770                                           BANK     06                                    
063255,000129: 00,2000                                           SETLOC   DLAYJOB                               
063256,000130: 00,2000                                           BANK                                           
063257,000131: 
063258,000132:                                                                                                  #  THIS MUST REMAIN IN BANK 0 *****************************************
063259,000133: 
063260,000134: 00,3732                                           COUNT    00/DELAY                              
063261,000135: 
063262,000136: 00,3732           00004        DELAYJOB           INHINT                                         
063263,000137: 00,3733           54002                           TS       Q                                     #  STORE DELAY DT IN Q FOR DLY -1 IN
063264,000138: 00,3734           36214                           CAF      DELAYNUM                              #  WAITLIST
063265,000139: 00,3735           54070        DELLOOP            TS       RUPTREG1                              
063266,000140: 00,3736           50000                           INDEX    A                                     
063267,000141: 00,3737           31141                           CA       DELAYLOC                              #  IS THIS DELAYLOC AVAILABLE
063268,000142: 00,3740           00006                           EXTEND                                         
063269,000143: 00,3741           13746                           BZF      OK2DELAY                              #  YES
063270,000144: 
063271,000145: 00,3742           10070                           CCS      RUPTREG1                              #  NO, TRY NEXT DELAYLOC
063272,000146: 00,3743           13735                           TCF      DELLOOP                               
063273,000147: 
063274,000148: 00,3744           07755                           TC       BAILOUT                               #  NO AVAILABLE LOCS AVAILABLE.
063275,000149: 00,3745           01104                           OCT      1104                                  
063276,000150: 
063277,000151: 00,3746           33766        OK2DELAY           CA       TCSLEEP                               #  SET WAITLIST IMMEDIATE RETURN
063278,000152: 00,3747           54061                           TS       WAITEXIT                              
063279,000153: 
063280,000154: 00,3750           30004                           CA       FBANK                                 
063281,000155: 00,3751           60070                           AD       RUPTREG1                              #  STORE BBANK FOR TASK CALL
063282,000156: 00,3752           54001                           TS       L                                     
063283,000157: 
063284,000158: 00,3753           33767                           CAF      WAKECAD                               #  STORE CADR FOR TASK CALL
063285,000159: 00,3754           15255                           TCF      DLY2       -1                         #  DLY IS IN WAITLIST ROUTINE
063286,000160: 
063287,000161: 00,3755           04711        TCGETCAD           TC       MAKECADR                              #  GET CALLERS FCADR
063288,000162: 
063289,000163: 00,3756           50070                           INDEX    RUPTREG1                              
063290,000164: 00,3757           55141                           TS       DELAYLOC                              #  SAVE DELAY CADRS
063291,000165: 
063292,000166: 00,3760           05175                           TC       JOBSLEEP                              
063293,000167: 
063294,000168: 00,3761           35021        WAKER              CAF      ZERO                                  
063295,000169: 00,3762           50006                           INDEX    BBANK                                 
063296,000170: 00,3763           57141                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE

Page 1489

063298,000172: 00,3764           05201                           TC       JOBWAKE                               
063299,000173: 
063300,000174: 00,3765           05324                           TC       TASKOVER                              
063301,000175: 
063302,000176: 00,3766           03753        TCSLEEP            GENADR   TCGETCAD   -2                         
063303,000177: 00,3767           03761        WAKECAD            GENADR   WAKER                                 
063304,000178: 

Page 1490

063306,000180:                                                                                                  #  GENTRAN, A BLOCK TRANSFER ROUTINE.
063307,000181:                                                                                                  #  WRITTEN BY D. EYLES
063308,000182:                                                                                                  #  MOD 1 BY KERNAN                               UTILITYM REV 17 11/18/67
063309,000183:                                                                                                  #  MOD 2 BY SCHULENBERG  (REMOVE RELINT)  SKIPPER REV 4 2/28/68
063310,000184: 
063311,000185:                                                                                                  #  THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
063312,000186:                                                                                                  #  CONSECUTIVE ERASABLE LOCATIONS.  IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
063313,000187: 
063314,000188:                                                                                                  #  GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT.  THE CALLING SEQUENCE IS:
063315,000189:                                                                                                  #        I       CA      N-1             # OF QUANTITIES MINUS ONE.
063316,000190:                                                                                                  #        I +1    TC      GENTRAN         IN FIXED-FIXED.
063317,000191:                                                                                                  #        I +2    ADRES   L               STARTING ADRES OF DATA TO BE MOVED.
063318,000192:                                                                                                  #        I +3    ADRES   M               STARTING ADRES OF DUPLICATION BLOCK.
063319,000193:                                                                                                  #        I +4                            RETURNS HERE.
063320,000194: 
063321,000195:                                                                                                  #  GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
063322,000196:                                                                                                  #  A, L AND ITEMP1 ARE NOT PRESERVED.
063323,000197: 
063324,000198:    5606                                           BLOCK    02                                    
063325,000199:    4000                                           SETLOC   FFTAG4                                
063326,000200:    4000                                           BANK                                           
063327,000201: 
063328,000202:    5606     0061                                  EBANK=   ITEMP1                                
063329,000203: 
063330,000204:    5606                                           COUNT*   $$/TRAN                               
063331,000205: 
063332,000206:    5606           00004        GENTRAN            INHINT                                         
063333,000207:    5607           54061                           TS       ITEMP1                                #  SAVE N-1.
063334,000208:    5610           50002                           INDEX    Q                                     #  C(Q) = ADRES L.
063335,000209:    5611           60000                           AD       0                                     #  ADRES (L + N - 1).
063336,000210:    5612           50000                           INDEX    A                                     
063337,000211:    5613           30000                           CA       0                                     #  C(ABOVE).
063338,000212:    5614           54001                           TS       L                                     #  SAVE DATA.
063339,000213:    5615           30061                           CA       ITEMP1                                
063340,000214:    5616           50002                           INDEX    Q                                     
063341,000215:    5617           60001                           AD       1                                     #  ADRES (M + N - 1).
063342,000216:    5620           50000                           INDEX    A                                     
063343,000217:    5621           22000                           LXCH     0                                     #  STUFF IT.
063344,000218:    5622           10061                           CCS      ITEMP1                                #  LOOP UNTIL N-1 = 0.
063345,000219:    5623           15607                           TCF      GENTRAN    +1                         
063346,000220:    5624           16710                           TCF      Q+2                                   #  RETURN TO CALLER.
063347,000221: 

Page 1491

063349,000223:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
063350,000224:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
063351,000225: 
063352,000226:    5625                                           COUNT*   $$/EXTVB                              
063353,000227: 
063354,000228:    5625           45013        B5OFF              CS       BIT5                                  
063355,000229:    5626           71044                           MASK     EXTVBACT                              
063356,000230:    5627           55044                           TS       EXTVBACT                              
063357,000231:    5630           05217                           TC       ENDOFJOB                              
063358,000232: 

Page 1492

063360,000234:                                                                                                  #  SUBROUTINES TO TURN OFF AND TURN ON TRACKER FAIL LIGHT.
063361,000235: 
063362,000236:    5631           00004        TRFAILOF           INHINT                                         
063363,000237:    5632           47704                           CS       OCT40200                              #  TURN OFF TRACKER LIGHT
063364,000238:    5633           71036                           MASK     DSPTAB     +11D                       
063365,000239:    5634           65001                           AD       BIT15                                 
063366,000240:    5635           55036                           TS       DSPTAB     +11D                       
063367,000241:    5636           41331                           CS       OPTMODES                              #  TO INSURE THAT OCDU FAIL WILL GO ON
063368,000242:    5637           75011                           MASK     BIT7                                  #  AGAIN IF IT WAS ON IN ADDITION TO
063369,000243:    5640           27331                           ADS      OPTMODES                              #  TRACKER FAIL.
063370,000244: 
063371,000245:    5641           00003        REQ                RELINT                                         
063372,000246:    5642           00002                           TC       Q                                     
063373,000247: 
063374,000248:    5643           00004        TRFAILON           INHINT                                         
063375,000249:    5644           41036                           CS       DSPTAB     +11D                       #  TURN ON
063376,000250:    5645           77704                           MASK     OCT40200                              
063377,000251:    5646           27036                           ADS      DSPTAB     +11D                       
063378,000252:    5647           15641                           TCF      REQ                                   
063379,000253: 
063380,000254: 
063381,000255: 
063382,000256: 

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