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.

064626,000002:                                                                                                  ## Copyright:   Public domain.
064627,000003:                                                                                                  ## Filename:    RTB_OP_CODES.agc
064628,000004:                                                                                                  ## Purpose:     Part of the source code for Colossus, build 249.
064629,000005:                                                                                                  ##              It is part of the source code for the Command Module's (CM)
064630,000006:                                                                                                  ##              Apollo Guidance Computer (AGC), for Apollo 9.
064631,000007:                                                                                                  ## Assembler:   yaYUL
064632,000008:                                                                                                  ## Reference:   Starts on p. 1476
064633,000009:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
064634,000010:                                                                                                  ## Website:     www.ibiblio.org/apollo.
064635,000011:                                                                                                  ## Mod history: 08/30/04 RSB.   Adapted from corresponding Luminary131 file.
064636,000012:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
064637,000013:                                                                                                  ##                              original harcopy, as opposed to the PDF page
064638,000014:                                                                                                  ##                              numbers in 1701.pdf.
064639,000015:                                                                                                  ##              2017-01-18 RSB  Cross-diff'd comment text (not whitespace)
064640,000016:                                                                                                  ##                              vs the already-proofed corresponding Colossus
064641,000017:                                                                                                  ##                              237 and Comanche 55 source-code files
064642,000018:                                                                                                  ##                              and corrected errors found.
064643,000019:                                                                                                  ##
064644,000020:                                                                                                  ## The contents of the "Colossus249" files, in general, are transcribed 
064645,000021:                                                                                                  ## from a scanned copy of the program listing.  Notations on this
064646,000022:                                                                                                  ## document read, in part:
064647,000023:                                                                                                  ##
064648,000024:                                                                                                  ##      Assemble revision 249 of AGC program Colossus by NASA
064649,000025:                                                                                                  ##      2021111-041.  October 28, 1968.  
064650,000026:                                                                                                  ##
064651,000027:                                                                                                  ##      This AGC program shall also be referred to as
064652,000028:                                                                                                  ##                              Colossus 1A
064653,000029:                                                                                                  ##
064654,000030:                                                                                                  ##      Prepared by
064655,000031:                                                                                                  ##                      Massachusetts Institute of Technology
064656,000032:                                                                                                  ##                      75 Cambridge Parkway
064657,000033:                                                                                                  ##                      Cambridge, Massachusetts
064658,000034:                                                                                                  ##      under NASA contract NAS 9-4065.
064659,000035:                                                                                                  ##
064660,000036:                                                                                                  ## Refer directly to the online document mentioned above for further information.
064661,000037:                                                                                                  ## Please report any errors (relative to the scanned pages) to info@sandroid.org.
064662,000038:                                                                                                  ##
064663,000039:                                                                                                  ## In some cases, where the source code for Luminary 131 overlaps that of 
064664,000040:                                                                                                  ## Colossus 249, this code is instead copied from the corresponding Luminary 131
064665,000041:                                                                                                  ## source file, and then is proofed to incorporate any changes.
064666,000042: 

Page 1476

