Source Code

This is the source-code for the Apollo 9 Command Module's Guidance Computer. These files were derived originally from the scan from MIT's Dibner Institute's now-discontinued website titled "History of Recent Science and Technology", which in turn was originally created by Gary Neff, though his high-quality scans were unfortunately reduced in legibility when presented online. The markings on the front of the printout imply that it was the original AGC developer Norm Brodeur's copy. A scan by Ron Burkey has superceded it, made from a more-legible copy from the collection of original AGC developer Fred Martin. The source code was transcribed from those images by Ron Burkey. Note that the page images presented online are of reduced quality, and that higher-quality images are available. Report any conversion errors or legibility problems in page images to info@sandroid.org. Notations on the program listing read, in part:

	ASSEMBLE REVISION 249 OF AGC PROGRAM COLOSSUS BY NASA 2021111-041
	20'35 OCT. 28,1968
Note that the date is the date of the printout, not the date of the program revision.

063573,000002:                                                                                                  ## Copyright:   Public domain.
063574,000003:                                                                                                  ## Filename:    SERVICE_ROUTINES.agc
063575,000004:                                                                                                  ## Purpose:     Part of the source code for Colossus, build 249.
063576,000005:                                                                                                  ##              It is part of the source code for the Command Module's (CM)
063577,000006:                                                                                                  ##              Apollo Guidance Computer (AGC), for Apollo 9.
063578,000007:                                                                                                  ## Assembler:   yaYUL
063579,000008:                                                                                                  ## Reference:   Starts on p. 1453
063580,000009:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
063581,000010:                                                                                                  ## Website:     www.ibiblio.org/apollo.
063582,000011:                                                                                                  ## Mod history: 08/30/04 RSB.   Adapted from corresponding Luminary131 file.
063583,000012:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
063584,000013:                                                                                                  ##                              original harcopy, as opposed to the PDF page
063585,000014:                                                                                                  ##                              numbers in 1701.pdf.
063586,000015:                                                                                                  ##              2017-01-18 RSB  Cross-diff'd comment text (not whitespace)
063587,000016:                                                                                                  ##                              vs the already-proofed corresponding Colossus
063588,000017:                                                                                                  ##                              237 and Comanche 55 source-code files
063589,000018:                                                                                                  ##                              and corrected errors found.
063590,000019:                                                                                                  ##
063591,000020:                                                                                                  ## The contents of the "Colossus249" files, in general, are transcribed 
063592,000021:                                                                                                  ## from a scanned copy of the program listing.  Notations on this
063593,000022:                                                                                                  ## document read, in part:
063594,000023:                                                                                                  ##
063595,000024:                                                                                                  ##      Assemble revision 249 of AGC program Colossus by NASA
063596,000025:                                                                                                  ##      2021111-041.  October 28, 1968.  
063597,000026:                                                                                                  ##
063598,000027:                                                                                                  ##      This AGC program shall also be referred to as
063599,000028:                                                                                                  ##                              Colossus 1A
063600,000029:                                                                                                  ##
063601,000030:                                                                                                  ##      Prepared by
063602,000031:                                                                                                  ##                      Massachusetts Institute of Technology
063603,000032:                                                                                                  ##                      75 Cambridge Parkway
063604,000033:                                                                                                  ##                      Cambridge, Massachusetts
063605,000034:                                                                                                  ##      under NASA contract NAS 9-4065.
063606,000035:                                                                                                  ##
063607,000036:                                                                                                  ## Refer directly to the online document mentioned above for further information.
063608,000037:                                                                                                  ## Please report any errors (relative to the scanned pages) to info@sandroid.org.
063609,000038:                                                                                                  ##
063610,000039:                                                                                                  ## In some cases, where the source code for Luminary 131 overlaps that of 
063611,000040:                                                                                                  ## Colossus 249, this code is instead copied from the corresponding Luminary 131
063612,000041:                                                                                                  ## source file, and then is proofed to incorporate any changes.
063613,000042: 

Page 1453

