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.

021615,000002:                                                                                                  ## Copyright:   Public domain.
021616,000003:                                                                                                  ## Filename:    R31.agc
021617,000004:                                                                                                  ## Purpose:     Part of the source code for Colossus, build 249.
021618,000005:                                                                                                  ##              It is part of the source code for the Command Module's (CM)
021619,000006:                                                                                                  ##              Apollo Guidance Computer (AGC), for Apollo 9.
021620,000007:                                                                                                  ## Assembler:   yaYUL
021621,000008:                                                                                                  ## Reference:   pp. 496-501.
021622,000009:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
021623,000010:                                                                                                  ## Website:     www.ibiblio.org/apollo.
021624,000011:                                                                                                  ## Mod history: 08/11/04 RSB.   Began adapting from corresponding Luminary131
021625,000012:                                                                                                  ##                              source file.
021626,000013:                                                                                                  ##              2010-10-24 JL   Fixed indentation of last line (interpretive operand).
021627,000014:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
021628,000015:                                                                                                  ##                              original harcopy, as opposed to the PDF page
021629,000016:                                                                                                  ##                              numbers in 1701.pdf.
021630,000017:                                                                                                  ##              2017-01-18 RSB  Cross-diff'd comment text (not whitespace)
021631,000018:                                                                                                  ##                              vs the already-proofed corresponding Colossus
021632,000019:                                                                                                  ##                              237 and Comanche 55 source-code files
021633,000020:                                                                                                  ##                              and corrected errors found.
021634,000021:                                                                                                  ##
021635,000022:                                                                                                  ## The contents of the "Colossus249" files, in general, are transcribed 
021636,000023:                                                                                                  ## from a scanned copy of the program listing.  Notations on this
021637,000024:                                                                                                  ## document read, in part:
021638,000025:                                                                                                  ##
021639,000026:                                                                                                  ##      Assemble revision 249 of AGC program Colossus by NASA
021640,000027:                                                                                                  ##      2021111-041.  October 28, 1968.  
021641,000028:                                                                                                  ##
021642,000029:                                                                                                  ##      This AGC program shall also be referred to as
021643,000030:                                                                                                  ##                              Colossus 1A
021644,000031:                                                                                                  ##
021645,000032:                                                                                                  ##      Prepared by
021646,000033:                                                                                                  ##                      Massachusetts Institute of Technology
021647,000034:                                                                                                  ##                      75 Cambridge Parkway
021648,000035:                                                                                                  ##                      Cambridge, Massachusetts
021649,000036:                                                                                                  ##      under NASA contract NAS 9-4065.
021650,000037:                                                                                                  ##
021651,000038:                                                                                                  ## Refer directly to the online document mentioned above for further information.
021652,000039:                                                                                                  ## Please report any errors (relative to the scanned pages) to info@sandroid.org.
021653,000040:                                                                                                  ##
021654,000041:                                                                                                  ## In some cases, where the source code for Luminary 131 overlaps that of 
021655,000042:                                                                                                  ## Colossus 249, this code is instead copied from the corresponding Luminary 131
021656,000043:                                                                                                  ## source file, and then is proofed to incorporate any changes.
021657,000044: 

Page 496