064668,000044: 22,3505                                           BANK     22                                    
064669,000045: 22,2000                                           SETLOC   RTBCODES                              
064670,000046: 22,2000                                           BANK                                           
064671,000047: 
064672,000048: 22,3505  E5,1713                                  EBANK=   XNB                                   
064673,000049: 22,3505                                           COUNT*   $$/RTB                                
064674,000050: 
064675,000051:                                                                                                  #  LOAD TIME2, TIME1 INTO MPAC:
064676,000052: 
064677,000053: 22,3505           00006        LOADTIME           EXTEND                                         
064678,000054: 22,3506           30025                           DCA      TIME2                                 
064679,000055: 22,3507           16024                           TCF      SLOAD2                                
064680,000056: 
064681,000057:                                                                                                  #  CONVERT THE SINGLE PRECISION 2'S COMPLEMENT NUMBER ARRIVING IN MPAC (SCALED IN HALF-REVOLUTIONS) TO A
064682,000058:                                                                                                  #  DP 1'S COMPLEMENT NUMBER SCALED IN REVOLUTIONS.
064683,000059: 
064684,000060: 22,3510           10154        CDULOGIC           CCS      MPAC                                  
064685,000061: 22,3511           34714                           CAF      ZERO                                  
064686,000062: 22,3512           13515                           TCF      +3                                    
064687,000063: 22,3513           13514                           NOOP                                           
064688,000064: 22,3514           44675                           CS       HALF                                  
064689,000065: 
064690,000066: 22,3515           54155                           TS       MPAC       +1                         
064691,000067: 22,3516           34714                           CAF      ZERO                                  
064692,000068: 22,3517           56154                           XCH      MPAC                                  
064693,000069: 22,3520           00006                           EXTEND                                         
064694,000070: 22,3521           74675                           MP       HALF                                  
064695,000071: 22,3522           20155                           DAS      MPAC                                  
064696,000072: 22,3523           16030                           TCF      DANZIG                                #  MODE IS ALREADY AT DOUBLE-PRECISION
064697,000073: 
064698,000074:                                                                                                  #  READ THE PIPS INTO MPAC WITHOUT CHANGING THEM:
064699,000075: 
064700,000076: 22,3524           00004        READPIPS           INHINT                                         
064701,000077: 22,3525           30037                           CA       PIPAX                                 
064702,000078: 22,3526           54154                           TS       MPAC                                  
064703,000079: 22,3527           30040                           CA       PIPAY                                 
064704,000080: 22,3530           54157                           TS       MPAC       +3                         
064705,000081: 22,3531           30041                           CA       PIPAZ                                 
064706,000082: 22,3532           00003                           RELINT                                         
064707,000083: 22,3533           54161                           TS       MPAC       +5                         
064708,000084: 
064709,000085: 22,3534           34714                           CAF      ZERO                                  
064710,000086: 22,3535           54155                           TS       MPAC       +1                         
064711,000087: 22,3536           54160                           TS       MPAC       +4                         
064712,000088: 22,3537           54162                           TS       MPAC       +6                         
064713,000089: 
064714,000090: 22,3540           16470        VECMODE            TCF      VMODE                                 
064715,000091: 
064716,000092:                                                                                                  #  FORCE TP SIGN AGREEMENT IN MPAC:
064717,000093: 
064718,000094: 22,3541           07226        SGNAGREE           TC       TPAGREE                               

Page 1477

