Source Code

These source-code files are part of a reconstructed copy of Comanche 45, the second release, though not the final mission release, of the Apollo 10 Command Module (CM) Apollo Guidance Computer (AGC) software. Comanche 45 was preceded by Comanche 44 and followed by Comanche 45/2 (the flown release). The reconstruction is believed to be exactly accurate, but in the absence of an actual Apollo-era listing of Comanche 45, some explanation of the reconstruction process is needed to insure confidence in that accuracy.

The starting point was the source code of Comanche 44 (itself previously accurately reconstructed). Comanche 44 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 44 and 45. The now-reconstructed Comanche 45 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 tend to match those in the Comanche 55, the most-similar revision of Comanche for which we have access to an actual non-reconstructed hardcopy; the source code would likely have different page numbers in a contemporary Comanche 45 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 44. Here's a guide to the Apollo documentation referenced in those annotations:
There is also a detailed commentary about the reconstruction process.

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.

063069,000002:                                                                                                  ## Copyright:   Public domain.
063070,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
063071,000004:                                                                                                  ## Purpose:     A section of Comanche revision 045.
063072,000005:                                                                                                  ##              It is part of the reconstructed source code for the
063073,000006:                                                                                                  ##              second release of the flight software for the Command
063074,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
063075,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
063076,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
063077,000010:                                                                                                  ##              exactly match those specified for Comanche 45 in NASA drawing
063078,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
063079,000012:                                                                                                  ##              reconstruction is correct.
063080,000013:                                                                                                  ## Assembler:   yaYUL
063081,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
063082,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
063083,000016:                                                                                                  ## Mod history: 2020-12-06 MAS  Created from Comanche 44.
063084,000017: 

Page 1485

063086,000019:    7722                                           BLOCK    3                                     
063087,000020:    6000                                           SETLOC   FFTAG6                                
063088,000021:    6000                                           BANK                                           
063089,000022:    7722                                           COUNT    03/FLAG                               
063090,000023: 
063091,000024:    7722           54001        UPENT2             TS       L                                     #  WHICH FLAGWORD IS IT
063092,000025:    7723           75023                           MASK     OCT7                                  
063093,000026:    7724           56001                           XCH      L                                     #  SAVE IN L FOR INDEXING
063094,000027: 
063095,000028:    7725           75731                           MASK     OCT77770                              #  OBTAIN THE BIT INFORMATION
063096,000029:    7726           00004                           INHINT                                         #  PREVENT INTERUPTS
063097,000030:    7727           54061                           TS       ITEMP1                                #  STORE THE BIT INFORMATION TEMPORARIALY
063098,000031: 
063099,000032:    7730           50001                           NDX      L                                     
063100,000033:    7731           40074                           CS       FLAGWRD0                              
063101,000034:    7732           70061                           MASK     ITEMP1                                
063102,000035:    7733           50001                           NDX      L                                     
063103,000036:    7734           26074                           ADS      FLAGWRD0                              
063104,000037:    7735           00003                           RELINT                                         #  RELEASE INTERUPT INHIBIT
063105,000038: 
063106,000039:    7736           24002                           INCR     Q                                     #  OBTAIN THE CORRECT RETURN ADDRESS
063107,000040:    7737           00002                           TC       Q                                     #  RETURN
063108,000041: 
063109,000042:    7740           54001        DOWNENT2           TS       L                                     #  WHICH FLAGWORD IS IT
063110,000043:    7741           75023                           MASK     OCT7                                  
063111,000044:    7742           56001                           XCH      L                                     #  SAVE IN L FOR INDEXING
063112,000045: 
063113,000046:    7743           75731                           MASK     OCT77770                              #  OBTAIN THE BIT INFORMATION
063114,000047:    7744           40000                           COM                                            #  START TO PROCESS THE INFORMATION
063115,000048: 
063116,000049:    7745           00004                           INHINT                                         #  PREVENT INTERUPTS
063117,000050:    7746           50001                           NDX      L                                     
063118,000051:    7747           70074                           MASK     FLAGWRD0                              
063119,000052:    7750           50001                           NDX      L                                     
063120,000053:    7751           54074                           TS       FLAGWRD0                              
063121,000054:    7752           00003                           RELINT                                         #  RELEASE INTERUPT INHIBIT
063122,000055: 
063123,000056:    7753           24002                           INCR     Q                                     #  OBTAIN THE CORRECT RETURN ADDRESS
063124,000057:    7754           00002                           TC       Q                                     #  RETURN
063125,000058: 
063126,000059:    7755     5023               OCT7               EQUALS   SEVEN                                 
063127,000060: 10,3766                                           BANK     10                                    
063128,000061: 