063615,000044:    7717                                           BLOCK    3                                     
063616,000045:    6000                                           SETLOC   FFTAG6                                
063617,000046:    6000                                           BANK                                           
063618,000047:    7717                                           COUNT    03/FLAG                               
063619,000048: 
063620,000049:    7717           54001        UPENT2             TS       L                                     #  WHICH FLAGWORD IS IT
063621,000050:    7720           74716                           MASK     OCT7                                  
063622,000051:    7721           56001                           XCH      L                                     #  SAVE IN L FOR INDEXING
063623,000052: 
063624,000053:    7722           75630                           MASK     OCT77770                              #  OBTAIN THE BIT INFORMATION
063625,000054:    7723           00004                           INHINT                                         #  PREVENT INTERUPTS
063626,000055:    7724           54061                           TS       ITEMP1                                #  STORE THE BIT INFORMATION TEMPORARIALY
063627,000056: 
063628,000057:    7725           50001                           NDX      L                                     
063629,000058:    7726           40074                           CS       FLAGWRD0                              
063630,000059:    7727           70061                           MASK     ITEMP1                                
063631,000060:    7730           50001                           NDX      L                                     
063632,000061:    7731           26074                           ADS      FLAGWRD0                              
063633,000062:    7732           00003                           RELINT                                         #  RELEASE INTERUPT INHIBIT
063634,000063: 
063635,000064:    7733           24002                           INCR     Q                                     #  OBTAIN THE CORRECT RETURN ADDRESS
063636,000065:    7734           00002                           TC       Q                                     #  RETURN
063637,000066: 
063638,000067:    7735           54001        DOWNENT2           TS       L                                     #  WHICH FLAGWORD IS IT
063639,000068:    7736           74716                           MASK     OCT7                                  
063640,000069:    7737           56001                           XCH      L                                     #  SAVE IN L FOR INDEXING
063641,000070: 
063642,000071:    7740           75630                           MASK     OCT77770                              #  OBTAIN THE BIT INFORMATION
063643,000072:    7741           40000                           COM                                            #  START TO PROCESS THE INFORMATION
063644,000073: 
063645,000074:    7742           00004                           INHINT                                         #  PREVENT INTERUPTS
063646,000075:    7743           50001                           NDX      L                                     
063647,000076:    7744           70074                           MASK     FLAGWRD0                              
063648,000077:    7745           50001                           NDX      L                                     
063649,000078:    7746           54074                           TS       FLAGWRD0                              
063650,000079:    7747           00003                           RELINT                                         #  RELEASE INTERUPT INHIBIT
063651,000080: 
063652,000081:    7750           24002                           INCR     Q                                     #  OBTAIN THE CORRECT RETURN ADDRESS
063653,000082:    7751           00002                           TC       Q                                     #  RETURN
063654,000083: 
063655,000084:    7752     4716               OCT7               EQUALS   SEVEN                                 
063656,000085: 10,3671                                           BANK     10                                    
063657,000086: 

Page 1454