064720,000096: 22,3542           16030                           TCF      DANZIG                                
064721,000097: 
064722,000098:                                                                                                  #  CONVERT THE DP 1'S COMPLEMENT ANGLE SCALED IN REVOLUTIONS TO A SINGLE PRECISION 2'S COMPLEMENT ANGLE
064723,000099:                                                                                                  #  SCALED IN HALF-REVOLUTIONS.
064724,000100: 
064725,000101: 22,3543           03573        1STO2S             TC       1TO2SUB                               
064726,000102: 22,3544           34714                           CAF      ZERO                                  
064727,000103: 22,3545           54155                           TS       MPAC       +1                         
064728,000104: 22,3546           16027                           TCF      NEWMODE                               
064729,000105: 
064730,000106:                                                                                                  #  DO 1STO2S ON A VECTOR OF ANGLES:
064731,000107: 
064732,000108: 22,3547           03573        V1STO2S            TC       1TO2SUB                               #  ANSWER ARRIVES IN A AND MPAC.
064733,000109: 
064734,000110: 22,3550           52162                           DXCH     MPAC       +5                         
064735,000111: 22,3551           52155                           DXCH     MPAC                                  
064736,000112: 22,3552           03573                           TC       1TO2SUB                               
064737,000113: 22,3553           54156                           TS       MPAC       +2                         
064738,000114: 
064739,000115: 22,3554           52160                           DXCH     MPAC       +3                         
064740,000116: 22,3555           52155                           DXCH     MPAC                                  
064741,000117: 22,3556           03573                           TC       1TO2SUB                               
064742,000118: 22,3557           54155                           TS       MPAC       +1                         
064743,000119: 
064744,000120: 22,3560           30161                           CA       MPAC       +5                         
064745,000121: 22,3561           54154                           TS       MPAC                                  
064746,000122: 
064747,000123: 22,3562           34712        TPMODE             CAF      ONE                                   #  MODE IS TP.
064748,000124: 22,3563           16027                           TCF      NEWMODE                               
064749,000125: 
064750,000126:                                                                                                  #  V1STO2S FOR 2 COMPONENT VECTOR. USED BY RR.
064751,000127: 
064752,000128: 22,3564           03573        2V1STO2S           TC       1TO2SUB                               
064753,000129: 22,3565           52160                           DXCH     MPAC       +3                         
064754,000130: 22,3566           52155                           DXCH     MPAC                                  
064755,000131: 22,3567           03573                           TC       1TO2SUB                               
064756,000132: 22,3570           54001                           TS       L                                     
064757,000133: 22,3571           30157                           CA       MPAC       +3                         
064758,000134: 22,3572           16024                           TCF      SLOAD2                                
064759,000135: 
064760,000136:                                                                                                  #  SUBROUTINE TO DO DOUBLING AND 1'S TO 2'S CONVERSION:
064761,000137: 
064762,000138: 22,3573           52155        1TO2SUB            DXCH     MPAC                                  #  FINAL MPAC +1 UNSPECIFIED.
064763,000139: 22,3574           20001                           DDOUBL                                         
064764,000140: 22,3575           10000                           CCS      A                                     
064765,000141: 22,3576           64712                           AD       ONE                                   
064766,000142: 22,3577           13601                           TCF      +2                                    
064767,000143: 22,3600           40000                           COM                                            #  THIS WAS REVERSE OF MSU.
064768,000144: 
064769,000145: 22,3601           54154                           TS       MPAC                                  #  AND SKIP ON OVERFLOW.

Page 1478

064771,000147: 22,3602           00002                           TC       Q                                     
064772,000148: 
064773,000149: 22,3603           50000                           INDEX    A                                     #  OVERFLOW UNCORRECT AND IN MSU.
064774,000150: 22,3604           34673                           CAF      LIMITS                                
064775,000151: 22,3605           26154                           ADS      MPAC                                  
064776,000152: 22,3606           00002                           TC       Q                                     
064777,000153: 

Page 1479