Page 1486

063130,000063:                                                                                                  #  UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES.  USING THEM, WHETHER OR
063131,000064:                                                                                                  #  NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
063132,000065:                                                                                                  #  EBANK SETTING.  A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
063133,000066:                                                                                                  #  ASSEMBLER.
063134,000067: 
063135,000068:                                                                                                  #  AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS.  ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
063136,000069:                                                                                                  #  NAME ANY BIT IN ERASABLE MEMORY.
063137,000070: 
063138,000071:                                                                                                  #  CALLING SEQUENCES ARE AS FOLLOWS:-
063139,000072:                                                                                                  #                TC      UPFLAG                  TC      DOWNFLAG
063140,000073:                                                                                                  #                ADRES   NAME OF FLAG            ADRES   NAME OF FLAG
063141,000074: 
063142,000075:                                                                                                  #  RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
063143,000076:                                                                                                  #  UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
063144,000077: 
063145,000078:    5546                                           BLOCK    02                                    
063146,000079:    4000                                           SETLOC   FFTAG1                                
063147,000080:    4000                                           BANK                                           
063148,000081:    5546                                           COUNT*   $$/FLAG                               
063149,000082: 
063150,000083:    5546           30002        UPFLAG             CA       Q                                     
063151,000084:    5547           05564                           TC       DEBIT                                 
063152,000085:    5550           40000                           COM                                            #  +(15 - BIT)
063153,000086:    5551           00006                           EXTEND                                         
063154,000087:    5552           04001                           ROR      LCHAN                                 #  SET BIT
063155,000088:    5553           50061        COMFLAG            INDEX    ITEMP1                                
063156,000089:    5554           54074                           TS       FLAGWRD0                              
063157,000090:    5555           22063                           LXCH     ITEMP3                                
063158,000091:    5556           00003                           RELINT                                         
063159,000092:    5557           00001                           TC       L                                     
063160,000093: 
063161,000094:    5560           30002        DOWNFLAG           CA       Q                                     
063162,000095:    5561           05564                           TC       DEBIT                                 
063163,000096:    5562           70001                           MASK     L                                     #  RESET BIT
063164,000097:    5563           15553                           TCF      COMFLAG                               
063165,000098: 
063166,000099:    5564           65017        DEBIT              AD       ONE                                   #  GET DE BITS
063167,000100:    5565           00004                           INHINT                                         
063168,000101:    5566           54063                           TS       ITEMP3                                
063169,000102:    5567           35026                           CA       LOW4                                  #  DEC15
063170,000103:    5570           54061                           TS       ITEMP1                                
063171,000104:    5571           50063                           INDEX    ITEMP3                                
063172,000105:    5572           27777                           CA       0          -1                         #  ADRES
063173,000106:    5573           54001                           TS       L                                     
063174,000107:    5574           35021                           CA       ZERO                                  

Page 1487

063176,000109:    5575           00006                           EXTEND                                         
063177,000110:    5576           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
063178,000111:    5577           52062                           DXCH     ITEMP1                                
063179,000112:    5600           50061                           INDEX    ITEMP1                                
063180,000113:    5601           30074                           CA       FLAGWRD0                              
063181,000114:    5602           54001                           TS       L                                     #  CURRENT STATE
063182,000115:    5603           50062                           INDEX    ITEMP2                                
063183,000116:    5604           45001                           CS       BIT15                                 #  -(15 - BIT)
063184,000117:    5605           00002                           TC       Q                                     
063185,000118: 

Page 1488

