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.

057941,000002:                                                                                                  ## Copyright:   Public domain.
057942,000003:                                                                                                  ## Filename:    INFLIGHT_ALIGNMENT_ROUTINES.agc
057943,000004:                                                                                                  ## Purpose:     Part of the source code for Colossus, build 249.
057944,000005:                                                                                                  ##              It is part of the source code for the Command Module's (CM)
057945,000006:                                                                                                  ##              Apollo Guidance Computer (AGC), for Apollo 9.
057946,000007:                                                                                                  ## Assembler:   yaYUL
057947,000008:                                                                                                  ## Reference:   Starts on p. 1323
057948,000009:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
057949,000010:                                                                                                  ## Website:     www.ibiblio.org/apollo.
057950,000011:                                                                                                  ## Mod history: 08/29/04 RSB.   Adapted from corresponding Luminary131 file.
057951,000012:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
057952,000013:                                                                                                  ##                              original harcopy, as opposed to the PDF page
057953,000014:                                                                                                  ##                              numbers in 1701.pdf.
057954,000015:                                                                                                  ##              2017-01-14 RSB  Cross-diff'd comment text (not whitespace)
057955,000016:                                                                                                  ##                              vs the already-proofed corresponding Colossus
057956,000017:                                                                                                  ##                              237 and Comanche 55 source-code files
057957,000018:                                                                                                  ##                              and corrected errors found.  After corrections,
057958,000019:                                                                                                  ##                              there were no text-comment differences between
057959,000020:                                                                                                  ##                              the different versions.
057960,000021:                                                                                                  ##
057961,000022:                                                                                                  ## The contents of the "Colossus249" files, in general, are transcribed 
057962,000023:                                                                                                  ## from a scanned copy of the program listing.  Notations on this
057963,000024:                                                                                                  ## document read, in part:
057964,000025:                                                                                                  ##
057965,000026:                                                                                                  ##      Assemble revision 249 of AGC program Colossus by NASA
057966,000027:                                                                                                  ##      2021111-041.  October 28, 1968.  
057967,000028:                                                                                                  ##
057968,000029:                                                                                                  ##      This AGC program shall also be referred to as
057969,000030:                                                                                                  ##                              Colossus 1A
057970,000031:                                                                                                  ##
057971,000032:                                                                                                  ##      Prepared by
057972,000033:                                                                                                  ##                      Massachusetts Institute of Technology
057973,000034:                                                                                                  ##                      75 Cambridge Parkway
057974,000035:                                                                                                  ##                      Cambridge, Massachusetts
057975,000036:                                                                                                  ##      under NASA contract NAS 9-4065.
057976,000037:                                                                                                  ##
057977,000038:                                                                                                  ## Refer directly to the online document mentioned above for further information.
057978,000039:                                                                                                  ## Please report any errors (relative to the scanned pages) to info@sandroid.org.
057979,000040:                                                                                                  ##
057980,000041:                                                                                                  ## In some cases, where the source code for Luminary 131 overlaps that of 
057981,000042:                                                                                                  ## Colossus 249, this code is instead copied from the corresponding Luminary 131
057982,000043:                                                                                                  ## source file, and then is proofed to incorporate any changes.
057983,000044: 

Page 1323