063659,000088:                                                                                                  #  UPFLAG AND DOWNFLAG ARE ENTIRELY GENERAL FLAG SETTING AND CLEARING SUBROUTINES.  USING THEM, WHETHER OR
063660,000089:                                                                                                  #  NOT IN INTERRUPT, ONE MAY SET OR CLEAR ANY SINGLE, NAMED BIT IN ANY ERASABLE REGISTER, SUBJECT OF COURSE TO
063661,000090:                                                                                                  #  EBANK SETTING.  A "NAMED" BIT, AS THE WORD IS USED HERE, IS ANY BIT WITH A NAME FORMALLY ASSIGNED BY THE YUL
063662,000091:                                                                                                  #  ASSEMBLER.
063663,000092: 
063664,000093:                                                                                                  #  AT PRESENT THE ONLY NAMED BITS ARE THOSE IN THE FLAGWORDS.  ASSEMBLER CHANGES WILL MAKE IT POSSIBLE TO
063665,000094:                                                                                                  #  NAME ANY BIT IN ERASABLE MEMORY.
063666,000095: 
063667,000096:                                                                                                  #  CALLING SEQUENCES ARE AS FOLLOWS:-
063668,000097:                                                                                                  #                TC      UPFLAG                  TC      DOWNFLAG
063669,000098:                                                                                                  #                ADRES   NAME OF FLAG            ADRES   NAME OF FLAG
063670,000099: 
063671,000100:                                                                                                  #  RETURN IS TO THE LOCATION FOLLOWING THE "ADRES" ABOUT .58 MS AFTER THE "TC".
063672,000101:                                                                                                  #  UPON RETURN A CONTAINS THE CURRENT FLAGWRD SETTING.
063673,000102: 
063674,000103:    5435                                           BLOCK    02                                    
063675,000104:    4000                                           SETLOC   FFTAG1                                
063676,000105:    4000                                           BANK                                           
063677,000106:    5435                                           COUNT*   $$/FLAG                               
063678,000107: 
063679,000108:    5435           30002        UPFLAG             CA       Q                                     
063680,000109:    5436           05453                           TC       DEBIT                                 
063681,000110:    5437           40000                           COM                                            #  +(15 - BIT)
063682,000111:    5440           00006                           EXTEND                                         
063683,000112:    5441           04001                           ROR      LCHAN                                 #  SET BIT
063684,000113:    5442           50061        COMFLAG            INDEX    ITEMP1                                
063685,000114:    5443           54074                           TS       FLAGWRD0                              
063686,000115:    5444           22063                           LXCH     ITEMP3                                
063687,000116:    5445           00003                           RELINT                                         
063688,000117:    5446           00001                           TC       L                                     
063689,000118: 
063690,000119:    5447           30002        DOWNFLAG           CA       Q                                     
063691,000120:    5450           05453                           TC       DEBIT                                 
063692,000121:    5451           70001                           MASK     L                                     #  RESET BIT
063693,000122:    5452           15442                           TCF      COMFLAG                               
063694,000123: 
063695,000124:    5453           64712        DEBIT              AD       ONE                                   #  GET DE BITS
063696,000125:    5454           00004                           INHINT                                         
063697,000126:    5455           54063                           TS       ITEMP3                                
063698,000127:    5456           34721                           CA       LOW4                                  #  DEC15
063699,000128:    5457           54061                           TS       ITEMP1                                
063700,000129:    5460           50063                           INDEX    ITEMP3                                
063701,000130:    5461           27777                           CA       0          -1                         #  ADRES
063702,000131:    5462           54001                           TS       L                                     
063703,000132:    5463           34714                           CA       ZERO                                  

Page 1455

063705,000134:    5464           00006                           EXTEND                                         
063706,000135:    5465           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
063707,000136:    5466           52062                           DXCH     ITEMP1                                
063708,000137:    5467           50061                           INDEX    ITEMP1                                
063709,000138:    5470           30074                           CA       FLAGWRD0                              
063710,000139:    5471           54001                           TS       L                                     #  CURRENT STATE
063711,000140:    5472           50062                           INDEX    ITEMP2                                
063712,000141:    5473           44674                           CS       BIT15                                 #  -(15 - BIT)
063713,000142:    5474           00002                           TC       Q                                     
063714,000143: 

Page 1456