021659,000046: 34,2002                                           BANK     34                                    
021660,000047: 35,2000                                           SETLOC   R31                                   
021661,000048: 35,2000                                           BANK                                           
021662,000049: 
021663,000050: 35,3150                                           COUNT*   $$/R31                                
021664,000051: 
021665,000052: 35,3150           34752        R31CALL            CAF      PRIO3                                 
021666,000053: 35,3151           05042                           TC       FINDVAC                               
021667,000054: 35,3152  E4,1770                                  EBANK=   SUBEXIT                               
021668,000055: 35,3152           03204 72064                     2CADR    V83CALL                               
021669,000056: 
021670,000057: 35,3154           34734        DSPDELAY           CAF      1SEC                                  
021671,000058: 35,3155           04555                           TC       BANKCALL                              
021672,000059: 35,3156           01732                           CADR     DELAYJOB                              
021673,000060: 35,3157           31044                           CA       EXTVBACT                              
021674,000061: 35,3160           74677                           MASK     BIT12                                 
021675,000062: 35,3161           00006                           EXTEND                                         
021676,000063: 35,3162           13154                           BZF      DSPDELAY                              
021677,000064: 
021678,000065: 35,3163           30105        DISPN5X            CA       FLAGWRD9                              #  TEST R31FLAG (IN SUNDANCE R31FLAG WILL
021679,000066: 35,3164           74707                           MASK     BIT4                                  #        ALWAYS BE SET AS R34 DOES NOT EXIST)
021680,000067: 35,3165           00006                           EXTEND                                         
021681,000068: 35,3166           13171                           BZF      +3                                    
021682,000069: 35,3167           33310                           CAF      V16N54                                #  R31   USE NOUN 54
021683,000070: 35,3170           03172                           TC       +2                                    
021684,000071: 35,3171           33311                           CAF      V16N53                                #  R34   USE NOUN 53
021685,000072: 35,3172           04555                           TC       BANKCALL                              
021686,000073: 35,3173           20465                           CADR     GOMARKF                               
021687,000074: 35,3174           05514                           TC       B5OFF                                 
021688,000075: 35,3175           05514                           TC       B5OFF                                 
021689,000076: 35,3176           13163                           TCF      DISPN5X                               
021690,000077: 
021691,000078: 35,3177           06006        V83                TC       INTPRET                               
021692,000079: 35,3200           77624                           CALL                                           
021693,000080: 35,3201           73426                                    REDOEXTP                              
021694,000081: 35,3202           77650                           GOTO                                           
021695,000082: 35,3203           73207                                    COMPDISP                              
021696,000083: 35,3204           06006        V83CALL            TC       INTPRET                               
021697,000084: 35,3205           77624                           CALL                                           
021698,000085: 35,3206           73312                                    STATEXTP                              #  EXTRAPOLATE STATE VECTORS
021699,000086: 35,3207           52375        COMPDISP           VLOAD    VSU                                   
021700,000087: 35,3210           00001                                    RATT                                  
021701,000088: 35,3211           02327                                    RONE                                  
021702,000089: 35,3212           51406                           PUSH     ABVAL                                 #  RATT-RONE TO 0D       PD= 6
021703,000090: 35,3213           02321                           STORE    RANGE                                 #  METERS B-29
021704,000091: 35,3214           77301                           NORM     VLOAD                                 
021705,000092: 35,3215           00047                                    X1                                    #  RATT-RONE             PD= 0
021706,000093: 35,3216           77762                           VSR1                                           
021707,000094: 35,3217           53457                           VSL*     UNIT                                  

Page 497

