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.

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

Page 1476

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

Page 1477

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

Page 1478

064789,000147: 22,3602           00002                           TC       Q                                     
064790,000148: 
064791,000149: 22,3603           50000                           INDEX    A                                     #  OVERFLOW UNCORRECT AND IN MSU.
064792,000150: 22,3604           34673                           CAF      LIMITS                                
064793,000151: 22,3605           26154                           ADS      MPAC                                  
064794,000152: 22,3606           00002                           TC       Q                                     
064795,000153: 

Page 1479

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

Page 1480

064845,000203:                                                                                                  #  RTB TO TORQUE GYROS, EXCEPT FOR THE CALL TO IMUSTALL.  ECADR OF COMMANDS ARRIVES IN X1.
064846,000204: 
064847,000205: 22,3650           50120        PULSEIMU           INDEX    FIXLOC                                #  ADDRESS OF GYRO COMMANDS SHOULD BE IN X1
064848,000206: 22,3651           30046                           CA       X1                                    
064849,000207: 22,3652           04555                           TC       BANKCALL                              
064850,000208: 22,3653           17125                           CADR     IMUPULSE                              
064851,000209: 22,3654           16030                           TCF      DANZIG                                
064852,000210: 

Page 1481

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

Page 1482

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

Page 1483

064943,000301: 22,3744           30155                           CA       MPAC       +1                         #  SHIFT ALL COMPONENTS LEFT 13
064944,000302: 22,3745           00006                           EXTEND                                         
064945,000303: 22,3746           74675                           MP       BIT14                                 
064946,000304: 22,3747           20155                           DAS      MPAC                                  #  DAS GAINS A LITTLE ACCURACY
064947,000305: 22,3750           30160                           CA       MPAC       +4                         
064948,000306: 22,3751           00006                           EXTEND                                         
064949,000307: 22,3752           74675                           MP       BIT14                                 
064950,000308: 22,3753           20160                           DAS      MPAC       +3                         
064951,000309: 22,3754           30162                           CA       MPAC       +6                         
064952,000310: 22,3755           00006                           EXTEND                                         
064953,000311: 22,3756           74675                           MP       BIT14                                 
064954,000312: 22,3757           20162                           DAS      MPAC       +5                         
064955,000313: 22,3760           34720                           CAF      THIRTEEN                              
064956,000314: 22,3761           50156                           INDEX    MPAC       +2                         
064957,000315: 22,3762           54045                           TS       37D                                   
064958,000316: 22,3763           04574        OFFTUNIT           TC       POSTJUMP                              
064959,000317: 22,3764           01024                           CADR     UNIT       +1                         #  SKIP THE "TC VECAGREE" DONE AT UNIT
064960,000318: 
064961,000319: 22,3765           34714        NOSHIFT            CAF      ZERO                                  
064962,000320: 22,3766           13761                           TCF      OFFTUNIT   -2                         
064963,000321: 
064964,000322:                                                                                                  #  RTB VECSGNAG ... FORCES SIGN AGREEMENT OF VECTOR IN MPAC.
064965,000323: 
064966,000324: 22,3767           04555        VECSGNAG           TC       BANKCALL                              
064967,000325: 22,3770           01010                           CADR     VECAGREE                              
064968,000326: 22,3771           06030                           TC       DANZIG                                
064969,000327: 
064970,000328: 

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