057985,000046: 22,3505                                           BANK     22                                    
057986,000047: 23,2000                                           SETLOC   INFLIGHT                              
057987,000048: 23,2000                                           BANK                                           
057988,000049: 
057989,000050: 23,3140  E5,1671                                  EBANK=   XSM                                   
057990,000051: 
057991,000052:                                                                                                  #  CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
057992,000053: 
057993,000054:                                                                                                  #  THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES.  THE THREE
057994,000055:                                                                                                  #  HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
057995,000056: 
057996,000057:                                                                                                  #  THE OUTPUTS ARE THE THREE GYRO TORQUING ANGLES TO BE APPLIED TO THE Y, Z, AND X GYROS AND ARE STORED DP AT IGC,
057997,000058:                                                                                                  #  MGC, AND OGC RESPECTIVELY.
057998,000059: 
057999,000060: 23,3140                                           COUNT    23/INFLT                              
058000,000061: 
058001,000062: 23,3140           71220        CALCGTA            ITA      DLOAD                                 #  PUSHDOWN 00-03, 16D-27D, 34D-37D
058002,000063: 23,3141           00051                                    S2                                    #  XDC = (XD1 XD2 XD3)
058003,000064: 23,3142           02714                                    XDC                                   #  YDC = (YD1 YD2 YD3)
058004,000065: 23,3143           65325                           PDDL     PDDL                                  #  ZDC = (ZD1 ZD2 ZD3)
058005,000066: 23,3144           15332                                    HI6ZEROS                              
058006,000067: 23,3145           02720                                    XDC        +4                         
058007,000068: 23,3146           55476                           DCOMP    VDEF                                  
058008,000069: 23,3147           77656                           UNIT                                           
058009,000070: 23,3150           14027                           STODL    ZPRIME                                #  ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
058010,000071: 23,3151           00027                                    ZPRIME                                
058011,000072: 
058012,000073: 23,3152           77742                           SR1                                            
058013,000074: 23,3153           14023                           STODL    SINTH                                 #  SIN(IGC) = ZP1
058014,000075: 23,3154           00033                                    ZPRIME     +4                         
058015,000076: 23,3155           77742                           SR1                                            
058016,000077: 23,3156           34021                           STCALL   COSTH                                 #  COS(IGC) = ZP3
058017,000078: 23,3157           47211                                    ARCTRIG                               
058018,000079: 
058019,000080: 23,3160           16762                           STODL    IGC                                   #  Y GYRO TORQUING ANGLE   FRACTION OF REV.
058020,000081: 23,3161           02716                                    XDC        +2                         
058021,000082: 23,3162           77742                           SR1                                            
058022,000083: 23,3163           14023                           STODL    SINTH                                 #  SIN(MGC) = XD2
058023,000084: 23,3164           00027                                    ZPRIME                                
058024,000085: 
058025,000086: 23,3165           65205                           DMP      PDDL                                  
058026,000087: 23,3166           02720                                    XDC        +4                         #  PD00 = (ZP1)(XD3)
058027,000088: 23,3167           00033                                    ZPRIME     +4                         
058028,000089: 
058029,000090: 23,3170           45205                           DMP      DSU                                   
058030,000091: 23,3171           02714                                    XDC                                   #  MPAC = (ZP3)(XD1)
058031,000092: 23,3172           77626                           STADR                                          
058032,000093: 23,3173           43756                           STCALL   COSTH                                 #  COS(MGC) = MPAC - PD00
058033,000094: 23,3174           47211                                    ARCTRIG                               

Page 1324

058035,000096: 23,3175           26764                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
058036,000097: 23,3176           00027                                    ZPRIME                                
058037,000098: 23,3177           77641                           DOT                                            
058038,000099: 23,3200           02730                                    ZDC                                   
058039,000100: 23,3201           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
058040,000101: 23,3202           00027                                    ZPRIME                                
058041,000102: 23,3203           77641                           DOT                                            
058042,000103: 23,3204           02722                                    YDC                                   
058043,000104: 23,3205           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
058044,000105: 23,3206           47211                                    ARCTRIG                               
058045,000106: 
058046,000107: 23,3207           36760                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
058047,000108: 23,3210           00051                                    S2                                    
058048,000109: 

Page 1325