021709,000096: 35,3220           20201                                    0,1                                   
021710,000097: 35,3221           52315                           PDVL     VSU                                   #  UNIT(LOS) TO 0D       PD= 6
021711,000098: 35,3222           00007                                    VATT                                  
021712,000099: 35,3223           02335                                    VONE                                  
021713,000100: 35,3224           77641                           DOT                                            #  (VATT-VONE).UNIT(LOS) PD= 0
021714,000101: 35,3225           77752                           SL1                                            
021715,000102: 35,3226           36323                           STCALL   RRATE                                 #  RANGE RATE M/CS B-7
021716,000103: 35,3227           47432                                    CDUTRIG                               #  TO INITIALIZE FOR *NBSM*
021717,000104: 35,3230           77624                           CALL                                           
021718,000105: 35,3231           62000                                    R34LOS                                #  NOTE.  PDL MUST = 0.
021719,000106: 35,3232           53575        R34ANG             VLOAD    UNIT                                  
021720,000107: 35,3233           02327                                    RONE                                  
021721,000108: 35,3234           77715                           PDVL                                           #  UR TO 0D              PD= 6
021722,000109: 35,3235           15330                                    THISAXIS                              #  UNITX FOR CM, UNITZ FOR LM
021723,000110: 35,3236           77214                           BON      VLOAD                                 #  CHK R31FLAG.  ON=R31 THETA, OFF=R34 PHI
021724,000111: 35,3237           04713                                    R31FLAG                               
021725,000112: 35,3240           73242                                    +2                                    #  R31-THETA
021726,000113: 35,3241           00015                                    12D                                   
021727,000114: 35,3242           77624                           CALL                                           
021728,000115: 35,3243           47601                                    *NBSM*                                
021729,000116: 35,3244           41505                           VXM      PUSH                                  #  UXORZ TO 6D           PD=12D
021730,000117: 35,3245           01736                                    REFSMMAT                              
021731,000118: 35,3246           72431                           VPROJ    VSL2                                  
021732,000119: 35,3247           00001                                    0D                                    
021733,000120: 35,3250           53445                           BVSU     UNIT                                  
021734,000121: 35,3251           00007                                    6D                                    
021735,000122: 35,3252           47315                           PDVL     VXV                                   #  UP/2 TO 12D           PD=18D
021736,000123: 35,3253           02327                                    RONE                                  
021737,000124: 35,3254           02335                                    VONE                                  
021738,000125: 35,3255           47256                           UNIT     VXV                                   
021739,000126: 35,3256           02327                                    RONE                                  
021740,000127: 35,3257           63241                           DOT      PDVL                                  #  SIGN TO 12D, UP/2 TO MPAC     PD=18D
021741,000128: 35,3260           00015                                    12D                                   
021742,000129: 35,3261           50372                           VSL1     DOT                                   #  UP.UXORZ
021743,000130: 35,3262           00007                                    6D                                    
021744,000131: 35,3263           72565                           SIGN     SL1                                   
021745,000132: 35,3264           00015                                    12D                                   
021746,000133: 35,3265           77726                           ACOS                                           
021747,000134: 35,3266           26325                           STOVL    RTHETA                                
021748,000135: 35,3267           02327                                    RONE                                  
021749,000136: 35,3270           51041                           DOT      BPL                                   
021750,000137: 35,3271           00007                                    6D                                    
021751,000138: 35,3272           73277                                    +5                                    
021752,000139: 35,3273           44345                           DLOAD    BDSU                                  #  IF UXORZ.R NEG, RTHETA = 1 - RTHETA
021753,000140: 35,3274           02325                                    RTHETA                                
021754,000141: 35,3275           15340                                    DPPOSMAX                              
021755,000142: 35,3276           02325                           STORE    RTHETA                                #  RTHETA BETWEEN 0 AND 1 REV.
021756,000143: 35,3277           77776                           EXIT                                           
021757,000144: 35,3300           34706                           CAF      BIT5                                  #  HAVE WE BEEN ANSWERED
021758,000145: 35,3301           71044                           MASK     EXTVBACT                              

Page 498

021760,000147: 35,3302           00006                           EXTEND                                         
021761,000148: 35,3303           15423                           BZF      ENDEXT                                #  YES, DIE
021762,000149: 
021763,000150: 35,3304           41044                           CS       EXTVBACT                              
021764,000151: 35,3305           74677                           MASK     BIT12                                 
021765,000152: 35,3306           27044                           ADS      EXTVBACT                              
021766,000153: 
021767,000154: 35,3307           13177                           TCF      V83                                   
021768,000155: 35,3310           04066        V16N54             VN       1654                                  
021769,000156: 35,3311           04065        V16N53             VN       1653                                  
021770,000157: 

Page 499