063187,000120:                                                                                                  #  DELAYJOB- A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
063188,000121: 
063189,000122:                                                                                                  #  ENTRANCE REQUIREMENTS...
063190,000123:                                                                                                  #                CAF     DT              DELAY JOB FOR DT CENTISECS
063191,000124:                                                                                                  #                TC      BANKCALL
063192,000125:                                                                                                  #                CADR    DELAYJOB
063193,000126: 
063194,000127: 06,3770                                           BANK     06                                    
063195,000128: 00,2000                                           SETLOC   DLAYJOB                               
063196,000129: 00,2000                                           BANK                                           
063197,000130: 
063198,000131:                                                                                                  #  THIS MUST REMAIN IN BANK 0 *****************************************
063199,000132: 
063200,000133: 00,3732                                           COUNT    00/DELAY                              
063201,000134: 
063202,000135: 00,3732           00004        DELAYJOB           INHINT                                         
063203,000136: 00,3733           54002                           TS       Q                                     #  STORE DELAY DT IN Q FOR DLY -1 IN
063204,000137: 00,3734           36214                           CAF      DELAYNUM                              #  WAITLIST
063205,000138: 00,3735           54070        DELLOOP            TS       RUPTREG1                              
063206,000139: 00,3736           50000                           INDEX    A                                     
063207,000140: 00,3737           31141                           CA       DELAYLOC                              #  IS THIS DELAYLOC AVAILABLE
063208,000141: 00,3740           00006                           EXTEND                                         
063209,000142: 00,3741           13746                           BZF      OK2DELAY                              #  YES
063210,000143: 
063211,000144: 00,3742           10070                           CCS      RUPTREG1                              #  NO, TRY NEXT DELAYLOC
063212,000145: 00,3743           13735                           TCF      DELLOOP                               
063213,000146: 
063214,000147: 00,3744           07755                           TC       BAILOUT                               #  NO AVAILABLE LOCS AVAILABLE.
063215,000148: 00,3745           01104                           OCT      1104                                  
063216,000149: 
063217,000150: 00,3746           33766        OK2DELAY           CA       TCSLEEP                               #  SET WAITLIST IMMEDIATE RETURN
063218,000151: 00,3747           54061                           TS       WAITEXIT                              
063219,000152: 
063220,000153: 00,3750           30004                           CA       FBANK                                 
063221,000154: 00,3751           60070                           AD       RUPTREG1                              #  STORE BBANK FOR TASK CALL
063222,000155: 00,3752           54001                           TS       L                                     
063223,000156: 
063224,000157: 00,3753           33767                           CAF      WAKECAD                               #  STORE CADR FOR TASK CALL
063225,000158: 00,3754           15255                           TCF      DLY2       -1                         #  DLY IS IN WAITLIST ROUTINE
063226,000159: 
063227,000160: 00,3755           04711        TCGETCAD           TC       MAKECADR                              #  GET CALLERS FCADR
063228,000161: 
063229,000162: 00,3756           50070                           INDEX    RUPTREG1                              
063230,000163: 00,3757           55141                           TS       DELAYLOC                              #  SAVE DELAY CADRS
063231,000164: 
063232,000165: 00,3760           05175                           TC       JOBSLEEP                              
063233,000166: 
063234,000167: 00,3761           35021        WAKER              CAF      ZERO                                  
063235,000168: 00,3762           50006                           INDEX    BBANK                                 
063236,000169: 00,3763           57141                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE

Page 1489

063238,000171: 00,3764           05201                           TC       JOBWAKE                               
063239,000172: 
063240,000173: 00,3765           05324                           TC       TASKOVER                              
063241,000174: 
063242,000175: 00,3766           03753        TCSLEEP            GENADR   TCGETCAD   -2                         
063243,000176: 00,3767           03761        WAKECAD            GENADR   WAKER                                 
063244,000177: 

Page 1490

