Source Code

These source-code files were from the printout at the MIT Museum, with many thanks to Deborah Douglas, the Museum's Curator of Science and Technology, for releasing it to us. The printout was digitally photographed by Paul Fjeld. A team of volunteers transcribed the source code manually from these images or, where appropriate, modified already-transcribed but similar source Luminary 131 (Apollo 13) source code to agree with the images from the printout. 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:

	GAP:  ASSEMBLE REVISION 001 OF AGC PROGRAM LMY99 BY NASA 2021112-061
	16:27 JULY 14,1969
Note that the date is the date of the printout, not the date of the program revision.

048328,000002:                                                                                                  ## Copyright:   Public domain.
048329,000003:                                                                                                  ## Filename:    LATITUDE_LONGITUDE_SUBROUTINES.agc
048330,000004:                                                                                                  ## Purpose:     Part of the source code for Luminary 1A build 099.
048331,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
048332,000006:                                                                                                  ##              Apollo Guidance Computer (AGC), for Apollo 11.
048333,000007:                                                                                                  ##
048334,000008:                                                                                                  ## Assembler:   yaYUL
048335,000009:                                                                                                  ## Contact:     Jim Lawton <jim DOT lawton AT gmail DOT com>
048336,000010:                                                                                                  ## Website:     www.ibiblio.org/apollo.
048337,000011:                                                                                                  ## Pages:       1133-1139
048338,000012:                                                                                                  ## Mod history: 2009-05-28 JL   Updated from page images.
048339,000013:                                                                                                  ##              2011-01-06 JL   Fixed interpretive indentation.
048340,000014:                                                                                                  ##              2016-12-17 RSB  Proofed text comments with octopus/ProoferComments
048341,000015:                                                                                                  ##                              and corrected the errors found.
048342,000016:                                                                                                  ##              2017-03-15 RSB  Comment-text fixes identified in 5-way
048343,000017:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
048344,000018: 
048345,000019:                                                                                                  ## This source code has been transcribed or otherwise adapted from digitized
048346,000020:                                                                                                  ## images of a hardcopy from the MIT Museum.  The digitization was performed
048347,000021:                                                                                                  ## by Paul Fjeld, and arranged for by Deborah Douglas of the Museum.  Many
048348,000022:                                                                                                  ## thanks to both.  The images (with suitable reduction in storage size and
048349,000023:                                                                                                  ## consequent reduction in image quality as well) are available online at
048350,000024:                                                                                                  ## www.ibiblio.org/apollo.  If for some reason you find that the images are
048351,000025:                                                                                                  ## illegible, contact me at info@sandroid.org about getting access to the
048352,000026:                                                                                                  ## (much) higher-quality images which Paul actually created.
048353,000027:                                                                                                  ##
048354,000028:                                                                                                  ## Notations on the hardcopy document read, in part:
048355,000029:                                                                                                  ##
048356,000030:                                                                                                  ##    Assemble revision 001 of AGC program LMY99 by NASA 2021112-061
048357,000031:                                                                                                  ##    16:27 JULY 14, 1969
048358,000032: 

Page 1133