064779,000155:                                                                                                  #  SUBROUTINE TO INCREMENT CDUS
064780,000156: 
064781,000157: 22,3607           33622        INCRCDUS           CAF      LOCTHETA                              
064782,000158: 22,3610           54130                           TS       BUF                                   #  PLACE ADRES(THETA) IN BUF.
064783,000159: 22,3611           30154                           CAE      MPAC                                  #  INCREMENT IN 1S COMPL.
064784,000160: 22,3612           03623                           TC       CDUINC                                
064785,000161: 
064786,000162: 22,3613           24130                           INCR     BUF                                   
064787,000163: 22,3614           30157                           CAE      MPAC       +3                         
064788,000164: 22,3615           03623                           TC       CDUINC                                
064789,000165: 
064790,000166: 22,3616           24130                           INCR     BUF                                   
064791,000167: 22,3617           30161                           CAE      MPAC       +5                         
064792,000168: 22,3620           03623                           TC       CDUINC                                
064793,000169: 
064794,000170: 22,3621           13540                           TCF      VECMODE                               
064795,000171: 
064796,000172: 22,3622           01155        LOCTHETA           ADRES    THETAD                                
064797,000173: 
064798,000174:                                                                                                  #  THE FOLLOWING ROUTINE INCREMENTS IN 2S COMPLEMENT THE REGISTER WHOSE ADDRESS IS IN BUF BY THE 1S COMPL.
064799,000175:                                                                                                  #  QUANTITY FOUND IN TEM2.  THIS MAY BE USED TO INCREMENT DESIRED IMU AND OPTICS CDU ANGLES OR ANY OTHER 2S COMPL.
064800,000176:                                                                                                  #  (+0 UNEQUAL TO -0) QUANTITY.  MAY BE CALLED BY BANKCALL/SWCALL.
064801,000177: 
064802,000178: 22,3623           54142        CDUINC             TS       TEM2                                  #  1S COMPL. QUANT. ARRIVES IN ACC.  STORE IT
064803,000179: 22,3624           50130                           INDEX    BUF                                   
064804,000180: 22,3625           10000                           CCS      0                                     #  CHANGE 2S COMPL. ANGLE(IN BUF) INTO 1S
064805,000181: 22,3626           64712                           AD       ONE                                   
064806,000182: 22,3627           13633                           TCF      +4                                    
064807,000183: 22,3630           64712                           AD       ONE                                   
064808,000184: 22,3631           64712                           AD       ONE                                   #  OVERFLOW HERE IF 2S COMPL. IS 180 DEG.
064809,000185: 22,3632           40000                           COM                                            
064810,000186: 
064811,000187: 22,3633           60142                           AD       TEM2                                  #  SULT MOVES FROM 2ND TO 3D QUAD. (OR BACK)
064812,000188: 22,3634           10000                           CCS      A                                     #  BACK TO 2S COMPL.
064813,000189: 22,3635           64712                           AD       ONE                                   
064814,000190: 22,3636           13640                           TCF      +2                                    
064815,000191: 22,3637           40000                           COM                                            
064816,000192: 22,3640           54142                           TS       TEM2                                  #  STORE 14BIT QUANTITY WITH PRESENT SIGN
064817,000193: 22,3641           13645                           TCF      +4                                    
064818,000194: 22,3642           50000                           INDEX    A                                     #  SIGN.
064819,000195: 22,3643           34673                           CAF      LIMITS                                #  FIX IT, BY ADDING IN 37777 OR 40000
064820,000196: 22,3644           60142                           AD       TEM2                                  
064821,000197: 
064822,000198: 22,3645           50130                           INDEX    BUF                                   
064823,000199: 22,3646           54000                           TS       0                                     #  STORE NEW ANGLE IN 2S COMPLEMENT.
064824,000200: 22,3647           00002                           TC       Q                                     
064825,000201: 

Page 1480

064827,000203:                                                                                                  #  RTB TO TORQUE GYROS, EXCEPT FOR THE CALL TO IMUSTALL.  ECADR OF COMMANDS ARRIVES IN X1.
064828,000204: 
064829,000205: 22,3650           50120        PULSEIMU           INDEX    FIXLOC                                #  ADDRESS OF GYRO COMMANDS SHOULD BE IN X1
064830,000206: 22,3651           30046                           CA       X1                                    
064831,000207: 22,3652           04555                           TC       BANKCALL                              
064832,000208: 22,3653           17125                           CADR     IMUPULSE                              
064833,000209: 22,3654           16030                           TCF      DANZIG                                
064834,000210: 

Page 1481

