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.

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

Page 1453

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

Page 1454

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

Page 1455

063723,000134:    5464           00006                           EXTEND                                         
063724,000135:    5465           10061                           DV       ITEMP1                                #  A = FLAGWRD, L = (15 - BIT)
063725,000136:    5466           52062                           DXCH     ITEMP1                                
063726,000137:    5467           50061                           INDEX    ITEMP1                                
063727,000138:    5470           30074                           CA       FLAGWRD0                              
063728,000139:    5471           54001                           TS       L                                     #  CURRENT STATE
063729,000140:    5472           50062                           INDEX    ITEMP2                                
063730,000141:    5473           44674                           CS       BIT15                                 #  -(15 - BIT)
063731,000142:    5474           00002                           TC       Q                                     
063732,000143: 

Page 1456

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

Page 1457

063785,000196: 00,3764           05074                           TC       JOBWAKE                               
063786,000197: 
063787,000198: 00,3765           05213                           TC       TASKOVER                              
063788,000199: 
063789,000200: 00,3766           03753        TCSLEEP            GENADR   TCGETCAD   -2                         
063790,000201: 00,3767           03761        WAKECAD            GENADR   WAKER                                 
063791,000202: 

Page 1458

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

Page 1459

063836,000247:                                                                                                  #  B5OFF         ZERO BIT 5 OF EXTVBACT, WHICH IS SET BY TESTXACT.
063837,000248:                                                                                                  #  MAY BE USED AS NEEDED BY ANY EXTENDED VERB WHICH HAS DONE TESTXACT
063838,000249: 
063839,000250:    5514                                           COUNT*   $$/EXTVB                              
063840,000251: 
063841,000252:    5514           44706        B5OFF              CS       BIT5                                  
063842,000253:    5515           71044                           MASK     EXTVBACT                              
063843,000254:    5516           55044                           TS       EXTVBACT                              
063844,000255:    5517           05112                           TC       ENDOFJOB                              
063845,000256: 

Page 1460

063847,000258:                                                                                                  #  SUBROUTINES TO TURNOFF AND TURN ON TRACKER FAIL LIGHT.
063848,000259: 
063849,000260:    5520           00004        TRFAILOF           INHINT                                         
063850,000261:    5521           47704                           CS       OCT40200                              #  TURN OFF TRACKER LIGHT
063851,000262:    5522           71036                           MASK     DSPTAB     +11D                       
063852,000263:    5523           64674                           AD       BIT15                                 
063853,000264:    5524           55036                           TS       DSPTAB     +11D                       
063854,000265:    5525           41331                           CS       OPTMODES                              #  TO INSURE THAT OCDU FAIL WILL GO ON
063855,000266:    5526           74704                           MASK     BIT7                                  #  AGAIN IF IT WAS ON IN ADDITION TO
063856,000267:    5527           27331                           ADS      OPTMODES                              #  TRACKER FAIL.
063857,000268: 
063858,000269:    5530           00003        REQ                RELINT                                         
063859,000270:    5531           00002                           TC       Q                                     
063860,000271: 
063861,000272:    5532           00004        TRFAILON           INHINT                                         
063862,000273:    5533           41036                           CS       DSPTAB     +11D                       #  TURN ON
063863,000274:    5534           77704                           MASK     OCT40200                              
063864,000275:    5535           27036                           ADS      DSPTAB     +11D                       
063865,000276:    5536           15530                           TCF      REQ                                   
063866,000277: 
063867,000278: 
063868,000279: 
063869,000280: 

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