048360,000034:                                                                                                  #  SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
048361,000035: 
048362,000036:                                                                                                  #  CALLING SEQUENCE
048363,000037:                                                                                                  #        L-1     CALL
048364,000038:                                                                                                  #        L               LAT-LONG
048365,000039: 
048366,000040:                                                                                                  #  SUBROUTINES USED
048367,000041:                                                                                                  #        R-TO-RP, ARCTAN, SETGAMMA, SETRE
048368,000042: 
048369,000043:                                                                                                  #  ERASABLE INIT. REQ.
048370,000044:                                                                                                  #        AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
048371,000045:                                                                                                  #        ALPHAV = POSITION VECTOR METERS B-29
048372,000046:                                                                                                  #        MPAC -- TIME (CSECS B-28)
048373,000047:                                                                                                  #        ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
048374,000048:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
048375,000049: 
048376,000050:                                                                                                  #  OUTPUT
048377,000051:                                                                                                  #        LATITUDE IN LAT         (REVS. B-0)
048378,000052:                                                                                                  #        LONGITUDE IN LONG       (REVS. B-0)
048379,000053:                                                                                                  #        ALTITUDE IN ALT         METERS B-29
048380,000054: 
048381,000055: 30,3775                                           BANK     30                                    
048382,000056: 13,2000                                           SETLOC   LATLONG                               
048383,000057: 13,2000                                           BANK                                           
048384,000058: 
048385,000059: 13,2351                                           COUNT*   $$/LT-LG                              
048386,000060: 13,2351  E4,1431                                  EBANK=   ALPHAV                                
048387,000061: 13,2351           40220        LAT-LONG           STQ      SETPD                                 
048388,000062: 13,2352           03674                                    INCORPEX                              
048389,000063: 13,2353           00001                                    0D                                    
048390,000064: 13,2354           24007                           STOVL    6D                                    #  SAVE TIME IN 6-7D FOR R-TO-RP
048391,000065: 13,2355           02032                                    ALPHAV                                
048392,000066: 13,2356           51406                           PUSH     ABVAL                                 #  0-5D= R FOR R-TO-RP
048393,000067: 13,2357           16070                           STODL    ALPHAM                                #  ABS. VALUE OF R FOR ALT FORMULA BELOW
048394,000068: 13,2360           24007                                    ZEROVEC                               #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
048395,000069: 13,2361           71414                           BOFF     COS                                   #  USE COS(0) TO GET NON-ZERO IN MPAC
048396,000070: 13,2362           01743                                    LUNAFLAG                              #  0=EARTH, 1=MOON
048397,000071: 13,2363           26364                                    CALLRTRP                              
048398,000072: 13,2364           77624        CALLRTRP           CALL                                           
048399,000073: 13,2365           51670                                    R-TO-RP                               #  RP VECTOR CONVERTED FROM R B-29
048400,000074: 13,2366           77656                           UNIT                                           #  UNIT RP B-1
048401,000075: 13,2367           36032                           STCALL   ALPHAV                                #  U2= 1/2 SINL FOR SETRE SUBR BELOW
048402,000076: 13,2370           26550                                    SETGAMMA                              #        SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
048403,000077: 13,2371           77624                           CALL                                           #        SCALED B-1
048404,000078: 13,2372           26560                                    SETRE                                 #  CALC RE METERS B-29
048405,000079: 13,2373           63545                           DLOAD    DSQ                                   
048406,000080: 13,2374           02032                                    ALPHAV                                
048407,000081: 13,2375           63525                           PDDL     DSQ                                   
048408,000082: 13,2376           02034                                    ALPHAV     +2                         
048409,000083: 13,2377           75415                           DAD      SQRT                                  

Page 1134

048411,000085: 13,2400           76405                           DMP      SL1R                                  
048412,000086: 13,2401           00011                                    GAMRP                                 
048413,000087: 13,2402           14021                           STODL    COSTH                                 #  COS(LAT) B-1
048414,000088: 13,2403           02036                                    ALPHAV     +4                         
048415,000089: 13,2404           34023                           STCALL   SINTH                                 #  SIN(LAT) B-1
048416,000090: 13,2405           26510                                    ARCTAN                                
048417,000091: 13,2406           15121                           STODL    LAT                                   #  LAT B0
048418,000092: 13,2407           02032                                    ALPHAV                                
048419,000093: 13,2410           14021                           STODL    COSTH                                 #  COS(LONG) B-1
048420,000094: 13,2411           02034                                    ALPHAV     +2                         
048421,000095: 13,2412           34023                           STCALL   SINTH                                 #  SIN(LONG) B-1
048422,000096: 13,2413           26510                                    ARCTAN                                
048423,000097: 13,2414           15123                           STODL    LONG                                  #  LONG. REVS B-0 IN RANGE -1/2 TO 1/2
048424,000098: 13,2415           02070                                    ALPHAM                                
048425,000099: 13,2416           77625                           DSU                                            #  ALT= R-RE METERS B-29
048426,000100: 13,2417           03673                                    ERADM                                 
048427,000101: 13,2420           35125                           STCALL   ALT                                   #  EXIT WITH ALT METERS B-29
048428,000102: 13,2421           03674                                    INCORPEX                              

Page 1135