021772,000159:                                                                                                  #  THE STATEXTP SUBROUTINE DOES A PRECISION EXTRAPOLATION OF BOTH VEHICLES
021773,000160:                                                                                                  #  STATE VECTORS TO PRESENT TIME AND SAVES THEM AS BASE VECTORS.
021774,000161:                                                                                                  #  IF SERVICER IS OFF ---
021775,000162:                                                                                                  #                THIS VEHICLES BASE VECTOR IS CONIC EXTRAPOLATED TO
021776,000163:                                                                                                  #                PRESENT TIME AND SAVED AS RONE, VONE.
021777,000164:                                                                                                  #                THE OTHER VEHICLES BASE VECTOR IS CONIC EXTRAPOLATED
021778,000165:                                                                                                  #                TO THE SAME TIME, THE OUTPUT BEING LEFT IN RATT, VATT.
021779,000166:                                                                                                  #  IF SERVICER IS ON ---
021780,000167:                                                                                                  #                RONE, VONE ARE SET EQUAL TO RN, VN AND THE OTHER
021781,000168:                                                                                                  #                VEHICLES STATE VECTOR IS PREC. EXTRAPOLATED TO PIPTIME.
021782,000169: 
021783,000170: 35,3312           47020        STATEXTP           STQ      RTB                                   
021784,000171: 35,3313           00112                                    STATEXIT                              
021785,000172: 35,3314           45505                                    LOADTIME                              
021786,000173: 35,3315           34041                           STCALL   TDEC1                                 
021787,000174: 35,3316           27036                                    OTHPREC                               #  GET BASE VECTORS
021788,000175: 35,3317           77775                           VLOAD                                          
021789,000176: 35,3320           00017                                    RATT1                                 
021790,000177: 35,3321           26225                           STOVL    BASEOTP                               #  OTHER POS.
021791,000178: 35,3322           00025                                    VATT1                                 
021792,000179: 35,3323           16241                           STODL    BASEOTV                               #  OTHER VEL.
021793,000180: 35,3324           00015                                    TAT                                   
021794,000181: 35,3325           02272                           STORE    BASETIME                              
021795,000182: 35,3326           34041                           STCALL   TDEC1                                 
021796,000183: 35,3327           27022                                    THISPREC                              
021797,000184: 35,3330           77775                           VLOAD                                          
021798,000185: 35,3331           00017                                    RATT1                                 
021799,000186: 35,3332           26255                           STOVL    BASETHP                               #  THIS POS.
021800,000187: 35,3333           00025                                    VATT1                                 
021801,000188: 35,3334           02263                           STORE    BASETHV                               #  THIS VEL
021802,000189: 35,3335           47014        HAVEBASE           BON      RTB                                   
021803,000190: 35,3336           03711                                    V37FLAG                               
021804,000191: 35,3337           73413                                    GETRVN                                #  IF AVG ON ,GET RN ETC.
021805,000192: 35,3340           45505                                    LOADTIME                              
021806,000193: 35,3341           34041                           STCALL   TDEC1                                 #  BEGIN SET UP FOR CONIC EXTRAP. FOR THIS.
021807,000194: 35,3342           27371                                    INTSTALL                              
021808,000195: 35,3343           43175                           VLOAD    CLEAR                                 
021809,000196: 35,3344           02255                                    BASETHP                               
021810,000197: 35,3345           00263                                    MOONFLAG                              
021811,000198: 35,3346           25535                           STOVL    RCV                                   
021812,000199: 35,3347           02263                                    BASETHV                               
021813,000200: 35,3350           15543                           STODL    VCV                                   
021814,000201: 35,3351           02272                                    BASETIME                              
021815,000202: 35,3352           43014                           BOF      SET                                   #  GET APPROPRIATE MOONFLAG SETTING
021816,000203: 35,3353           04343                                    MOONTHIS                              
021817,000204: 35,3354           73356                                    +2                                    
021818,000205: 35,3355           00063                                    MOONFLAG                              
021819,000206: 35,3356           77614                           SET                                            
021820,000207: 35,3357           01473                                    INTYPFLG                              #  CONIC EXTRAP.
021821,000208: 35,3360           35517                           STCALL   TET                                   
021822,000209: 35,3361           27066                                    INTEGRVS                              #  INTEGRATION --- AT LAST---

Page 500