063716,000145:                                                                                                  #  DELAYJOB- A GENERAL ROUTINE TO DELAY A JOB A SPECIFIC AMOUNT OF TIME BEFORE PICKING UP AGAIN.
063717,000146: 
063718,000147:                                                                                                  #  ENTRANCE REQUIREMENTS ...
063719,000148:                                                                                                  #                CAF     DT              DELAY JOB FOR DT CENTISECS
063720,000149:                                                                                                  #                TC      BANKCALL
063721,000150:                                                                                                  #                CADR    DELAYJOB
063722,000151: 
063723,000152: 06,3651                                           BANK     06                                    
063724,000153: 00,2000                                           SETLOC   DLAYJOB                               
063725,000154: 00,2000                                           BANK                                           
063726,000155: 
063727,000156:                                                                                                  #  THIS MUST REMAIN IN BANK 0 *****************************************
063728,000157: 
063729,000158: 00,3732                                           COUNT    00/DELAY                              
063730,000159: 
063731,000160: 00,3732           00004        DELAYJOB           INHINT                                         
063732,000161: 00,3733           54002                           TS       Q                                     #  STORE DELAY DT IN Q FOR DLY -1 IN
063733,000162: 00,3734           36214                           CAF      DELAYNUM                              #  WAITLIST
063734,000163: 00,3735           54070        DELLOOP            TS       RUPTREG1                              
063735,000164: 00,3736           50000                           INDEX    A                                     
063736,000165: 00,3737           31141                           CA       DELAYLOC                              #  IS THIS DELAYLOC AVAILABLE
063737,000166: 00,3740           00006                           EXTEND                                         
063738,000167: 00,3741           13746                           BZF      OK2DELAY                              #  YES
063739,000168: 
063740,000169: 00,3742           10070                           CCS      RUPTREG1                              #  NO, TRY NEXT DELAYLOC
063741,000170: 00,3743           13735                           TCF      DELLOOP                               
063742,000171: 
063743,000172: 00,3744           05604                           TC       BAILOUT                               #  NO AVAILABLE LOCS AVAILABLE.
063744,000173: 00,3745           01104                           OCT      1104                                  
063745,000174: 
063746,000175: 00,3746           33766        OK2DELAY           CA       TCSLEEP                               #  SET WAITLIST IMMEDIATE RETURN
063747,000176: 00,3747           54061                           TS       WAITEXIT                              
063748,000177: 
063749,000178: 00,3750           30004                           CA       FBANK                                 
063750,000179: 00,3751           60070                           AD       RUPTREG1                              #  STORE BBANK FOR TASK CALL
063751,000180: 00,3752           54001                           TS       L                                     
063752,000181: 
063753,000182: 00,3753           33767                           CAF      WAKECAD                               #  STORE CADR FOR TASK CALL
063754,000183: 00,3754           15146                           TCF      DLY2       -1                         #  DLY IS IN WAITLIST ROUTINE
063755,000184: 
063756,000185: 00,3755           04604        TCGETCAD           TC       MAKECADR                              #  GET CALLERS FCADR
063757,000186: 
063758,000187: 00,3756           50070                           INDEX    RUPTREG1                              
063759,000188: 00,3757           55141                           TS       DELAYLOC                              #  SAVE DELAY CADRS
063760,000189: 
063761,000190: 00,3760           05070                           TC       JOBSLEEP                              
063762,000191: 
063763,000192: 00,3761           34714        WAKER              CAF      ZERO                                  
063764,000193: 00,3762           50006                           INDEX    BBANK                                 
063765,000194: 00,3763           57141                           XCH      DELAYLOC                              #  MAKE DELAYLOC AVAILABLE

Page 1457

063767,000196: 00,3764           05074                           TC       JOBWAKE                               
063768,000197: 
063769,000198: 00,3765           05213                           TC       TASKOVER                              
063770,000199: 
063771,000200: 00,3766           03753        TCSLEEP            GENADR   TCGETCAD   -2                         
063772,000201: 00,3767           03761        WAKECAD            GENADR   WAKER                                 
063773,000202: 

Page 1458