048430,000104:                                                                                                  #  SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
048431,000105: 
048432,000106:                                                                                                  #  CALLING SEQUENCE
048433,000107:                                                                                                  #        L-1     CALL
048434,000108:                                                                                                  #        L               LALOTORV
048435,000109: 
048436,000110:                                                                                                  #  SUBROUTINES USED
048437,000111:                                                                                                  #        SETGAMMA, SETRE, RP-TO-R
048438,000112: 
048439,000113:                                                                                                  #  ERASABLE INIT. REQ.
048440,000114:                                                                                                  #        AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
048441,000115:                                                                                                  #        LAT -- LATITUDE         (REVS B0)
048442,000116:                                                                                                  #        LONG -- LONGITUDE       (REVS B0)
048443,000117:                                                                                                  #        ALT -- ALTITUDE         (METERS) B-29
048444,000118:                                                                                                  #        MPAC -- TIME            (CSECS B-28)
048445,000119:                                                                                                  #        ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
048446,000120:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
048447,000121: 
048448,000122:                                                                                                  #  OUTPUT
048449,000123:                                                                                                  #        R-VECTOR IN ALPHAV      (METERS B-29)
048450,000124: 
048451,000125: 13,2422           40220        LALOTORV           STQ      SETPD                                 #  LAT,LONG,ALT TO R VECTOR
048452,000126: 13,2423           03674                                    INCORPEX                              
048453,000127: 13,2424           00001                                    0D                                    
048454,000128: 13,2425           34007                           STCALL   6D                                    #  6-7D= TIME FOR RP-TO-R
048455,000129: 13,2426           26550                                    SETGAMMA                              #  GAMMA=B2/A2 FOR EARTH, 1 FOR MOON B-1
048456,000130: 13,2427           73545                           DLOAD    SIN                                   #                COS(LONG)COS(LAT) IN MPAC
048457,000131: 13,2430           01121                                    LAT                                   #      UNIT RP = SIN(LONG)COS(LAT)    2-3D
048458,000132: 13,2431           65275                           DMPR     PDDL                                  #  PD 2          GAMMA*SIN(LAT)       0-1D
048459,000133: 13,2432           00011                                    GAMRP                                 
048460,000134: 13,2433           01121                                    LAT                                   #         0-1D = GAMMA*SIN(LAT) B-2
048461,000135: 13,2434           65346                           COS      PDDL                                  #  PD4    2-3D = COS(LAT) B-1 TEMPORARILY
048462,000136: 13,2435           01123                                    LONG                                  
048463,000137: 13,2436           57356                           SIN      DMPR                                  #  PD 2
048464,000138: 13,2437           71525                           PDDL     COS                                   #  PD 4   2-3D = SIN(LONG)COS(LAT) B-2
048465,000139: 13,2440           01121                                    LAT                                   
048466,000140: 13,2441           71525                           PDDL     COS                                   #  PD 6   4-5D = COS(LAT) B-1 TEMPORARILY
048467,000141: 13,2442           01123                                    LONG                                  
048468,000142: 13,2443           55475                           DMPR     VDEF                                  #  PD 4   MPAC = COS(LONG)COS(LAT) B-2
048469,000143: 13,2444           41456                           UNIT     PUSH                                  #  0-5D= UNIT RP FOR RP-TO-R SUBR.
048470,000144: 13,2445           36032                           STCALL   ALPHAV                                #  ALPHAV +4= SINL FOR SETRE SUBR.
048471,000145: 13,2446           26560                                    SETRE                                 #  RE METERS B-29
048472,000146: 13,2447           43145                           DLOAD    BOFF                                  #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
048473,000147: 13,2450           24007                                    ZEROVEC                               
048474,000148: 13,2451           01743                                    LUNAFLAG                              
048475,000149: 13,2452           26454                                    CALLRPRT                              
048476,000150: 13,2453           77746                           COS                                            #  USE COS(0) TO GET NON-ZERO IN MPAC
048477,000151: 13,2454           77624        CALLRPRT           CALL                                           
048478,000152: 13,2455           55716                                    RP-TO-R                               #  EXIT WITH UNIT R VECTOR IN MPAC
048479,000153: 13,2456           16032                           STODL    ALPHAV                                
048480,000154: 13,2457           03673                                    ERADM                                 

Page 1136

