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.

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

Page 496

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

Page 497

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

Page 498

021772,000147: 35,3302           00006                           EXTEND                                         
021773,000148: 35,3303           15423                           BZF      ENDEXT                                #  YES, DIE
021774,000149: 
021775,000150: 35,3304           41044                           CS       EXTVBACT                              
021776,000151: 35,3305           74677                           MASK     BIT12                                 
021777,000152: 35,3306           27044                           ADS      EXTVBACT                              
021778,000153: 
021779,000154: 35,3307           13177                           TCF      V83                                   
021780,000155: 35,3310           04066        V16N54             VN       1654                                  
021781,000156: 35,3311           04065        V16N53             VN       1653                                  
021782,000157: 

Page 499

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

Page 500

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

Page 501

021887,000262: 31,2007           30120                           CA       FIXLOC                                
021888,000263: 31,2010           66211                           AD       SIX                                   
021889,000264: 31,2011           40000                           COM                                            
021890,000265: 31,2012           50120                           INDEX    FIXLOC                                
021891,000266: 31,2013           54046                           TS       X1                                    
021892,000267: 31,2014           06006                           TC       INTPRET                               
021893,000268: 31,2015           77624                           CALL                                           
021894,000269: 31,2016           46000                                    SXTNB                                 
021895,000270: 31,2017           34015                           STCALL   12D                                   
021896,000271: 31,2020           73232                                    R34ANG                                
021897,000272: 

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