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.

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

Page 1323

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

Page 1324

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

Page 1325

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

Page 1326

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

Page 1327

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

Page 1328

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

Page 1329

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

Page 1330

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

Page 1331

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

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

058259,000319: 
058260,000320: 

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