058050,000111:                                                                                                  #  ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
058051,000112: 
058052,000113:                                                                                                  #  THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
058053,000114: 
058054,000115:                                                                                                  #  THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA.  THE OUTPUT IS ALSO
058055,000116:                                                                                                  #  AVAILABLE AT MPAC.
058056,000117: 
058057,000118: 23,3211           51545        ARCTRIG            DLOAD    ABS                                   #  PUSHDOWN  16D-21D
058058,000119: 23,3212           00023                                    SINTH                                 
058059,000120: 23,3213           50025                           DSU      BMN                                   
058060,000121: 23,3214           07427                                    QTSN45                                #  ABS(SIN/4) - SIN(45)/4
058061,000122: 23,3215           47224                                    TRIG1                                 #  IF (-45,45) OR (135,-135)
058062,000123: 
058063,000124: 23,3216           72545                           DLOAD    SL1                                   #  (45,135) OR (-135,-45)
058064,000125: 23,3217           00021                                    COSTH                                 
058065,000126: 23,3220           75326                           ACOS     SIGN                                  
058066,000127: 23,3221           00023                                    SINTH                                 
058067,000128: 23,3222           00025                           STORE    THETA                                 #  X = ARCCOS(COS) WITH SIGN(SIN)
058068,000129: 23,3223           77616                           RVQ                                            
058069,000130: 
058070,000131: 23,3224           72545        TRIG1              DLOAD    SL1                                   #  (-45,45) OR (135,-135)
058071,000132: 23,3225           00023                                    SINTH                                 
058072,000133: 23,3226           77736                           ASIN                                           
058073,000134: 23,3227           14025                           STODL    THETA                                 #  X = ARCSIN(SIN) WITH SIGN(SIN)
058074,000135: 23,3230           00021                                    COSTH                                 
058075,000136: 23,3231           77640                           BMN                                            
058076,000137: 23,3232           47235                                    TRIG2                                 #  IF (135,-135)
058077,000138: 
058078,000139: 23,3233           43545                           DLOAD    RVQ                                   
058079,000140: 23,3234           00025                                    THETA                                 #  X = ARCSIN(SIN)   (-45,45)
058080,000141: 
058081,000142: 23,3235           75345        TRIG2              DLOAD    SIGN                                  #  (135,-135)
058082,000143: 23,3236           15330                                    HIDPHALF                              
058083,000144: 23,3237           00023                                    SINTH                                 
058084,000145: 23,3240           77625                           DSU                                            
058085,000146: 23,3241           00025                                    THETA                                 
058086,000147: 23,3242           00025                           STORE    THETA                                 #  X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
058087,000148: 23,3243           77616                           RVQ                                            #        (+) - (+) OR (-) - (-)
058088,000149: 

Page 1326

058090,000151:                                                                                                  #  SMNB, NBSM, AND AXISROT, WHICH USED TO APPEAR HERE, HAVE BEEN
058091,000152:                                                                                                  #  COMBINED IN A ROUTINE CALLED AX*SR*T, WHICH APPEARS AMONG THE POWERED
058092,000153:                                                                                                  #  FLIGHT SUBROUTINES.
058093,000154: 

Page 1327

058095,000156:                                                                                                  #  CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
058096,000157: 
058097,000158:                                                                                                  #  THE INPUTS ARE  1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM.  THE THREE HALF-UNIT
058098,000159:                                                                                                  #  VECTORS ARE STORED AT XNB, YNB, AND ZNB.  2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
058099,000160:                                                                                                  #  COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
058100,000161: 
058101,000162:                                                                                                  #  THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
058102,000163: 
058103,000164: 23,3244           77601        CALCGA             SETPD                                          #  PUSHDOWN 00-05, 16D-21D, 34D-37D
058104,000165: 23,3245           00001                                    0                                     
058105,000166: 23,3246           47375                           VLOAD    VXV                                   
058106,000167: 23,3247           02714                                    XNB                                   #  XNB = OGA (OUTER GIMBAL AXIS)
058107,000168: 23,3250           02700                                    YSM                                   #  YSM = IGA (INNER GIMBAL AXIS)
058108,000169: 23,3251           41456                           UNIT     PUSH                                  #  PD0 = UNIT(OGA X IGA) = MGA
058109,000170: 
058110,000171: 23,3252           44041                           DOT      ITA                                   
058111,000172: 23,3253           02730                                    ZNB                                   
058112,000173: 23,3254           00051                                    S2                                    
058113,000174: 23,3255           24021                           STOVL    COSTH                                 #  COS(OG) = MGA . ZNB
058114,000175: 23,3256           00001                                    0                                     
058115,000176: 23,3257           77641                           DOT                                            
058116,000177: 23,3260           02722                                    YNB                                   
058117,000178: 23,3261           34023                           STCALL   SINTH                                 #  SIN(OG) = MGA . YNB
058118,000179: 23,3262           47211                                    ARCTRIG                               
058119,000180: 23,3263           26760                           STOVL    OGC                                   
058120,000181: 23,3264           00001                                    0                                     
058121,000182: 
058122,000183: 23,3265           50235                           VXV      DOT                                   #  PROVISION FOR MG ANGLE OF 90 DEGREES
058123,000184: 23,3266           02714                                    XNB                                   
058124,000185: 23,3267           02700                                    YSM                                   
058125,000186: 23,3270           77752                           SL1                                            
058126,000187: 23,3271           24021                           STOVL    COSTH                                 #  COS(MG) = IGA . (MGA X OGA)
058127,000188: 23,3272           02700                                    YSM                                   
058128,000189: 23,3273           77641                           DOT                                            
058129,000190: 23,3274           02714                                    XNB                                   
058130,000191: 23,3275           34023                           STCALL   SINTH                                 #  SIN(MG) = IGA . OGA
058131,000192: 23,3276           47211                                    ARCTRIG                               
058132,000193: 23,3277           02764                           STORE    MGC                                   
058133,000194: 
058134,000195: 23,3300           45246                           ABS      DSU                                   
058135,000196: 23,3301           07431                                    .166...                               
058136,000197: 23,3302           77644                           BPL                                            
058137,000198: 23,3303           47324                                    GIMLOCK1                              #  IF ANGLE GREATER THAN 60 DEGREES
058138,000199: 
058139,000200: 23,3304           50375        CALCGA1            VLOAD    DOT                                   
058140,000201: 23,3305           02706                                    ZSM                                   
058141,000202: 23,3306           00001                                    0                                     
058142,000203: 23,3307           24021                           STOVL    COSTH                                 #  COS(IG) = ZSM . MGA
058143,000204: 23,3310           02672                                    XSM                                   