063246,000179:                                                                                                  #  GENTRAN, A BLOCK TRANSFER ROUTINE.
063247,000180:                                                                                                  #  WRITTEN BY D. EYLES
063248,000181:                                                                                                  #  MOD 1 BY KERNAN                               UTILITYM REV 17 11/18/67
063249,000182:                                                                                                  #  MOD 2 BY SCHULENBERG  (REMOVE RELINT)  SKIPPER REV 4 2/28/68
063250,000183: 
063251,000184:                                                                                                  #  THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
063252,000185:                                                                                                  #  CONSECUTIVE ERASABLE LOCATIONS.  IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
063253,000186: 
063254,000187:                                                                                                  #  GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT.  THE CALLING SEQUENCE IS:
063255,000188:                                                                                                  #        I       CA      N-1             # OF QUANTITIES MINUS ONE.
063256,000189:                                                                                                  #        I +1    TC      GENTRAN         IN FIXED-FIXED.
063257,000190:                                                                                                  #        I +2    ADRES   L               STARTING ADRES OF DATA TO BE MOVED.
063258,000191:                                                                                                  #        I +3    ADRES   M               STARTING ADRES OF DUPLICATION BLOCK.
063259,000192:                                                                                                  #        I +4                            RETURNS HERE.
063260,000193: 
063261,000194:                                                                                                  #  GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
063262,000195:                                                                                                  #  A, L AND ITEMP1 ARE NOT PRESERVED.
063263,000196: 
063264,000197:    5606                                           BLOCK    02                                    
063265,000198:    4000                                           SETLOC   FFTAG4                                
063266,000199:    4000                                           BANK                                           
063267,000200: 
063268,000201:    5606     0061                                  EBANK=   ITEMP1                                
063269,000202: 
063270,000203:    5606                                           COUNT*   $$/TRAN                               
063271,000204: 
063272,000205:    5606           00004        GENTRAN            INHINT                                         
063273,000206:    5607           54061                           TS       ITEMP1                                #  SAVE N-1.
063274,000207:    5610           50002                           INDEX    Q                                     #  C(Q) = ADRES L.
063275,000208:    5611           60000                           AD       0                                     #  ADRES (L + N - 1).
063276,000209:    5612           50000                           INDEX    A                                     
063277,000210:    5613           30000                           CA       0                                     #  C(ABOVE).
063278,000211:    5614           54001                           TS       L                                     #  SAVE DATA.
063279,000212:    5615           30061                           CA       ITEMP1                                
063280,000213:    5616           50002                           INDEX    Q                                     
063281,000214:    5617           60001                           AD       1                                     #  ADRES (M + N - 1).
063282,000215:    5620           50000                           INDEX    A                                     
063283,000216:    5621           22000                           LXCH     0                                     #  STUFF IT.
063284,000217:    5622           10061                           CCS      ITEMP1                                #  LOOP UNTIL N-1 = 0.
063285,000218:    5623           15607                           TCF      GENTRAN    +1                         
063286,000219:    5624           16710                           TCF      Q+2                                   #  RETURN TO CALLER.
063287,000220: 

Page 1491

063289,000222:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
063290,000223:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
063291,000224: 
063292,000225:    5625                                           COUNT*   $$/EXTVB                              
063293,000226: 
063294,000227:    5625           45013        B5OFF              CS       BIT5                                  
063295,000228:    5626           71044                           MASK     EXTVBACT                              
063296,000229:    5627           55044                           TS       EXTVBACT                              
063297,000230:    5630           05217                           TC       ENDOFJOB                              
063298,000231: 

Page 1492

063300,000233:                                                                                                  #  SUBROUTINES TO TURN OFF AND TURN ON TRACKER FAIL LIGHT.
063301,000234: 
063302,000235:    5631           00004        TRFAILOF           INHINT                                         
063303,000236:    5632           47704                           CS       OCT40200                              #  TURN OFF TRACKER LIGHT
063304,000237:    5633           71036                           MASK     DSPTAB     +11D                       
063305,000238:    5634           65001                           AD       BIT15                                 
063306,000239:    5635           55036                           TS       DSPTAB     +11D                       
063307,000240:    5636           41331                           CS       OPTMODES                              #  TO INSURE THAT OCDU FAIL WILL GO ON
063308,000241:    5637           75011                           MASK     BIT7                                  #  AGAIN IF IT WAS ON IN ADDITION TO
063309,000242:    5640           27331                           ADS      OPTMODES                              #  TRACKER FAIL.
063310,000243: 
063311,000244:    5641           00003        REQ                RELINT                                         
063312,000245:    5642           00002                           TC       Q                                     
063313,000246: 
063314,000247:    5643           00004        TRFAILON           INHINT                                         
063315,000248:    5644           41036                           CS       DSPTAB     +11D                       #  TURN ON
063316,000249:    5645           77704                           MASK     OCT40200                              
063317,000250:    5646           27036                           ADS      DSPTAB     +11D                       
063318,000251:    5647           15641                           TCF      REQ                                   
063319,000252: 
063320,000253: 
063321,000254: 
063322,000255: 

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