Source Code

These source-code files are part of a reconstructed copy of Comanche 72/3 (AKA Manche72 revision 3), the final, flown mission release of the Apollo Guidance Computer (AGC) Command Module (CM) software for Apollo 13.

The starting point was the source code of Comanche 72 (itself previously reconstructed). Comanche 72 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 72 and 72/3. The resulting code assembles to have identical memory-bank checksums as those specified in NASA drawing 2021153G; this gives reasonably high confidence that the changes that have been made are correct. In places where ambiguity exists, this ambiguity is discussed in "## Reconstruction:" comments.

Since no contemporary listings of Comanche 72/3 are available as source material, all comments and labels are approximate. They have been taken from other AGC programs where possible, or, in some places, written from scratch to match what we believe would have been in the original listing.

061881,000002:                                                                                                  ## Copyright:   Public domain.
061882,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
061883,000004:                                                                                                  ## Purpose:     A section of Manche72 revision 3.
061884,000005:                                                                                                  ##              It is part of the reconstructed source code for the final, flown
061885,000006:                                                                                                  ##              release of the software for the Command Module's (CM) Apollo
061886,000007:                                                                                                  ##              Guidance Computer (AGC) for Apollo 13. No original listings
061887,000008:                                                                                                  ##              of this program are available; instead, this file was recreated
061888,000009:                                                                                                  ##              from a reconstructed copy of Comanche 072. It has been adapted
061889,000010:                                                                                                  ##              such that the resulting bugger words exactly match those
061890,000011:                                                                                                  ##              specified for Manche72 revision 3 in NASA drawing 2021153G,
061891,000012:                                                                                                  ##              which gives relatively high confidence that the reconstruction
061892,000013:                                                                                                  ##              is correct.
061893,000014:                                                                                                  ## Assembler:   yaYUL
061894,000015:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
061895,000016:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
061896,000017:                                                                                                  ## Mod history: 2024-05-19 MAS  Created from Comanche 072.
061897,000018: 
061898,000019:    7722                                           BLOCK    3                                     
061899,000020:    6000                                           SETLOC   FFTAG6                                
061900,000021:    6000                                           BANK                                           
061901,000022:    7722                                           COUNT    03/FLAG                               
061902,000023: 
061903,000024:    7722           54001        UPENT2             TS       L                                     #  WHICH FLAGWORD IS IT
061904,000025:    7723           75037                           MASK     OCT7                                  
061905,000026:    7724           56001                           XCH      L                                     #  SAVE IN L FOR INDEXING
061906,000027: 
061907,000028:    7725           75735                           MASK     OCT77770                              #  OBTAIN THE BIT INFORMATION
061908,000029:    7726           00004                           INHINT                                         #  PREVENT INTERUPTS
061909,000030:    7727           54061                           TS       ITEMP1                                #  STORE THE BIT INFORMATION TEMPORARIALY
061910,000031: 
061911,000032:    7730           50001                           NDX      L                                     
061912,000033:    7731           40074                           CS       FLAGWRD0                              
061913,000034:    7732           70061                           MASK     ITEMP1                                
061914,000035:    7733           50001                           NDX      L                                     
061915,000036:    7734           26074                           ADS      FLAGWRD0                              
061916,000037:    7735           00003                           RELINT                                         #  RELEASE INTERUPT INHIBIT
061917,000038: 
061918,000039:    7736           24002                           INCR     Q                                     #  OBTAIN THE CORRECT RETURN ADDRESS
061919,000040:    7737           00002                           TC       Q                                     #  RETURN
061920,000041: 
061921,000042:    7740           54001        DOWNENT2           TS       L                                     #  WHICH FLAGWORD IS IT
061922,000043:    7741           75037                           MASK     OCT7                                  
061923,000044:    7742           56001                           XCH      L                                     #  SAVE IN L FOR INDEXING
061924,000045: 
061925,000046:    7743           75735                           MASK     OCT77770                              #  OBTAIN THE BIT INFORMATION
061926,000047:    7744           40000                           COM                                            #  START TO PROCESS THE INFORMATION
061927,000048: 
061928,000049:    7745           00004                           INHINT                                         #  PREVENT INTERUPTS
061929,000050:    7746           50001                           NDX      L                                     
061930,000051:    7747           70074                           MASK     FLAGWRD0                              
061931,000052:    7750           50001                           NDX      L                                     
061932,000053:    7751           54074                           TS       FLAGWRD0                              
061933,000054:    7752           00003                           RELINT                                         #  RELEASE INTERUPT INHIBIT
061934,000055: 
061935,000056:    7753           24002                           INCR     Q                                     #  OBTAIN THE CORRECT RETURN ADDRESS
061936,000057:    7754           00002                           TC       Q                                     #  RETURN
061937,000058: 
061938,000059:    7755     5037               OCT7               EQUALS   SEVEN                                 
061939,000060: 10,3766                                           BANK     10                                    
061940,000061: 
061941,000062:                                                                                                  #  UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES.  USING THEM, WHETHER OR
061942,000063:                                                                                                  #  NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
061943,000064:                                                                                                  #  EBANK SETTING.  A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
061944,000065:                                                                                                  #  ASSEMBLER.
061945,000066: 
061946,000067:                                                                                                  #  AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS.  ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
061947,000068:                                                                                                  #  NAME ANY BIT IN ERASABLE MEMORY.
061948,000069: 
061949,000070:                                                                                                  #  CALLING SEQUENCES ARE AS FOLLOWS:-
061950,000071:                                                                                                  #                TC      UPFLAG                  TC      DOWNFLAG
061951,000072:                                                                                                  #                ADRES   NAME OF FLAG            ADRES   NAME OF FLAG
061952,000073: 
061953,000074:                                                                                                  #  RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
061954,000075:                                                                                                  #  UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
061955,000076: 
061956,000077:    5562                                           BLOCK    02                                    
061957,000078:    4000                                           SETLOC   FFTAG1                                
061958,000079:    4000                                           BANK                                           
061959,000080:    5562                                           COUNT*   $$/FLAG                               
061960,000081: 
061961,000082:    5562           30002        UPFLAG             CA       Q                                     
061962,000083:    5563           05600                           TC       DEBIT                                 
061963,000084:    5564           40000                           COM                                            #  +(15 - BIT)
061964,000085:    5565           00006                           EXTEND                                         
061965,000086:    5566           04001                           ROR      LCHAN                                 #  SET BIT
061966,000087:    5567           50061        COMFLAG            INDEX    ITEMP1                                
061967,000088:    5570           54074                           TS       FLAGWRD0                              
061968,000089:    5571           22063                           LXCH     ITEMP3                                
061969,000090:    5572           00003                           RELINT                                         
061970,000091:    5573           00001                           TC       L                                     
061971,000092: 
061972,000093:    5574           30002        DOWNFLAG           CA       Q                                     
061973,000094:    5575           05600                           TC       DEBIT                                 
061974,000095:    5576           70001                           MASK     L                                     #  RESET BIT
061975,000096:    5577           15567                           TCF      COMFLAG                               
061976,000097: 
061977,000098:    5600           65033        DEBIT              AD       ONE                                   #  GET DE BITS
061978,000099:    5601           00004                           INHINT                                         
061979,000100:    5602           54063                           TS       ITEMP3                                
061980,000101:    5603           35042                           CA       LOW4                                  #  DEC15
061981,000102:    5604           54061                           TS       ITEMP1                                
061982,000103:    5605           50063                           INDEX    ITEMP3                                
061983,000104:    5606           27777                           CA       0          -1                         #  ADRES
061984,000105:    5607           54001                           TS       L                                     
061985,000106:    5610           35035                           CA       ZERO                                  
061986,000107:    5611           00006                           EXTEND                                         
061987,000108:    5612           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
061988,000109:    5613           52062                           DXCH     ITEMP1                                
061989,000110:    5614           50061                           INDEX    ITEMP1                                
061990,000111:    5615           30074                           CA       FLAGWRD0                              
061991,000112:    5616           54001                           TS       L                                     #  CURRENT STATE
061992,000113:    5617           50062                           INDEX    ITEMP2                                
061993,000114:    5620           45015                           CS       BIT15                                 #  -(15 - BIT)
061994,000115:    5621           00002                           TC       Q                                     
061995,000116: 
061996,000117:                                                                                                  #  DELAYJOB- A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
061997,000118: 
061998,000119:                                                                                                  #  ENTRANCE REQUIREMENTS...
061999,000120:                                                                                                  #                CAF     DT              DELAY JOB FOR DT CENTISECS
062000,000121:                                                                                                  #                TC      BANKCALL
062001,000122:                                                                                                  #                CADR    DELAYJOB
062002,000123: 
062003,000124: 06,3770                                           BANK     06                                    
062004,000125: 00,2000                                           SETLOC   DLAYJOB                               
062005,000126: 00,2000                                           BANK                                           
062006,000127: 
062007,000128:                                                                                                  #  THIS MUST REMAIN IN BANK 0 *****************************************
062008,000129: 
062009,000130: 00,3732                                           COUNT    00/DELAY                              
062010,000131: 
062011,000132: 00,3732           00004        DELAYJOB           INHINT                                         
062012,000133: 00,3733           54002                           TS       Q                                     #  STORE DELAY DT IN Q FOR DLY -1 IN
062013,000134: 00,3734           36214                           CAF      DELAYNUM                              #  WAITLIST
062014,000135: 00,3735           54070        DELLOOP            TS       RUPTREG1                              
062015,000136: 00,3736           50000                           INDEX    A                                     
062016,000137: 00,3737           31141                           CA       DELAYLOC                              #  IS THIS DELAYLOC AVAILABLE
062017,000138: 00,3740           00006                           EXTEND                                         
062018,000139: 00,3741           13746                           BZF      OK2DELAY                              #  YES
062019,000140: 
062020,000141: 00,3742           10070                           CCS      RUPTREG1                              #  NO, TRY NEXT DELAYLOC
062021,000142: 00,3743           13735                           TCF      DELLOOP                               
062022,000143: 
062023,000144: 00,3744           07755                           TC       BAILOUT                               #  NO AVAILABLE LOCS AVAILABLE.
062024,000145: 00,3745           31104                           OCT      31104                                 
062025,000146: 
062026,000147: 00,3746           33766        OK2DELAY           CA       TCSLEEP                               #  SET WAITLIST IMMEDIATE RETURN
062027,000148: 00,3747           54061                           TS       WAITEXIT                              
062028,000149: 
062029,000150: 00,3750           30004                           CA       FBANK                                 
062030,000151: 00,3751           60070                           AD       RUPTREG1                              #  STORE BBANK FOR TASK CALL
062031,000152: 00,3752           54001                           TS       L                                     
062032,000153: 
062033,000154: 00,3753           33767                           CAF      WAKECAD                               #  STORE CADR FOR TASK CALL
062034,000155: 00,3754           15271                           TCF      DLY2       -1                         #  DLY IS IN WAITLIST ROUTINE
062035,000156: 
062036,000157: 00,3755           04725        TCGETCAD           TC       MAKECADR                              #  GET CALLERS FCADR
062037,000158: 
062038,000159: 00,3756           50070                           INDEX    RUPTREG1                              
062039,000160: 00,3757           55141                           TS       DELAYLOC                              #  SAVE DELAY CADRS
062040,000161: 
062041,000162: 00,3760           05211                           TC       JOBSLEEP                              
062042,000163: 
062043,000164: 00,3761           35035        WAKER              CAF      ZERO                                  
062044,000165: 00,3762           50006                           INDEX    BBANK                                 
062045,000166: 00,3763           57141                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE
062046,000167: 00,3764           05215                           TC       JOBWAKE                               
062047,000168: 
062048,000169: 00,3765           05340                           TC       TASKOVER                              
062049,000170: 
062050,000171: 00,3766           03753        TCSLEEP            GENADR   TCGETCAD   -2                         
062051,000172: 00,3767           03761        WAKECAD            GENADR   WAKER                                 
062052,000173: 
062053,000174:                                                                                                  #  GENTRAN, A BLOCK TRANSFER ROUTINE.
062054,000175:                                                                                                  #  WRITTEN BY D. EYLES
062055,000176:                                                                                                  #  MOD 1 BY KERNAN                               UTILITYM REV 17 11/18/67
062056,000177:                                                                                                  #  MOD 2 BY SCHULENBERG  (REMOVE RELINT)  SKIPPER REV 4 2/28/68
062057,000178: 
062058,000179:                                                                                                  #  THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
062059,000180:                                                                                                  #  CONSECUTIVE ERASABLE LOCATIONS.  IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
062060,000181: 
062061,000182:                                                                                                  #  GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT.  THE CALLING SEQUENCE IS:
062062,000183:                                                                                                  #        I       CA      N-1             # OF QUANTITIES MINUS ONE.
062063,000184:                                                                                                  #        I +1    TC      GENTRAN         IN FIXED-FIXED.
062064,000185:                                                                                                  #        I +2    ADRES   L               STARTING ADRES OF DATA TO BE MOVED.
062065,000186:                                                                                                  #        I +3    ADRES   M               STARTING ADRES OF DUPLICATION BLOCK.
062066,000187:                                                                                                  #        I +4                            RETURNS HERE.
062067,000188: 
062068,000189:                                                                                                  #  GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
062069,000190:                                                                                                  #  A, L AND ITEMP1 ARE NOT PRESERVED.
062070,000191: 
062071,000192:    5622                                           BLOCK    02                                    
062072,000193:    4000                                           SETLOC   FFTAG4                                
062073,000194:    4000                                           BANK                                           
062074,000195: 
062075,000196:    5622     0061                                  EBANK=   ITEMP1                                
062076,000197: 
062077,000198:    5622                                           COUNT*   $$/TRAN                               
062078,000199: 
062079,000200:    5622           00004        GENTRAN            INHINT                                         
062080,000201:    5623           54061                           TS       ITEMP1                                #  SAVE N-1.
062081,000202:    5624           50002                           INDEX    Q                                     #  C(Q) = ADRES L.
062082,000203:    5625           60000                           AD       0                                     #  ADRES (L + N - 1).
062083,000204:    5626           50000                           INDEX    A                                     
062084,000205:    5627           30000                           CA       0                                     #  C(ABOVE).
062085,000206:    5630           54001                           TS       L                                     #  SAVE DATA.
062086,000207:    5631           30061                           CA       ITEMP1                                
062087,000208:    5632           50002                           INDEX    Q                                     
062088,000209:    5633           60001                           AD       1                                     #  ADRES (M + N - 1).
062089,000210:    5634           50000                           INDEX    A                                     
062090,000211:    5635           22000                           LXCH     0                                     #  STUFF IT.
062091,000212:    5636           10061                           CCS      ITEMP1                                #  LOOP UNTIL N-1 = 0.
062092,000213:    5637           15623                           TCF      GENTRAN    +1                         
062093,000214:    5640           16710                           TCF      Q+2                                   #  RETURN TO CALLER.
062094,000215: 
062095,000216:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
062096,000217:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
062097,000218: 
062098,000219:    5641                                           COUNT*   $$/EXTVB                              
062099,000220: 
062100,000221:    5641           45027        B5OFF              CS       BIT5                                  
062101,000222:    5642           71044                           MASK     EXTVBACT                              
062102,000223:    5643           55044                           TS       EXTVBACT                              
062103,000224:    5644           05233                           TC       ENDOFJOB                              
062104,000225: 
062105,000226:                                                                                                  #  SUBROUTINES TO TURN OFF AND TURN ON TRACKER FAIL LIGHT.
062106,000227: 
062107,000228:    5645           00004        TRFAILOF           INHINT                                         
062108,000229:    5646           47704                           CS       OCT40200                              #  TURN OFF TRACKER LIGHT
062109,000230:    5647           71036                           MASK     DSPTAB     +11D                       
062110,000231:    5650           65015                           AD       BIT15                                 
062111,000232:    5651           55036                           TS       DSPTAB     +11D                       
062112,000233:    5652           41331                           CS       OPTMODES                              #  TO INSURE THAT OCDU FAIL WILL GO ON
062113,000234:    5653           75025                           MASK     BIT7                                  #  AGAIN IF IT WAS ON IN ADDITION TO
062114,000235:    5654           27331                           ADS      OPTMODES                              #  TRACKER FAIL.
062115,000236: 
062116,000237:    5655           00003        REQ                RELINT                                         
062117,000238:    5656           00002                           TC       Q                                     
062118,000239: 
062119,000240:    5657           00004        TRFAILON           INHINT                                         
062120,000241:    5660           41036                           CS       DSPTAB     +11D                       #  TURN ON
062121,000242:    5661           77704                           MASK     OCT40200                              
062122,000243:    5662           27036                           ADS      DSPTAB     +11D                       
062123,000244:    5663           15655                           TCF      REQ                                   
062124,000245: 
062125,000246: 
062126,000247: 
062127,000248: 

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