Page 1328

058145,000206: 23,3311           45441                           DOT      STADR                                 
058146,000207: 23,3312           43754                           STCALL   SINTH                                 #  SIN(IG) = XSM . MGA
058147,000208: 23,3313           47211                                    ARCTRIG                               
058148,000209: 
058149,000210: 23,3314           26762                           STOVL    IGC                                   
058150,000211: 23,3315           02760                                    OGC                                   
058151,000212: 23,3316           43034                           RTB      BONCLR                                
058152,000213: 23,3317           45547                                    V1STO2S                               
058153,000214: 23,3320           00200                                    CPHIFLAG                              
058154,000215: 23,3321           00051                                    S2                                    
058155,000216: 23,3322           35156                           STCALL   THETAD                                
058156,000217: 23,3323           00051                                    S2                                    
058157,000218: 
058158,000219: 23,3324           77776        GIMLOCK1           EXIT                                           
058159,000220: 23,3325           05537                           TC       ALARM                                 
058160,000221: 23,3326           00401                           OCT      00401                                 
058161,000222: 23,3327           05435                           TC       UPFLAG                                #  GIMBAL LOCK HAS OCCURED
058162,000223: 23,3330           00056                           ADRES    GLOKFAIL                              
058163,000224: 
058164,000225: 23,3331           06006                           TC       INTPRET                               
058165,000226: 23,3332           77650                           GOTO                                           
058166,000227: 23,3333           47304                                    CALCGA1                               
058167,000228: 

Page 1329