048482,000156: 13,2460           74215                           DAD      VXSC                                  #  (RE + ALT)(UNIT R) METERS B-30
048483,000157: 13,2461           01125                                    ALT                                   
048484,000158: 13,2462           02032                                    ALPHAV                                
048485,000159: 13,2463           77772                           VSL1                                           #  R METERS B-29
048486,000160: 13,2464           36032                           STCALL   ALPHAV                                #  EXIT WITH R IN METERS B-29
048487,000161: 13,2465           03674                                    INCORPEX                              
048488,000162: 
048489,000163:                                                                                                  #  SUBROUTINE TO COMPUTE EARTH RADIUS
048490,000164: 
048491,000165:                                                                                                  #  INPUT
048492,000166:                                                                                                  #        1/2 SIN LAT IN ALPHAV +4
048493,000167: 
048494,000168:                                                                                                  #  OUTPUT
048495,000169:                                                                                                  #        EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
048496,000170: 
048497,000171: 13,2466           63545        GETERAD            DLOAD    DSQ                                   
048498,000172: 13,2467           02036                                    ALPHAV     +4                         #  SIN**2(L)
048499,000173: 13,2470           44352                           SL1      BDSU                                  
048500,000174: 13,2471           24005                                    DP1/2                                 #  COS**2(L)
048501,000175: 13,2472           44275                           DMPR     BDSU                                  
048502,000176: 13,2473           26507                                    EE                                    
048503,000177: 13,2474           24005                                    DP1/2                                 
048504,000178: 13,2475           75465                           BDDV     SQRT                                  
048505,000179: 13,2476           26503                                    B2XSC                                 
048506,000180: 13,2477           77622                           SR4R                                           
048507,000181: 13,2500           03673                           STORE    ERADM                                 
048508,000182: 13,2501           77616                           RVQ                                            
048509,000183: 
048510,000184:                                                                                                  #  THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
048511,000185:                                                                                                  #  B2XSC = B**2 SCALED B-51
048512,000186:                                                                                                  #  B2/A2 = B**2/A**2 SCALED B-1
048513,000187:                                                                                                  #  EE = (1-B**2/A**2) SCALED B-0
048514,000188: 
048515,000189: 13,2502           00446 00305  B2XSC              2DEC     .0179450689                            #  B**2 SCALED B-51
048516,000190: 13,2504  12,2004               DP1/2              =        XUNIT                                 
048517,000191: 13,2504           17711 05254  B2/A2              2DEC     .9933064884 B-1                        #  GAMMA= B**2/A**2 B-1
048518,000192: 13,2506           00155 25250  EE                 2DEC     6.6935116  E-3                        #  (1-B**2/A**2) B-0
048519,000193: 

Page 1137

048521,000195:                                                                                                  #  ARCTAN SUBROUTINE
048522,000196: 
048523,000197:                                                                                                  #  CALLING SEQUENCE
048524,000198:                                                                                                  #        SIN THETA IN SINTH B-1
048525,000199:                                                                                                  #        COS THETA IN COSTH B-1
048526,000200:                                                                                                  #        CALL ARCTAN
048527,000201: 
048528,000202:                                                                                                  #  OUTPUT
048529,000203:                                                                                                  #        ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
048530,000204: 
048531,000205: 13,2510           77600        ARCTAN             BOV                                            
048532,000206: 13,2511           26512                                    CLROVFLW                              
048533,000207: 13,2512           63545        CLROVFLW           DLOAD    DSQ                                   
048534,000208: 13,2513           00023                                    SINTH                                 
048535,000209: 13,2514           63525                           PDDL     DSQ                                   
048536,000210: 13,2515           00021                                    COSTH                                 
048537,000211: 13,2516           77615                           DAD                                            
048538,000212: 13,2517           75454                           BZE      SQRT                                  
048539,000213: 13,2520           26536                                    ARCTANXX                              #  ATAN=0/0  SET THETA=0
048540,000214: 13,2521           40065                           BDDV     BOV                                   
048541,000215: 13,2522           00023                                    SINTH                                 
048542,000216: 13,2523           26543                                    ATAN=90                               
048543,000217: 13,2524           67542                           SR1      ASIN                                  
048544,000218: 13,2525           00025                           STORE    THETA                                 
048545,000219: 13,2526           50125                           PDDL     BMN                                   
048546,000220: 13,2527           00021                                    COSTH                                 
048547,000221: 13,2530           26532                                    NEGCOS                                
048548,000222: 13,2531           43545                           DLOAD    RVQ                                   
048549,000223: 13,2532           57545        NEGCOS             DLOAD    DCOMP                                 
048550,000224: 13,2533           43244                           BPL      DAD                                   
048551,000225: 13,2534           26540                                    NEGOUT                                
048552,000226: 13,2535           24005                                    DP1/2                                 
048553,000227: 13,2536           00025        ARCTANXX           STORE    THETA                                 
048554,000228: 13,2537           77616                           RVQ                                            
048555,000229: 
048556,000230: 13,2540           52025        NEGOUT             DSU      GOTO                                  
048557,000231: 13,2541           24005                                    DP1/2                                 
048558,000232: 13,2542           26536                                    ARCTANXX                              
048559,000233: 13,2543           75345        ATAN=90            DLOAD    SIGN                                  
048560,000234: 13,2544           11037                                    LODP1/4                               
048561,000235: 13,2545           00023                                    SINTH                                 
048562,000236: 13,2546           00025                           STORE    THETA                                 
048563,000237: 13,2547           77616                           RVQ                                            
048564,000238: 
048565,000239: 13,2550  12,2006               2DZERO             =        DPZERO                                
048566,000240: 