064836,000212:                                                                                                  #  EACH ROUTINE TAKES A 3X3 MATRIX STORED IN DOUBLE PRECISION IN A FIXED AREA OF ERASABLE MEMORY AND REPLACES IT
064837,000213:                                                                                                  #  WITH THE TRANSPOSE MATRIX.  TRANSP1 USES LOCATIONS XNB+0,+1 THROUGH XNB+16D, 17D AND TRANSP2 USES LOCATIONS
064838,000214:                                                                                                  #  XNB1+0,+1 THROUGH XNB1+16D, 17D.  EACH MATRIX IS STORED BY ROWS.
064839,000215: 
064840,000216: 22,3655           02713        XNBEB              ECADR    XNB                                   
064841,000217: 22,3656           02554        XNB1EB             ECADR    XNB1                                  
064842,000218: 
064843,000219: 22,3657  E5,1713                                  EBANK=   XNB                                   
064844,000220: 
064845,000221: 22,3657           33655        TRANSP1            CAF      XNBEB                                 
064846,000222: 22,3660           54003                           TS       EBANK                                 
064847,000223: 22,3661           53716                           DXCH     XNB        +2                         
064848,000224: 22,3662           53722                           DXCH     XNB        +6                         
064849,000225: 22,3663           53716                           DXCH     XNB        +2                         
064850,000226: 
064851,000227: 22,3664           53720                           DXCH     XNB        +4                         
064852,000228: 22,3665           53730                           DXCH     XNB        +12D                       
064853,000229: 22,3666           53720                           DXCH     XNB        +4                         
064854,000230: 
064855,000231: 22,3667           53726                           DXCH     XNB        +10D                       
064856,000232: 22,3670           53732                           DXCH     XNB        +14D                       
064857,000233: 22,3671           53726                           DXCH     XNB        +10D                       
064858,000234: 22,3672           16030                           TCF      DANZIG                                
064859,000235: 22,3673  E5,1554                                  EBANK=   XNB1                                  
064860,000236: 
064861,000237: 22,3673           33656        TRANSP2            CAF      XNB1EB                                
064862,000238: 22,3674           54003                           TS       EBANK                                 
064863,000239: 22,3675           53557                           DXCH     XNB1       +2                         
064864,000240: 22,3676           53563                           DXCH     XNB1       +6                         
064865,000241: 22,3677           53557                           DXCH     XNB1       +2                         
064866,000242: 
064867,000243: 22,3700           53561                           DXCH     XNB1       +4                         
064868,000244: 22,3701           53571                           DXCH     XNB1       +12D                       
064869,000245: 22,3702           53561                           DXCH     XNB1       +4                         
064870,000246: 
064871,000247: 22,3703           53567                           DXCH     XNB1       +10D                       
064872,000248: 22,3704           53573                           DXCH     XNB1       +14D                       
064873,000249: 22,3705           53567                           DXCH     XNB1       +10D                       
064874,000250: 22,3706           16030                           TCF      DANZIG                                
064875,000251: 

Page 1482

064877,000253:                                                                                                  #  THE SUBROUTINE SIGNMPAC SETS C(MPAC, MPAC +1) TO SIGN(MPAC).
064878,000254:                                                                                                  #  FOR THIS, ONLY THE CONTENTS OF MPAC ARE EXAMINED.  ALSO +0 YIELDS POSMAX AND -0 YIELDS NEGMAX.
064879,000255: 
064880,000256:                                                                                                  #  ENTRY MAY BE BY EITHER OF THE FOLLOWING:
064881,000257:                                                                                                  #        1.      LIMIT THE SIZE OF MPAC ON INTERPRETIVE OVERFLOW:
064882,000258:                                                                                                  #                ENTRY:          BOVB
064883,000259:                                                                                                  #                                        SIGNMPAC
064884,000260:                                                                                                  #        2.      GENERATE IN MPAC THE SIGNUM FUNCTION OF MPAC:
064885,000261:                                                                                                  #                ENTRY:          RTB
064886,000262:                                                                                                  #                                        SIGNMPAC
064887,000263:                                                                                                  #  IN EITHER CASE, RETURN IS TO THE NEXT INTERPRETIVE INSTRUCTION IN THE CALLING SEQUENCE.
064888,000264: 
064889,000265: 22,3707           00006        SIGNMPAC           EXTEND                                         
064890,000266: 22,3710           34672                           DCA      DPOSMAX                               
064891,000267: 22,3711           52155                           DXCH     MPAC                                  
064892,000268: 22,3712           10000                           CCS      A                                     
064893,000269: 22,3713           34714        DPMODE             CAF      ZERO                                  #  SETS MPAC +2 TO ZERO IN THE PROCESS
064894,000270: 22,3714           16026                           TCF      SLOAD2     +2                         
064895,000271: 22,3715           13716                           TCF      +1                                    
064896,000272: 22,3716           00006                           EXTEND                                         
064897,000273: 22,3717           44672                           DCS      DPOSMAX                               
064898,000274: 22,3720           16024                           TCF      SLOAD2                                
064899,000275: 
064900,000276:                                                                                                  #  RTB OP CODE NORMUNIT IS LIKE INTERPRETIVE INSTRUCTION UNIT, EXCEPT THAT IT CAN BE DEPENDED ON NOT TO BLOW
064901,000277:                                                                                                  #  UP WHEN THE VECTOR BEING UNITIZED IS VERY SMALL -- IT WILL BLOW UP WHEN ALL COMPONENTS ARE ZERO.  IF NORMUNIT
064902,000278:                                                                                                  #  IS USED AND THE UPPER ORDER HALVES OF ALL COMPONENTS ARE ZERO, THE MAGNITUDE RETURNED IN 36D WILL BE TOO LARGE
064903,000279:                                                                                                  #  BY A FACTOR OF 2(13) AND THE SQUARED MAGNITUDE RETURNED AT 34D WILL BE TOO BIG BY A FACTOR OF 2(26).
064904,000280: 
064905,000281: 22,3721           34712        NORMUNX1           CAF      ONE                                   
064906,000282: 22,3722           13724                           TCF      NORMUNIT   +1                         
064907,000283: 22,3723           34714        NORMUNIT           CAF      ZERO                                  
064908,000284: 22,3724           60120                           AD       FIXLOC                                
064909,000285: 22,3725           54156                           TS       MPAC       +2                         
064910,000286: 22,3726           04555                           TC       BANKCALL                              #  GET SIGN AGREEMENT IN ALL COMPONENTS
064911,000287: 22,3727           01010                           CADR     VECAGREE                              
064912,000288: 22,3730           10154                           CCS      MPAC                                  
064913,000289: 22,3731           13765                           TCF      NOSHIFT                               
064914,000290: 22,3732           13734                           TCF      +2                                    
064915,000291: 22,3733           13765                           TCF      NOSHIFT                               
064916,000292: 22,3734           10157                           CCS      MPAC       +3                         
064917,000293: 22,3735           13765                           TCF      NOSHIFT                               
064918,000294: 22,3736           13740                           TCF      +2                                    
064919,000295: 22,3737           13765                           TCF      NOSHIFT                               
064920,000296: 22,3740           10161                           CCS      MPAC       +5                         
064921,000297: 22,3741           13765                           TCF      NOSHIFT                               
064922,000298: 22,3742           13744                           TCF      +2                                    
064923,000299: 22,3743           13765                           TCF      NOSHIFT                               

