Source Code

These source code files are a reconstruction of Sundance, the Apollo 9 LM (Lunar Module) AGC (Apollo Guidance Computer) flight software, created from binary dumps of original core rope program modules, as follows:
  • B1 — Revision 292
  • B2 — Revision 302
  • B3 — Revision 302
  • B4 — Revision 302
  • B5 — Revision 292
  • B6 — Revision 306
This means that source code does not represent a specific historical revision of Sundance, but rather a mixture of the three released versions. Nonetheless, it is capable of flying the whole Apollo 9 mission. This source code matches the binary dumps, as closely as feasible, but 100% match is not possible, due mostly to changes in memory addresses at which code and variables were allocated in different revisions of Sundance. Refer to this list of explanations for each binary mismatch.

Since only binary dumps (rather than listings) of Sundance are available as source material, all comments and labels are approximate. They have been taken from other AGC programs where possible, or, in some places, written from scratch to match what we believe would have been in the original listing.

048586,000002:                                                                                                  ## Copyright:   Public domain.
048587,000003:                                                                                                  ## Filename:    INFLIGHT_ALIGNMENT_ROUTINES.agc
048588,000004:                                                                                                  ## Purpose:     A section of a reconstructed, mixed version of Sundance
048589,000005:                                                                                                  ##              It is part of the reconstructed source code for the Lunar
048590,000006:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
048591,000007:                                                                                                  ##              No original listings of this program are available;
048592,000008:                                                                                                  ##              instead, this file was created via disassembly of dumps
048593,000009:                                                                                                  ##              of various revisions of Sundance core rope modules.
048594,000010:                                                                                                  ## Assembler:   yaYUL
048595,000011:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
048596,000012:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
048597,000013:                                                                                                  ## Mod history: 2020-06-17 MAS  Created from Luminary 69.
048598,000014: 
048599,000015:                                                                                                  ## Sundance 302
048600,000016: 
048601,000017: 22,3644                                           BANK     22                                    
048602,000018: 23,2000                                           SETLOC   INFLIGHT                              
048603,000019: 23,2000                                           BANK                                           
048604,000020: 
048605,000021: 23,2757  E5,1642                                  EBANK=   XSM                                   
048606,000022: 
048607,000023:                                                                                                  #  CALCGTA COMPUTES THE GYRO TORQUE ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
048608,000024: 
048609,000025:                                                                                                  #  THE INPUT IS THE DESIRED STABLE MEMBER COORDINATES REFERRED TO PRESENT STABLE MEMBER COORDINATES. THE THREE
048610,000026:                                                                                                  #  HALF-UNIT VECTORS ARE STORED AT XDC, YDC, AND ZDC.
048611,000027: 
048612,000028:                                                                                                  #  THE OUTPUTS ARE THE THREE GYRO TORQUING ANGLES TO BE APPLIED TO THE Y, Z, AND X GYROS AND ARE STORED DP AT IGC,
048613,000029:                                                                                                  #  MGC, AND OGC RESPECTIVELY.
048614,000030: 
048615,000031: 23,2757                                           COUNT*   $$/INFLT                              
048616,000032: 23,2757           71220        CALCGTA            ITA      DLOAD                                 #  PUSHDOWN  00-03,16D-27D,34D-37D
048617,000033: 23,2760           00051                                    S2                                    #  XDC = (XD1 XD2 XD3)
048618,000034: 23,2761           02665                                    XDC                                   #  YDC = (YD1 YD2 YD3)
048619,000035: 23,2762           65325                           PDDL     PDDL                                  #  ZDC = (ZD1 ZD2 ZD3)
048620,000036: 23,2763           06233                                    HI6ZEROS                              
048621,000037: 23,2764           02671                                    XDC        +4                         
048622,000038: 23,2765           55476                           DCOMP    VDEF                                  
048623,000039: 23,2766           77656                           UNIT                                           
048624,000040: 23,2767           14027                           STODL    ZPRIME                                #  ZP = UNIT(-XD3 0 XD1) = (ZP1 ZP2 ZP3)
048625,000041: 23,2770           00027                                    ZPRIME                                
048626,000042: 
048627,000043: 23,2771           77742                           SR1                                            
048628,000044: 23,2772           14023                           STODL    SINTH                                 #  SIN(IGC) = ZP1
048629,000045: 23,2773           00033                                    ZPRIME     +4                         
048630,000046: 23,2774           77742                           SR1                                            
048631,000047: 23,2775           34021                           STCALL   COSTH                                 #  COS(IGC) = ZP3
048632,000048: 23,2776           47030                                    ARCTRIG                               
048633,000049: 
048634,000050: 23,2777           16742                           STODL    IGC                                   #  Y GYRO TORQUING ANGLE   FRACTION OF REV.
048635,000051: 23,3000           02667                                    XDC        +2                         
048636,000052: 23,3001           77742                           SR1                                            
048637,000053: 23,3002           14023                           STODL    SINTH                                 #  SIN(MGC) = XD2
048638,000054: 23,3003           00027                                    ZPRIME                                
048639,000055: 
048640,000056: 23,3004           65205                           DMP      PDDL                                  
048641,000057: 23,3005           02671                                    XDC        +4                         #  PD00 = (ZP1)(XD3)
048642,000058: 23,3006           00033                                    ZPRIME     +4                         
048643,000059: 
048644,000060: 23,3007           45205                           DMP      DSU                                   
048645,000061: 23,3010           02665                                    XDC                                   #  MPAC = (ZP3)(XD1)
048646,000062: 23,3011           77626                           STADR                                          
048647,000063: 23,3012           43756                           STCALL   COSTH                                 #  COS(MGC) = MPAC - PD00
048648,000064: 23,3013           47030                                    ARCTRIG                               
048649,000065: 23,3014           26744                           STOVL    MGC                                   #  Z GYRO TORQUING ANGLE   FRACTION OF REV.
048650,000066: 23,3015           00027                                    ZPRIME                                
048651,000067: 23,3016           77641                           DOT                                            
048652,000068: 23,3017           02701                                    ZDC                                   
048653,000069: 23,3020           24021                           STOVL    COSTH                                 #  COS(OGC) = ZP . ZDC
048654,000070: 23,3021           00027                                    ZPRIME                                
048655,000071: 23,3022           77641                           DOT                                            
048656,000072: 23,3023           02673                                    YDC                                   
048657,000073: 23,3024           34023                           STCALL   SINTH                                 #  SIN(OGC) = ZP . YDC
048658,000074: 23,3025           47030                                    ARCTRIG                               
048659,000075: 
048660,000076: 23,3026           36740                           STCALL   OGC                                   #  X GYRO TORQUING ANGLE   FRACTION OF REV.
048661,000077: 23,3027           00051                                    S2                                    
048662,000078: 
048663,000079:                                                                                                  #  ARCTRIG COMPUTES AN ANGLE GIVEN THE SINE AND COSINE OF THIS ANGLE.
048664,000080: 
048665,000081:                                                                                                  #  THE INPUTS ARE SIN/4 AND COS/4 STORED DP AT SINTH AND COSTH.
048666,000082: 
048667,000083:                                                                                                  #  THE OUTPUT IS THE CALCULATED ANGLE BETWEEN +.5 AND -.5 REVOLUTIONS AND STORED AT THETA. THE OUTPUT IS ALSO
048668,000084:                                                                                                  #  AVAILABLE AT MPAC.
048669,000085: 
048670,000086: 23,3030           51545        ARCTRIG            DLOAD    ABS                                   #  PUSHDOWN  16D-21D
048671,000087: 23,3031           00023                                    SINTH                                 
048672,000088: 23,3032           50025                           DSU      BMN                                   
048673,000089: 23,3033           07246                                    QTSN45                                #  ABS(SIN/4) - SIN(45)/4
048674,000090: 23,3034           47043                                    TRIG1                                 #  IF (-45,45) OR (135,-135)
048675,000091: 
048676,000092: 23,3035           72545                           DLOAD    SL1                                   #  (45,135) OR (-135,-45)
048677,000093: 23,3036           00021                                    COSTH                                 
048678,000094: 23,3037           75326                           ACOS     SIGN                                  
048679,000095: 23,3040           00023                                    SINTH                                 
048680,000096: 23,3041           00025                           STORE    THETA                                 #  X = ARCCOS(COS) WITH SIGN(SIN)
048681,000097: 23,3042           77616                           RVQ                                            
048682,000098: 
048683,000099: 23,3043           72545        TRIG1              DLOAD    SL1                                   #  (-45,45) OR (135,-135)
048684,000100: 23,3044           00023                                    SINTH                                 
048685,000101: 23,3045           77736                           ASIN                                           
048686,000102: 23,3046           14025                           STODL    THETA                                 #  X = ARCSIN(SIN) WITH SIGN(SIN)
048687,000103: 23,3047           00021                                    COSTH                                 
048688,000104: 23,3050           77640                           BMN                                            
048689,000105: 23,3051           47054                                    TRIG2                                 #  IF (135,-135)
048690,000106: 
048691,000107: 23,3052           43545                           DLOAD    RVQ                                   
048692,000108: 23,3053           00025                                    THETA                                 #  X = ARCSIN(SIN)   (-45,45)
048693,000109: 
048694,000110: 23,3054           75345        TRIG2              DLOAD    SIGN                                  #  (135,-135)
048695,000111: 23,3055           06231                                    HIDPHALF                              
048696,000112: 23,3056           00023                                    SINTH                                 
048697,000113: 23,3057           77625                           DSU                                            
048698,000114: 23,3060           00025                                    THETA                                 
048699,000115: 23,3061           00025                           STORE    THETA                                 #  X = .5 WITH SIGN(SIN) - ARCSIN(SIN)
048700,000116: 23,3062           77616                           RVQ                                            #        (+) - (+) OR (-) - (-)
048701,000117: 
048702,000118:                                                                                                  #      SMNB, NBSM, AND AXISROT, WHICH USED TO APPEAR HERE, HAVE BEEN
048703,000119:                                                                                                  #  COMBINED IN A ROUTINE CALLED AX*SR*T, WHICH APPEARS AMONG THE POWERED
048704,000120:                                                                                                  #  FLIGHT SUBROUTINES.
048705,000121: 
048706,000122:                                                                                                  #  CALCGA COMPUTES THE CDU DRIVING ANGLES REQUIRED TO BRING THE STABLE MEMBER INTO THE DESIRED ORIENTATION.
048707,000123: 
048708,000124:                                                                                                  #  THE INPUTS ARE  1) THE NAVIGATION BASE COORDINATES REFERRED TO ANY COORDINATE SYSTEM. THE THREE HALF-UNIT
048709,000125:                                                                                                  #  VECTORS ARE STORED AT XNB, YNB, AND ZNB. 2) THE DESIRED STABLE MEMBER COORDINATES REFERRED TO THE SAME
048710,000126:                                                                                                  #  COORDINATE SYSTEM ARE STORED AT XSM, YSM, AND ZSM.
048711,000127: 
048712,000128:                                                                                                  #  THE OUTPUTS ARE THE THREE CDU DRIVING ANGLES AND ARE STORED SP AT THETAD, THETAD +1, AND THETAD +2.
048713,000129: 
048714,000130: 23,3063           77601        CALCGA             SETPD                                          #  PUSHDOWN  00-05, 16D-21D, 34D-37D
048715,000131: 23,3064           00001                                    0                                     
048716,000132: 23,3065           47375                           VLOAD    VXV                                   
048717,000133: 23,3066           02665                                    XNB                                   #  XNB = OGA (OUTER GIMBAL AXIS)
048718,000134: 23,3067           02651                                    YSM                                   #  YSM = IGA (INNER GIMBAL AXIS)
048719,000135: 23,3070           41456                           UNIT     PUSH                                  #  PD0 = UNIT(OGA X IGA) = MGA
048720,000136: 
048721,000137: 23,3071           44041                           DOT      ITA                                   
048722,000138: 23,3072           02701                                    ZNB                                   
048723,000139: 23,3073           00051                                    S2                                    
048724,000140: 23,3074           24021                           STOVL    COSTH                                 #  COS(OG) = MGA . ZNB
048725,000141: 23,3075           00001                                    0                                     
048726,000142: 23,3076           77641                           DOT                                            
048727,000143: 23,3077           02673                                    YNB                                   
048728,000144: 23,3100           34023                           STCALL   SINTH                                 #  SIN(OG) = MGA . YNB
048729,000145: 23,3101           47030                                    ARCTRIG                               
048730,000146: 23,3102           26740                           STOVL    OGC                                   
048731,000147: 23,3103           00001                                    0                                     
048732,000148: 
048733,000149: 23,3104           50235                           VXV      DOT                                   #  PROVISION FOR MG ANGLE OF 90 DEGREES
048734,000150: 23,3105           02665                                    XNB                                   
048735,000151: 23,3106           02651                                    YSM                                   
048736,000152: 23,3107           77752                           SL1                                            
048737,000153: 23,3110           24021                           STOVL    COSTH                                 #  COS(MG) = IGA . (MGA X OGA)
048738,000154: 23,3111           02651                                    YSM                                   
048739,000155: 23,3112           77641                           DOT                                            
048740,000156: 23,3113           02665                                    XNB                                   
048741,000157: 23,3114           34023                           STCALL   SINTH                                 #  SIN(MG) = IGA . OGA
048742,000158: 23,3115           47030                                    ARCTRIG                               
048743,000159: 23,3116           02744                           STORE    MGC                                   
048744,000160: 
048745,000161: 23,3117           45246                           ABS      DSU                                   
048746,000162: 23,3120           07250                                    .166...                               
048747,000163: 23,3121           77644                           BPL                                            
048748,000164: 23,3122           47143                                    GIMLOCK1                              #  IF ANGLE GREATER THAN 60 DEGREES
048749,000165: 
048750,000166: 23,3123           50375        CALCGA1            VLOAD    DOT                                   
048751,000167: 23,3124           02657                                    ZSM                                   
048752,000168: 23,3125           00001                                    0                                     
048753,000169: 23,3126           24021                           STOVL    COSTH                                 #  COS(IG) = ZSM . MGA
048754,000170: 23,3127           02643                                    XSM                                   
048755,000171: 23,3130           45441                           DOT      STADR                                 
048756,000172: 23,3131           43754                           STCALL   SINTH                                 #  SIN(IG) = XSM . MGA
048757,000173: 23,3132           47030                                    ARCTRIG                               
048758,000174: 
048759,000175: 23,3133           26742                           STOVL    IGC                                   
048760,000176: 23,3134           02740                                    OGC                                   
048761,000177: 23,3135           43034                           RTB      BONCLR                                
048762,000178: 23,3136           21516                                    V1STO2S                               
048763,000179: 23,3137           00200                                    CPHIFLAG                              
048764,000180: 23,3140           00051                                    S2                                    
048765,000181: 23,3141           35207                           STCALL   THETAD                                
048766,000182: 23,3142           00051                                    S2                                    
048767,000183: 
048768,000184: 23,3143           77776        GIMLOCK1           EXIT                                           
048769,000185: 23,3144           05646                           TC       ALARM                                 
048770,000186: 23,3145           00401                           OCT      00401                                 
048771,000187: 23,3146           05563                           TC       UPFLAG                                #  GIMBAL LOCK HAS OCCURED
048772,000188: 23,3147           00056                           ADRES    GLOKFAIL                              
048773,000189: 
048774,000190: 23,3150           06014                           TC       INTPRET                               
048775,000191: 23,3151           77650                           GOTO                                           
048776,000192: 23,3152           47123                                    CALCGA1                               
048777,000193: 
048778,000194:                                                                                                  #  AXISGEN COMPUTES THE COORDINATES OF ONE COORDINATE SYSTEM REFERRED TO ANOTHER COORDINATE SYSTEM.
048779,000195: 
048780,000196:                                                                                                  #  THE INPUTS ARE  1) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM A STORED AT STARAD.  2) THE STAR2 VECTOR
048781,000197:                                                                                                  #  REFERRED TO COORDINATE SYSTEM A STORED AT STARAD +6.  3) THE STAR1 VECTOR REFERRED TO COORDINATE SYSTEM B STORED
048782,000198:                                                                                                  #  AT LOCATION 6 OF THE VAC AREA.  4) THE STAR2 VECTOR REFERRED TO COORDINATE SYSTEM B STORED AT LOCATION 12D OF
048783,000199:                                                                                                  #  THE VAC AREA.
048784,000200: 
048785,000201:                                                                                                  #  THE OUTPUT DEFINES COORDINATE SYSTEM A REFERRED TO COORDINATE SYSTEM B. THE THREE HALF-UNIT VECTORS ARE STORED
048786,000202:                                                                                                  #  AT LOCATIONS XDC, XDC +6, XDC +12D, AND STARAD, STARAD +6, STARAD +12D.
048787,000203: 
048788,000204: 23,3153           66370        AXISGEN            AXT,1    SSP                                   #  PUSHDOWN 00-30D,34D-37D
048789,000205: 23,3154           02714                                    STARAD     +6                         
048790,000206: 23,3155           00051                                    S1                                    
048791,000207: 23,3156           02700                                    STARAD     -6                         
048792,000208: 
048793,000209: 23,3157           77601                           SETPD                                          
048794,000210: 23,3160           00001                                    0                                     
048795,000211: 23,3161           46773        AXISGEN1           VLOAD*   VXV*                                  #  06D   UA = S1
048796,000212: 23,3162           02723                                    STARAD     +12D,1                     #         STARAD +00D   UB = S1
048797,000213: 23,3163           02731                                    STARAD     +18D,1                     
048798,000214: 23,3164           77656                           UNIT                                           #  12D   VA = UNIT(S1 X S2)
048799,000215: 23,3165           06731                           STORE    STARAD     +18D,1                     #         STARAD +06D   VB = UNIT(S1 X S2)
048800,000216: 23,3166           77773                           VLOAD*                                         
048801,000217: 23,3167           02723                                    STARAD     +12D,1                     
048802,000218: 
048803,000219: 23,3170           76433                           VXV*     VSL1                                  
048804,000220: 23,3171           02731                                    STARAD     +18D,1                     #  18D   WA = UA X VA
048805,000221: 23,3172           06737                           STORE    STARAD     +24D,1                     #         STARAD +12D   WB = UB X VB
048806,000222: 
048807,000223: 23,3173           77700                           TIX,1                                          
048808,000224: 23,3174           47161                                    AXISGEN1                              
048809,000225: 
048810,000226: 23,3175           66160                           AXC,1    SXA,1                                 
048811,000227: 23,3176           00006                                    6                                     
048812,000228: 23,3177           00036                                    30D                                   
048813,000229: 
048814,000230: 23,3200           66370                           AXT,1    SSP                                   
048815,000231: 23,3201           00022                                    18D                                   
048816,000232: 23,3202           00051                                    S1                                    
048817,000233: 23,3203           00006                                    6                                     
048818,000234: 
048819,000235: 23,3204           66374                           AXT,2    SSP                                   
048820,000236: 23,3205           00006                                    6                                     
048821,000237: 23,3206           00052                                    S2                                    
048822,000238: 23,3207           00002                                    2                                     
048823,000239: 
048824,000240: 23,3210           76720        AXISGEN2           XCHX,1   VLOAD*                                
048825,000241: 23,3211           00036                                    30D                                   #  X1=-6 X2=+6   X1=-6 X2=+4     X1=-6 X2=+2
048826,000242: 23,3212           00001                                    0,1                                   
048827,000243: 
048828,000244: 23,3213           62757                           VXSC*    PDVL*                                 #  J=(UA)(UB1)   J=(UA)(UB2)     J=(UA)(UB3)
048829,000245: 23,3214           75062                                    STARAD     +6,2                       
048830,000246: 23,3215           00007                                    6,1                                   
048831,000247: 23,3216           77757                           VXSC*                                          
048832,000248: 23,3217           75054                                    STARAD     +12D,2                     
048833,000249: 23,3220           30031                           STOVL*   24D                                   #  K=(VA)(VB1)   J=(VA)(VB2)     J=(VA)(VB3)
048834,000250: 23,3221           00015                                    12D,1                                 
048835,000251: 
048836,000252: 23,3222           53357                           VXSC*    VAD                                   
048837,000253: 23,3223           75046                                    STARAD     +18D,2                     #  L=(WA)(WB1)   J=(WA)(WB2)     J=(WA)(WB3)
048838,000254: 23,3224           76455                           VAD      VSL1                                  
048839,000255: 23,3225           00031                                    24D                                   
048840,000256: 23,3226           53520                           XCHX,1   UNIT                                  
048841,000257: 23,3227           00036                                    30D                                   
048842,000258: 23,3230           06707                           STORE    XDC        +18D,1                     #  XDC = L+J+K   YDC = L+J+K     ZDC = L+J+K
048843,000259: 
048844,000260: 23,3231           77700                           TIX,1                                          
048845,000261: 23,3232           47233                                    AXISGEN3                              
048846,000262: 
048847,000263: 23,3233           77704        AXISGEN3           TIX,2                                          
048848,000264: 23,3234           47210                                    AXISGEN2                              
048849,000265: 
048850,000266: 23,3235           77775                           VLOAD                                          
048851,000267: 23,3236           02665                                    XDC                                   
048852,000268: 23,3237           26707                           STOVL    STARAD                                
048853,000269: 23,3240           02673                                    YDC                                   
048854,000270: 23,3241           26715                           STOVL    STARAD     +6                         
048855,000271: 23,3242           02701                                    ZDC                                   
048856,000272: 23,3243           02723                           STORE    STARAD     +12D                       
048857,000273: 
048858,000274: 23,3244           77616                           RVQ                                            
048859,000275: 
048860,000276: 23,3245           05520 26075  QTSN45             2DEC     .1768                                 
048861,000277: 
048862,000278: 23,3247           05252 25253  .166...            2DEC     .1666666667                            
048863,000279: 

Empty page

048865,000281: 

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