021824,000211: 35,3362           77775                           VLOAD                                          
021825,000212: 35,3363           00001                                    RATT                                  
021826,000213: 35,3364           26327                           STOVL    RONE                                  
021827,000214: 35,3365           00007                                    VATT                                  
021828,000215: 35,3366           36335                           STCALL   VONE                                  #  GET SET FOR CONIC EXTRAP., OTHER.
021829,000216: 35,3367           27371                                    INTSTALL                              
021830,000217: 35,3370           71214                           SET      DLOAD                                 
021831,000218: 35,3371           01473                                    INTYPFLG                              
021832,000219: 35,3372           00015                                    TAT                                   
021833,000220: 35,3373           00041        OTHINT             STORE    TDEC1                                 
021834,000221: 35,3374           43175                           VLOAD    CLEAR                                 
021835,000222: 35,3375           02225                                    BASEOTP                               
021836,000223: 35,3376           00263                                    MOONFLAG                              
021837,000224: 35,3377           25535                           STOVL    RCV                                   
021838,000225: 35,3400           02241                                    BASEOTV                               
021839,000226: 35,3401           15543                           STODL    VCV                                   
021840,000227: 35,3402           02272                                    BASETIME                              
021841,000228: 35,3403           43014                           BOF      SET                                   
021842,000229: 35,3404           04343                                    MOONTHIS                              
021843,000230: 35,3405           73407                                    +2                                    
021844,000231: 35,3406           00063                                    MOONFLAG                              
021845,000232: 35,3407           35517                           STCALL   TET                                   
021846,000233: 35,3410           27066                                    INTEGRVS                              
021847,000234: 35,3411           77650                           GOTO                                           
021848,000235: 35,3412           00112                                    STATEXIT                              #  THIS VEHICLES POS.,VEL. IN PUSHLIST.
021849,000236: 
021850,000237: 35,3413           77775        GETRVN             VLOAD                                          
021851,000238: 35,3414           01171                                    RN                                    
021852,000239: 35,3415           26327                           STOVL    RONE                                  
021853,000240: 35,3416           01177                                    VN                                    
021854,000241: 35,3417           16335                           STODL    VONE                                  
021855,000242: 35,3420           01205                                    PIPTIME                               
021856,000243: 35,3421           77624                           CALL                                           
021857,000244: 35,3422           27371                                    INTSTALL                              
021858,000245: 35,3423           52014                           CLEAR    GOTO                                  
021859,000246: 35,3424           01673                                    INTYPFLG                              #  PREC EXTRAP FOR OTHER
021860,000247: 35,3425           73373                                    OTHINT                                
021861,000248: 
021862,000249: 35,3426           52020        REDOEXTP           STQ      GOTO                                  
021863,000250: 35,3427           00112                                    STATEXIT                              
021864,000251: 35,3430           73335                                    HAVEBASE                              
021865,000252: 31,2000                                           SETLOC   R34                                   
021866,000253: 31,2000                                           BANK                                           
021867,000254: 31,2000           77776        R34LOS             EXIT                                           
021868,000255: 31,2001           30036                           CA       CDUS                                  
021869,000256: 31,2002           50120                           INDEX    FIXLOC                                
021870,000257: 31,2003           54011                           TS       9D                                    
021871,000258: 31,2004           30035                           CA       CDUT                                  
021872,000259: 31,2005           50120                           INDEX    FIXLOC                                
021873,000260: 31,2006           54013                           TS       11D                                   

Page 501

021875,000262: 31,2007           30120                           CA       FIXLOC                                
021876,000263: 31,2010           66211                           AD       SIX                                   
021877,000264: 31,2011           40000                           COM                                            
021878,000265: 31,2012           50120                           INDEX    FIXLOC                                
021879,000266: 31,2013           54046                           TS       X1                                    
021880,000267: 31,2014           06006                           TC       INTPRET                               
021881,000268: 31,2015           77624                           CALL                                           
021882,000269: 31,2016           46000                                    SXTNB                                 
021883,000270: 31,2017           34015                           STCALL   12D                                   
021884,000271: 31,2020           73232                                    R34ANG                                
021885,000272: 

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