Source Code

These source code files are an attempted reconstruction of Sundance revision 306, 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
These dumps were then modified using memos, checklists, observed address changes, and the Sundance GSOPs to get the entire program to match Sundance revision 306 as closely as possible. Without more information, it is not possible to say how close it actually is; however, this code should be quite close. It is capable of flying the whole Apollo 9 mission using the original checklists and padload. 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.

043664,000002:                                                                                                  ## Copyright:   Public domain.
043665,000003:                                                                                                  ## Filename:    LATITUDE_LONGITUDE_SUBROUTINES.agc
043666,000004:                                                                                                  ## Purpose:     A section of an attempt to reconstruct Sundance revision 306
043667,000005:                                                                                                  ##              as closely as possible with available information. Sundance
043668,000006:                                                                                                  ##              306 is the source code for the Lunar Module's (LM) Apollo
043669,000007:                                                                                                  ##              Guidance Computer (AGC) for Apollo 9. This program was created
043670,000008:                                                                                                  ##              using the mixed-revision SundanceXXX as a starting point, and
043671,000009:                                                                                                  ##              pulling back features from Luminary 69 believed to have been
043672,000010:                                                                                                  ##              added based on memos, checklists, observed address changes,
043673,000011:                                                                                                  ##              or the Sundance GSOPs.
043674,000012:                                                                                                  ## Assembler:   yaYUL
043675,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
043676,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
043677,000015:                                                                                                  ## Mod history: 2020-07-24 MAS  Created from SundanceXXX.
043678,000016: 
043679,000017: 
043680,000018: 
043681,000019:                                                                                                  #  SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
043682,000020: 
043683,000021:                                                                                                  #  CALLING SEQUENCE
043684,000022:                                                                                                  #        L-1     CALL
043685,000023:                                                                                                  #        L               LAT-LONG
043686,000024: 
043687,000025:                                                                                                  #  SUBROUTINES USED
043688,000026:                                                                                                  #        R-TO-RP,ARCTAN,SETGAMMA,SETRE
043689,000027: 
043690,000028:                                                                                                  #  ERASABLE INIT. REQ.
043691,000029:                                                                                                  #        AXO,-AYO,AZO,TEPHEM (SET AT LAUNCH TIME)
043692,000030:                                                                                                  #        ALPHAV = POSITION VECTOR METERS B-29
043693,000031:                                                                                                  #        MPAC-- TIME (CSECS B-28)
043694,000032:                                                                                                  #        ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
043695,000033:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
043696,000034: 
043697,000035:                                                                                                  #  OUTPUT
043698,000036:                                                                                                  #        LATITUDE IN LAT         (REVS. B-0)
043699,000037:                                                                                                  #        LONGITUDE IN LONG       (REVS. B-0)
043700,000038:                                                                                                  #        ALTITUDE IN ALT         METERS B-29
043701,000039: 
043702,000040: 30,3645                                           BANK     30                                    
043703,000041: 13,2000                                           SETLOC   LATLONG                               
043704,000042: 13,2000                                           BANK                                           
043705,000043: 
043706,000044: 13,2323                                           COUNT*   $$/LT-LG                              
043707,000045: 13,2323  E4,1433                                  EBANK=   ALPHAV                                
043708,000046: 13,2323           40220        LAT-LONG           STQ      SETPD                                 
043709,000047: 13,2324           03661                                    INCORPEX                              
043710,000048: 13,2325           00001                                    0D                                    
043711,000049: 13,2326           24007                           STOVL    6D                                    #  SAVE TIME IN 6-7D FOR R-TO-RP
043712,000050: 13,2327           02034                                    ALPHAV                                
043713,000051: 13,2330           51406                           PUSH     ABVAL                                 #  0-5D= R FOR R-TO-RP
043714,000052: 13,2331           16072                           STODL    ALPHAM                                #  ABS. VALUE OF R FOR ALT FORMULA BELOW
043715,000053: 13,2332           22276                                    ZEROVEC                               #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
043716,000054: 13,2333           71414                           BOFF     COS                                   #  USE COS(0) TO GET NON-ZERO IN MPAC
043717,000055: 13,2334           01743                                    LUNAFLAG                              #  0=EARTH, 1=MOON
043718,000056: 13,2335           26336                                    CALLRTRP                              
043719,000057: 13,2336           77624        CALLRTRP           CALL                                           
043720,000058: 13,2337           51247                                    R-TO-RP                               #  RP VECTOR CONVERTED FROM R B-29
043721,000059: 13,2340           77656                           UNIT                                           #  UNIT RP B-1
043722,000060: 13,2341           36034                           STCALL   ALPHAV                                #  U2= 1/2 SINL FOR SETRE SUBR BELOW
043723,000061: 13,2342           26524                                    SETGAMMA                              #        SET GAMMA=B2/A2 FOR EARTH,=1 FOR MOON
043724,000062: 13,2343           77624                           CALL                                           #        SCALED B-1
043725,000063: 13,2344           26534                                    SETRE                                 #  CALC RE METERS B-29
043726,000064: 13,2345           63545                           DLOAD    DSQ                                   
043727,000065: 13,2346           02034                                    ALPHAV                                
043728,000066: 13,2347           63525                           PDDL     DSQ                                   
043729,000067: 13,2350           02036                                    ALPHAV     +2                         
043730,000068: 13,2351           75415                           DAD      SQRT                                  
043731,000069: 13,2352           76405                           DMP      SL1R                                  
043732,000070: 13,2353           00011                                    GAMRP                                 
043733,000071: 13,2354           14021                           STODL    COSTH                                 #  COS(LAT) B-1
043734,000072: 13,2355           02040                                    ALPHAV     +4                         
043735,000073: 13,2356           34023                           STCALL   SINTH                                 #  SIN(LAT) B-1
043736,000074: 13,2357           26464                                    ARCTAN                                
043737,000075: 13,2360           15124                           STODL    LAT                                   #  LAT B0
043738,000076: 13,2361           02034                                    ALPHAV                                
043739,000077: 13,2362           14021                           STODL    COSTH                                 #  COS(LONG) B-1
043740,000078: 13,2363           02036                                    ALPHAV     +2                         
043741,000079: 13,2364           34023                           STCALL   SINTH                                 #  SIN(LONG) B-1
043742,000080: 13,2365           26464                                    ARCTAN                                
043743,000081: 13,2366           15126                           STODL    LONG                                  #  LONG. REVS B-0 IN RANGE -1/2 TO 1/2
043744,000082: 13,2367           02072                                    ALPHAM                                
043745,000083: 13,2370           77625                           DSU                                            #  ALT= R-RE METERS B-29
043746,000084: 13,2371           03660                                    ERADM                                 
043747,000085: 13,2372           35130                           STCALL   ALT                                   #  EXIT WITH ALT METERS B-29
043748,000086: 13,2373           03661                                    INCORPEX                              
043749,000087:                                                                                                  #  SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
043750,000088: 
043751,000089:                                                                                                  #  CALLING SEQUENCE
043752,000090:                                                                                                  #        L-1     CALL
043753,000091:                                                                                                  #        L               LALOTORV
043754,000092: 
043755,000093:                                                                                                  #  SUBROUTINES USED
043756,000094:                                                                                                  #        SETGAMMA,SETRE,RP-TO-R
043757,000095: 
043758,000096:                                                                                                  #  ERASABLE INIT. REQ.
043759,000097:                                                                                                  #        AXO,AYO,AZO,TEPHEM SET AT LAUNCH TIME
043760,000098:                                                                                                  #        LAT-- LATITUDE  (REVS B0)
043761,000099:                                                                                                  #        LONG-- LONGITUDE        (REVS B0)
043762,000100:                                                                                                  #        ALT--ALTITUDE           (METERS) B-29
043763,000101:                                                                                                  #        MPAC-- TIME             (CSECS B-28)
043764,000102:                                                                                                  #        ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
043765,000103:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
043766,000104: 
043767,000105:                                                                                                  #  OUTPUT
043768,000106:                                                                                                  #        R-VECTOR IN ALPHAV      (METERS B-29)
043769,000107: 
043770,000108: 13,2374           40220        LALOTORV           STQ      SETPD                                 #  LAT,LONG,ALT TO R VECTOR
043771,000109: 13,2375           03661                                    INCORPEX                              
043772,000110: 13,2376           00001                                    0D                                    
043773,000111: 13,2377           34007                           STCALL   6D                                    #  6-7D= TIME FOR RP-TO-R
043774,000112: 13,2400           26524                                    SETGAMMA                              #  GAMMA=B2/A2 FOR EARTH,1 FOR MOON B-1
043775,000113: 13,2401           73545                           DLOAD    SIN                                   #                COS(LONG)COS(LAT) IN MPAC
043776,000114: 13,2402           01124                                    LAT                                   #      UNIT RP=  SIN(LONG)COS(LAT)    2-3D
043777,000115: 13,2403           65275                           DMPR     PDDL                                  #  PD 2          GAMMA*SIN(LAT)       0-1D
043778,000116: 13,2404           00011                                    GAMRP                                 
043779,000117: 13,2405           01124                                    LAT                                   #         0-1D=  GAMMA*SIN(LAT) B-2
043780,000118: 13,2406           65346                           COS      PDDL                                  #  PD 4     2-3D=COS(LAT) B-1 TEMPORARILY
043781,000119: 13,2407           01126                                    LONG                                  
043782,000120: 13,2410           57356                           SIN      DMPR                                  #  PD 2
043783,000121: 13,2411           71525                           PDDL     COS                                   #  PD 4   2-3D=SIN(LONG)COS(LAT) B-2
043784,000122: 13,2412           01124                                    LAT                                   
043785,000123: 13,2413           71525                           PDDL     COS                                   #  PD 6   4-5D=COS(LAT) B-1 TEMPORARILY
043786,000124: 13,2414           01126                                    LONG                                  
043787,000125: 13,2415           55475                           DMPR     VDEF                                  #  PD 4   MPAC=  COS(LONG)COS(LAT) B-2
043788,000126: 13,2416           41456                           UNIT     PUSH                                  #  0-5D= UNIT RP FOR RP-TO-R SUBR.
043789,000127: 13,2417           36034                           STCALL   ALPHAV                                #  ALPHAV +4= SINL FOR SETRE SUBR.
043790,000128: 13,2420           26534                                    SETRE                                 #  RE METERS B-29
043791,000129: 13,2421           43145                           DLOAD    BOFF                                  #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
043792,000130: 13,2422           22276                                    ZEROVEC                               
043793,000131: 13,2423           01743                                    LUNAFLAG                              
043794,000132: 13,2424           26426                                    CALLRPRT                              
043795,000133: 13,2425           77746                           COS                                            #  USE COS(0) TO GET NON-ZERO IN MPAC
043796,000134: 13,2426           77624        CALLRPRT           CALL                                           
043797,000135: 13,2427           51222                                    RP-TO-R                               #  EXIT WITH UNIT R VECTOR IN MPAC
043798,000136: 13,2430           16034                           STODL    ALPHAV                                
043799,000137: 13,2431           03660                                    ERADM                                 
043800,000138: 13,2432           74215                           DAD      VXSC                                  #  (RE + ALT)(UNIT R) METERS B-30
043801,000139: 13,2433           01130                                    ALT                                   
043802,000140: 13,2434           02034                                    ALPHAV                                
043803,000141: 13,2435           77772                           VSL1                                           #  R METERS B-29
043804,000142: 13,2436           36034                           STCALL   ALPHAV                                #  EXIT WITH R IN METERS B-29
043805,000143: 13,2437           03661                                    INCORPEX                              
043806,000144: 
043807,000145:                                                                                                  #  SUBROUTINE TO COMPUTE EARTH RADIUS
043808,000146: 
043809,000147:                                                                                                  #  INPUT
043810,000148:                                                                                                  #        1/2 SIN LAT IN ALPHAV +4
043811,000149: 
043812,000150:                                                                                                  #  OUTPUT
043813,000151:                                                                                                  #        EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
043814,000152: 
043815,000153: 13,2440           63545        GETERAD            DLOAD    DSQ                                   
043816,000154: 13,2441           02040                                    ALPHAV     +4                         #  SIN**2(L)
043817,000155: 13,2442           44352                           SL1      BDSU                                  
043818,000156: 13,2443           22274                                    DP1/2                                 #  COS**2(L)
043819,000157: 13,2444           44275                           DMPR     BDSU                                  
043820,000158: 13,2445           26461                                    EE                                    
043821,000159: 13,2446           22274                                    DP1/2                                 
043822,000160: 13,2447           75465                           BDDV     SQRT                                  
043823,000161: 13,2450           26455                                    B2XSC                                 
043824,000162: 13,2451           77622                           SR4R                                           
043825,000163: 13,2452           03660                           STORE    ERADM                                 
043826,000164: 13,2453           77616                           RVQ                                            
043827,000165: 
043828,000166:                                                                                                  #  THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
043829,000167:                                                                                                  #  B2XSC= B**2 SCALED B-51
043830,000168:                                                                                                  #  B2/A2= B**2/A**2 SCALED B-1
043831,000169:                                                                                                  #  EE=(1-B**2/A**2) SCALED B-0
043832,000170: 
043833,000171: 13,2454           00446 00305  B2XSC              2DEC     .0179450689                            #  B**2 SCALED B-51
043834,000172: 13,2456  11,2273               DP1/2              =        XUNIT                                 
043835,000173: 13,2456           17711 05254  B2/A2              2DEC     .9933064884 B-1                        #  GAMMA= B**2/A**2 B-1
043836,000174: 13,2460           00155 25250  EE                 2DEC     6.6935116  E-3                        #  (1-B**2/A**2) B-0
043837,000175: 13,2462           00302 17755  ERAD               2DEC     6373338    B-29                       #  PAD RADIUS
043838,000176: 
043839,000177:                                                                                                  #  ARCTAN SUBROUTINE
043840,000178: 
043841,000179:                                                                                                  #  CALLING SEQUENCE
043842,000180:                                                                                                  #        SIN THETA IN SINTH B-1
043843,000181:                                                                                                  #        COS THETA IN COSTH B-1
043844,000182:                                                                                                  #        CALL ARCTAN
043845,000183: 
043846,000184:                                                                                                  #  OUTPUT
043847,000185:                                                                                                  #        ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
043848,000186: 
043849,000187: 13,2464           77600        ARCTAN             BOV                                            
043850,000188: 13,2465           26466                                    CLROVFLW                              
043851,000189: 13,2466           63545        CLROVFLW           DLOAD    DSQ                                   
043852,000190: 13,2467           00023                                    SINTH                                 
043853,000191: 13,2470           63525                           PDDL     DSQ                                   
043854,000192: 13,2471           00021                                    COSTH                                 
043855,000193: 13,2472           77615                           DAD                                            
043856,000194: 13,2473           75454                           BZE      SQRT                                  
043857,000195: 13,2474           26512                                    ARCTANXX                              #  ATAN=0/0  SET THETA=0
043858,000196: 13,2475           40065                           BDDV     BOV                                   
043859,000197: 13,2476           00023                                    SINTH                                 
043860,000198: 13,2477           26517                                    ATAN=90                               
043861,000199: 13,2500           67542                           SR1      ASIN                                  
043862,000200: 13,2501           00025                           STORE    THETA                                 
043863,000201: 13,2502           50125                           PDDL     BMN                                   
043864,000202: 13,2503           00021                                    COSTH                                 
043865,000203: 13,2504           26506                                    NEGCOS                                
043866,000204: 13,2505           43545                           DLOAD    RVQ                                   
043867,000205: 13,2506           57545        NEGCOS             DLOAD    DCOMP                                 
043868,000206: 13,2507           43244                           BPL      DAD                                   
043869,000207: 13,2510           26514                                    NEGOUT                                
043870,000208: 13,2511           22274                                    DP1/2                                 
043871,000209: 13,2512           00025        ARCTANXX           STORE    THETA                                 
043872,000210: 13,2513           77616                           RVQ                                            
043873,000211: 
043874,000212: 13,2514           52025        NEGOUT             DSU      GOTO                                  
043875,000213: 13,2515           22274                                    DP1/2                                 
043876,000214: 13,2516           26512                                    ARCTANXX                              
043877,000215: 13,2517           75345        ATAN=90            DLOAD    SIGN                                  
043878,000216: 13,2520           10676                                    LODP1/4                               
043879,000217: 13,2521           00023                                    SINTH                                 
043880,000218: 13,2522           00025                           STORE    THETA                                 
043881,000219: 13,2523           77616                           RVQ                                            
043882,000220: 
043883,000221: 13,2524  11,2275               2DZERO             =        DPZERO                                
043884,000222: 
043885,000223:                                                                                                  #  ..... SETGAMMA SUBROUTINE .....
043886,000224:                                                                                                  #  SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
043887,000225: 
043888,000226:                                                                                                  #  GAMMA = B**2/A**2 FOR EARTH (B-1)
043889,000227:                                                                                                  #  GAMMA = 1 FOR MOON (B-1)
043890,000228: 
043891,000229:                                                                                                  #  CALLING SEQUENCE
043892,000230:                                                                                                  #        L       CALL
043893,000231:                                                                                                  #        L+1             SETGAMMA
043894,000232: 
043895,000233:                                                                                                  #  INPUT
043896,000234:                                                                                                  #        LUNAFLAG=0 FOR EARTH,=1 FOR MOON
043897,000235: 
043898,000236:                                                                                                  #  OUTPUT
043899,000237:                                                                                                  #        GAMMA IN GAMRP (B-1)
043900,000238: 
043901,000239: 13,2524           43145        SETGAMMA           DLOAD    BOFF                                  #  BRANCH FOR EARTH
043902,000240: 13,2525           26457                                    B2/A2                                 #  EARTH GAMMA
043903,000241: 13,2526           01743                                    LUNAFLAG                              
043904,000242: 13,2527           26532                                    SETGMEX                               
043905,000243: 13,2530           77735                           SLOAD                                          
043906,000244: 13,2531           22274                                    1B1                                   #  MOON GAMMA
043907,000245: 13,2532           00011        SETGMEX            STORE    GAMRP                                 
043908,000246: 13,2533           77616                           RVQ                                            
043909,000247: 13,2534                        GAMRP              =        8D                                    
043910,000248: 
043911,000249:                                                                                                  #  ..... SETRE SUBROUTINE .....
043912,000250:                                                                                                  #  SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
043913,000251: 
043914,000252:                                                                                                  #        RE= RM FOR MOON
043915,000253:                                                                                                  #                RE= RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
043916,000254: 
043917,000255:                                                                                                  #  CALLING SEQUENCE
043918,000256:                                                                                                  #        L       CALL
043919,000257:                                                                                                  #        L+1             SETRE
043920,000258: 
043921,000259:                                                                                                  #  SUBROUTINES USED
043922,000260:                                                                                                  #        GETERAD
043923,000261: 
043924,000262:                                                                                                  #  INPUT
043925,000263:                                                                                                  #        ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED RE
043926,000264:                                                                                                  #        ALPHAV +4= 1/2 SINL IF GETERAD IS CALLED
043927,000265:                                                                                                  #        LUNAFLAG=0 FOR EARTH,=1 FOR MOON
043928,000266: 
043929,000267:                                                                                                  #  OUTPUT
043930,000268:                                                                                                  #        ERADM= 504RM FOR MOON (METERS B-29)
043931,000269:                                                                                                  #        ERADM= ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
043932,000270: 
043933,000271: 13,2534           71220        SETRE              STQ      DLOAD                                 
043934,000272: 13,2535           00051                                    SETREX                                
043935,000273: 13,2536           26561                                    504RM                                 
043936,000274: 13,2537           71214                           BON      DLOAD                                 #  BRANCH FOR MOON
043937,000275: 13,2540           01703                                    LUNAFLAG                              
043938,000276: 13,2541           26551                                    TSTRLSRM                              
043939,000277: 13,2542           26463                                    ERAD                                  
043940,000278: 13,2543           45014                           BOFF     CALL                                  #  ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
043941,000279: 13,2544           00742                                    ERADFLAG                              
043942,000280: 13,2545           26547                                    SETRXX                                
043943,000281: 13,2546           26440                                    GETERAD                               
043944,000282: 13,2547           37660        SETRXX             STCALL   ERADM                                 #  EXIT WITH RE OR RM METERS B-29
043945,000283: 13,2550           00051                                    SETREX                                
043946,000284: 13,2551           77214        TSTRLSRM           BON      VLOAD                                 #  ERADFLAG=0, SET R0=RLS
043947,000285: 13,2552           00702                                    ERADFLAG                              #          =1      R0=RM
043948,000286: 13,2553           26547                                    SETRXX                                
043949,000287: 13,2554           02025                                    RLS                                   
043950,000288: 13,2555           64446                           ABVAL    SR2R                                  #  SCALE FROM B-27 TO B-29
043951,000289: 13,2556           77650                           GOTO                                           
043952,000290: 13,2557           26547                                    SETRXX                                
043953,000291: 13,2560  0000051               SETREX             =        S2                                    
043954,000292: 13,2560           00065 01265  504RM              2DEC     1738090    B-29                       #  METERS B-29 (EQUATORIAL MOON RADIUS)

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