Page 1483

064925,000301: 22,3744           30155                           CA       MPAC       +1                         #  SHIFT ALL COMPONENTS LEFT 13
064926,000302: 22,3745           00006                           EXTEND                                         
064927,000303: 22,3746           74675                           MP       BIT14                                 
064928,000304: 22,3747           20155                           DAS      MPAC                                  #  DAS GAINS A LITTLE ACCURACY
064929,000305: 22,3750           30160                           CA       MPAC       +4                         
064930,000306: 22,3751           00006                           EXTEND                                         
064931,000307: 22,3752           74675                           MP       BIT14                                 
064932,000308: 22,3753           20160                           DAS      MPAC       +3                         
064933,000309: 22,3754           30162                           CA       MPAC       +6                         
064934,000310: 22,3755           00006                           EXTEND                                         
064935,000311: 22,3756           74675                           MP       BIT14                                 
064936,000312: 22,3757           20162                           DAS      MPAC       +5                         
064937,000313: 22,3760           34720                           CAF      THIRTEEN                              
064938,000314: 22,3761           50156                           INDEX    MPAC       +2                         
064939,000315: 22,3762           54045                           TS       37D                                   
064940,000316: 22,3763           04574        OFFTUNIT           TC       POSTJUMP                              
064941,000317: 22,3764           01024                           CADR     UNIT       +1                         #  SKIP THE "TC VECAGREE" DONE AT UNIT
064942,000318: 
064943,000319: 22,3765           34714        NOSHIFT            CAF      ZERO                                  
064944,000320: 22,3766           13761                           TCF      OFFTUNIT   -2                         
064945,000321: 
064946,000322:                                                                                                  #  RTB VECSGNAG ... FORCES SIGN AGREEMENT OF VECTOR IN MPAC.
064947,000323: 
064948,000324: 22,3767           04555        VECSGNAG           TC       BANKCALL                              
064949,000325: 22,3770           01010                           CADR     VECAGREE                              
064950,000326: 22,3771           06030                           TC       DANZIG                                
064951,000327: 
064952,000328: 

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