Page 1138

048568,000242:                                                                                                  #  ..... SETGAMMA SUBROUTINE .....
048569,000243:                                                                                                  #  SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
048570,000244: 
048571,000245:                                                                                                  #  GAMMA = B**2/A**2 FOR EARTH (B-1)
048572,000246:                                                                                                  #  GAMMA = 1 FOR MOON (B-1)
048573,000247: 
048574,000248:                                                                                                  #  CALLING SEQUENCE
048575,000249:                                                                                                  #        L       CALL
048576,000250:                                                                                                  #        L+1             SETGAMMA
048577,000251: 
048578,000252:                                                                                                  #  INPUT
048579,000253:                                                                                                  #        LUNAFLAG=0 FOR EARTH, =1 FOR MOON
048580,000254: 
048581,000255:                                                                                                  #  OUTPUT
048582,000256:                                                                                                  #        GAMMA IN GAMRP (B-1)
048583,000257: 
048584,000258: 13,2550           43145        SETGAMMA           DLOAD    BOFF                                  #  BRANCH FOR EARTH
048585,000259: 13,2551           26505                                    B2/A2                                 #  EARTH GAMMA
048586,000260: 13,2552           01743                                    LUNAFLAG                              
048587,000261: 13,2553           26556                                    SETGMEX                               
048588,000262: 13,2554           77735                           SLOAD                                          
048589,000263: 13,2555           24005                                    1B1                                   #  MOON GAMMA
048590,000264: 13,2556           00011        SETGMEX            STORE    GAMRP                                 
048591,000265: 13,2557           77616                           RVQ                                            
048592,000266: 13,2560                        GAMRP              =        8D                                    
048593,000267: 

Page 1139

048595,000269:                                                                                                  #  ..... SETRE SUBROUTINE .....
048596,000270:                                                                                                  #  SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
048597,000271: 
048598,000272:                                                                                                  #        RE = RM FOR MOON
048599,000273:                                                                                                  #        RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
048600,000274: 
048601,000275:                                                                                                  #  CALLING SEQUENCE
048602,000276:                                                                                                  #        L       CALL
048603,000277:                                                                                                  #        L+1             SETRE
048604,000278: 
048605,000279:                                                                                                  #  SUBROUTINES USED
048606,000280:                                                                                                  #        GETERAD
048607,000281: 
048608,000282:                                                                                                  #  INPUT
048609,000283:                                                                                                  #        ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
048610,000284:                                                                                                  #        ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
048611,000285:                                                                                                  #        LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
048612,000286: 
048613,000287:                                                                                                  #  OUTPUT
048614,000288:                                                                                                  #        ERADM = 504RM FOR MOON (METERS B-29)
048615,000289:                                                                                                  #        ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
048616,000290: 
048617,000291: 13,2560           71220        SETRE              STQ      DLOAD                                 
048618,000292: 13,2561           00051                                    SETREX                                
048619,000293: 13,2562           10003                                    504RM                                 
048620,000294: 13,2563           71214                           BON      DLOAD                                 #  BRANCH FOR MOON
048621,000295: 13,2564           01703                                    LUNAFLAG                              
048622,000296: 13,2565           26575                                    TSTRLSRM                              
048623,000297: 13,2566           10001                                    ERAD                                  
048624,000298: 13,2567           45014                           BOFF     CALL                                  #  ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
048625,000299: 13,2570           00742                                    ERADFLAG                              
048626,000300: 13,2571           26573                                    SETRXX                                
048627,000301: 13,2572           26466                                    GETERAD                               
048628,000302: 13,2573           37673        SETRXX             STCALL   ERADM                                 #  EXIT WITH RE OR RM METERS B-29
048629,000303: 13,2574           00051                                    SETREX                                
048630,000304: 13,2575           77214        TSTRLSRM           BON      VLOAD                                 #  ERADFLAG=0, SET R0=RLS
048631,000305: 13,2576           00702                                    ERADFLAG                              #          =1      R0=RM
048632,000306: 13,2577           26573                                    SETRXX                                
048633,000307: 13,2600           02023                                    RLS                                   
048634,000308: 13,2601           64446                           ABVAL    SR2R                                  #  SCALE FROM B-27 TO B-29
048635,000309: 13,2602           77650                           GOTO                                           
048636,000310: 13,2603           26573                                    SETRXX                                
048637,000311: 13,2604  0000051               SETREX             =        S2                                    
048638,000312: 
048639,000313: 

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