063775,000204:                                                                                                  #  GENTRAN, A BLOCK TRANSFER ROUTINE.
063776,000205:                                                                                                  #  WRITTEN BY D. EYLES
063777,000206:                                                                                                  #  MOD 1 BY KERNAN                               UTILITYM REV 17 11/18/67
063778,000207:                                                                                                  #  MOD 2 BY SCHULENBERG    (REMOVE RELINT)    SKIPPER REV 4 2/28/68
063779,000208: 
063780,000209:                                                                                                  #  THIS ROUTINE IS USEFULL FOR TRANSFERING N CONSECUTIVE ERASABLE OR FIXED QUANTITIES TO SOME OTHER N
063781,000210:                                                                                                  #  CONSECUTIVE ERASABLE LOCATIONS.  IF BOTH BLOCKS OF DATA ARE IN SWITCHABLE EBANKS, THEY MUST BE IN THE SAME ONE.
063782,000211: 
063783,000212:                                                                                                  #  GENTRAN IS CALLABLE IN A JOB AS WELL AS A RUPT.  THE CALLING SEQUENCE IS:
063784,000213:                                                                                                  #        I       CA      N-1             # OF QUANTITIES MINUS ONE.
063785,000214:                                                                                                  #        I +1    TC      GENTRAN         IN FIXED-FIXED.
063786,000215:                                                                                                  #        I +2    ADRES   L               STARTING ADRES OF DATA TO BE MOVED.
063787,000216:                                                                                                  #        I +3    ADRES   M               STARTING ADRES OF DUPLICATION BLOCK.
063788,000217:                                                                                                  #        I +4                            RETURNS HERE.
063789,000218: 
063790,000219:                                                                                                  #  GENTRAN TAKES 25 MCT'S (300 MICROSECONDS) PER ITEM + 5 MCT'S (60 MICS) FOR ENTERING AND EXITING.
063791,000220:                                                                                                  #  A, L AND ITEMP1 ARE NOT PRESERVED.
063792,000221: 
063793,000222:    5475                                           BLOCK    02                                    
063794,000223:    4000                                           SETLOC   FFTAG4                                
063795,000224:    4000                                           BANK                                           
063796,000225: 
063797,000226:    5475     0061                                  EBANK=   ITEMP1                                
063798,000227: 
063799,000228:    5475                                           COUNT*   $$/TRAN                               
063800,000229: 
063801,000230:    5475           00004        GENTRAN            INHINT                                         
063802,000231:    5476           54061                           TS       ITEMP1                                #  SAVE N-1.
063803,000232:    5477           50002                           INDEX    Q                                     #  C(Q) = ADRES L.
063804,000233:    5500           60000                           AD       0                                     #  ADRES (L + N - 1).
063805,000234:    5501           50000                           INDEX    A                                     
063806,000235:    5502           30000                           CA       0                                     #  C(ABOVE).
063807,000236:    5503           54001                           TS       L                                     #  SAVE DATA.
063808,000237:    5504           30061                           CA       ITEMP1                                
063809,000238:    5505           50002                           INDEX    Q                                     
063810,000239:    5506           60001                           AD       1                                     #  ADRES (M + N - 1).
063811,000240:    5507           50000                           INDEX    A                                     
063812,000241:    5510           22000                           LXCH     0                                     #  STUFF IT.
063813,000242:    5511           10061                           CCS      ITEMP1                                #  LOOP UNTIL N-1 = 0.
063814,000243:    5512           15476                           TCF      GENTRAN    +1                         
063815,000244:    5513           16710                           TCF      Q+2                                   #  RETURN TO CALLER.
063816,000245: 

Page 1459

063818,000247:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
063819,000248:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
063820,000249: 
063821,000250:    5514                                           COUNT*   $$/EXTVB                              
063822,000251: 
063823,000252:    5514           44706        B5OFF              CS       BIT5                                  
063824,000253:    5515           71044                           MASK     EXTVBACT                              
063825,000254:    5516           55044                           TS       EXTVBACT                              
063826,000255:    5517           05112                           TC       ENDOFJOB                              
063827,000256: 

Page 1460

063829,000258:                                                                                                  #  SUBROUTINES TO TURNOFF AND TURN ON TRACKER FAIL LIGHT.
063830,000259: 
063831,000260:    5520           00004        TRFAILOF           INHINT                                         
063832,000261:    5521           47704                           CS       OCT40200                              #  TURN OFF TRACKER LIGHT
063833,000262:    5522           71036                           MASK     DSPTAB     +11D                       
063834,000263:    5523           64674                           AD       BIT15                                 
063835,000264:    5524           55036                           TS       DSPTAB     +11D                       
063836,000265:    5525           41331                           CS       OPTMODES                              #  TO INSURE THAT OCDU FAIL WILL GO ON
063837,000266:    5526           74704                           MASK     BIT7                                  #  AGAIN IF IT WAS ON IN ADDITION TO
063838,000267:    5527           27331                           ADS      OPTMODES                              #  TRACKER FAIL.
063839,000268: 
063840,000269:    5530           00003        REQ                RELINT                                         
063841,000270:    5531           00002                           TC       Q                                     
063842,000271: 
063843,000272:    5532           00004        TRFAILON           INHINT                                         
063844,000273:    5533           41036                           CS       DSPTAB     +11D                       #  TURN ON
063845,000274:    5534           77704                           MASK     OCT40200                              
063846,000275:    5535           27036                           ADS      DSPTAB     +11D                       
063847,000276:    5536           15530                           TCF      REQ                                   
063848,000277: 
063849,000278: 
063850,000279: 
063851,000280: 

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