058169,000230:                                                                                                  #  AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
058170,000231: 
058171,000232:                                                                                                  #  THE INPUTS ARE  1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD.  2) THE STAR2 VECTOR
058172,000233:                                                                                                  #  REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6.  3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
058173,000234:                                                                                                  #  AT LOCATION 6 OF THE VAC AREA.  4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
058174,000235:                                                                                                  #  THE VAC AREA.
058175,000236: 
058176,000237:                                                                                                  #  THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B.  THE THREE HALF-UNIT VECTORS ARE STORED
058177,000238:                                                                                                  #  AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
058178,000239: 
058179,000240: 23,3334           66370        AXISGEN            AXT,1    SSP                                   #  PUSHDOWN 00-30D, 34D-37D
058180,000241: 23,3335           02743                                    STARAD     +6                         
058181,000242: 23,3336           00051                                    S1                                    
058182,000243: 23,3337           02727                                    STARAD     -6                         
058183,000244: 
058184,000245: 23,3340           77601                           SETPD                                          
058185,000246: 23,3341           00001                                    0                                     
058186,000247: 23,3342           46773        AXISGEN1           VLOAD*   VXV*                                  #  06D   UA = S1
058187,000248: 23,3343           02752                                    STARAD     +12D,1                     #        STARAD +00D     UB = S1
058188,000249: 23,3344           02760                                    STARAD     +18D,1                     
058189,000250: 23,3345           77656                           UNIT                                           #  12D   VA = UNIT(S1 X S2)
058190,000251: 23,3346           06760                           STORE    STARAD     +18D,1                     #        STARAD +06D     VB = UNIT(S1 X S2)
058191,000252: 23,3347           77773                           VLOAD*                                         
058192,000253: 23,3350           02752                                    STARAD     +12D,1                     
058193,000254: 
058194,000255: 23,3351           76433                           VXV*     VSL1                                  
058195,000256: 23,3352           02760                                    STARAD     +18D,1                     #  18D   WA = UA X VA
058196,000257: 23,3353           06766                           STORE    STARAD     +24D,1                     #        STARAD +12D     WB = UB X VB
058197,000258: 
058198,000259: 23,3354           77700                           TIX,1                                          
058199,000260: 23,3355           47342                                    AXISGEN1                              
058200,000261: 
058201,000262: 23,3356           66160                           AXC,1    SXA,1                                 
058202,000263: 23,3357           00006                                    6                                     
058203,000264: 23,3360           00036                                    30D                                   
058204,000265: 
058205,000266: 23,3361           66370                           AXT,1    SSP                                   
058206,000267: 23,3362           00022                                    18D                                   
058207,000268: 23,3363           00051                                    S1                                    
058208,000269: 23,3364           00006                                    6                                     
058209,000270: 
058210,000271: 23,3365           66374                           AXT,2    SSP                                   
058211,000272: 23,3366           00006                                    6                                     
058212,000273: 23,3367           00052                                    S2                                    
058213,000274: 23,3370           00002                                    2                                     
058214,000275: 
058215,000276: 23,3371           76720        AXISGEN2           XCHX,1   VLOAD*                                
058216,000277: 23,3372           00036                                    30D                                   #  X1=-6 X2=+6   X1=-6 X2=+4     X1=-6 X2=+2
058217,000278: 23,3373           00001                                    0,1                                   
058218,000279: 

Page 1330

058220,000281: 23,3374           62757                           VXSC*    PDVL*                                 #  J=(UA)(UB1)   J=(UA)(UB2)     J=(UA)(UB3)
058221,000282: 23,3375           75033                                    STARAD     +6,2                       
058222,000283: 23,3376           00007                                    6,1                                   
058223,000284: 23,3377           77757                           VXSC*                                          
058224,000285: 23,3400           75025                                    STARAD     +12D,2                     
058225,000286: 23,3401           30031                           STOVL*   24D                                   #  K=(VA)(VB1)   J=(VA)(VB2)     J=(VA)(VB3)
058226,000287: 23,3402           00015                                    12D,1                                 
058227,000288: 
058228,000289: 23,3403           53357                           VXSC*    VAD                                   
058229,000290: 23,3404           75017                                    STARAD     +18D,2                     #  L=(WA)(WB1)   J=(WA)(WB2)     J=(WA)(WB3)
058230,000291: 23,3405           76455                           VAD      VSL1                                  
058231,000292: 23,3406           00031                                    24D                                   
058232,000293: 23,3407           53520                           XCHX,1   UNIT                                  
058233,000294: 23,3410           00036                                    30D                                   
058234,000295: 23,3411           06736                           STORE    XDC        +18D,1                     #  XDC = L+J+K   YDC = L+J+K     ZDC = L+J+K
058235,000296: 
058236,000297: 23,3412           77700                           TIX,1                                          
058237,000298: 23,3413           47414                                    AXISGEN3                              
058238,000299: 
058239,000300: 23,3414           77704        AXISGEN3           TIX,2                                          
058240,000301: 23,3415           47371                                    AXISGEN2                              
058241,000302: 
058242,000303: 23,3416           77775                           VLOAD                                          
058243,000304: 23,3417           02714                                    XDC                                   
058244,000305: 23,3420           26736                           STOVL    STARAD                                
058245,000306: 23,3421           02722                                    YDC                                   
058246,000307: 23,3422           26744                           STOVL    STARAD     +6                         
058247,000308: 23,3423           02730                                    ZDC                                   
058248,000309: 23,3424           02752                           STORE    STARAD     +12D                       
058249,000310: 
058250,000311: 23,3425           77616                           RVQ                                            
058251,000312: 

Page 1331

058253,000314: 23,3426           05520 26075  QTSN45             2DEC     .1768                                 
058254,000315: 23,3430           05252 25253  .166...            2DEC     .1666666667                            
058255,000316: 

Page 1332 There is no source code on this page of the original assembly listing. —RSB 2004

058258,000319: 
058259,000320: 

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