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,1969Note that the date is the date of the printout, not the date of the program revision. |
048330,000002: ## Copyright: Public domain.
048331,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
048332,000004: ## Purpose: Part of the source code for Luminary 1A build 099.
048333,000005: ## It is part of the source code for the Lunar Module's (LM)
048334,000006: ## Apollo Guidance Computer (AGC), for Apollo 11.
048335,000007: ##
048336,000008: ## Assembler: yaYUL
048337,000009: ## Contact: Jim Lawton <jim DOT lawton AT gmail DOT com>
048338,000010: ## Website: www.ibiblio.org/apollo.
048339,000011: ## Pages: 1133-1139
048340,000012: ## Mod history: 2009-05-28 JL Updated from page images.
048341,000013: ## 2011-01-06 JL Fixed interpretive indentation.
048342,000014: ## 2016-12-17 RSB Proofed text comments with octopus/ProoferComments
048343,000015: ## and corrected the errors found.
048344,000016: ## 2017-03-15 RSB Comment-text fixes identified in 5-way
048345,000017: ## side-by-side diff of Luminary 69/99/116/131/210.
048346,000018:
048347,000019: ## This source code has been transcribed or otherwise adapted from digitized
048348,000020: ## images of a hardcopy from the MIT Museum. The digitization was performed
048349,000021: ## by Paul Fjeld, and arranged for by Deborah Douglas of the Museum. Many
048350,000022: ## thanks to both. The images (with suitable reduction in storage size and
048351,000023: ## consequent reduction in image quality as well) are available online at
048352,000024: ## www.ibiblio.org/apollo. If for some reason you find that the images are
048353,000025: ## illegible, contact me at info@sandroid.org about getting access to the
048354,000026: ## (much) higher-quality images which Paul actually created.
048355,000027: ##
048356,000028: ## Notations on the hardcopy document read, in part:
048357,000029: ##
048358,000030: ## Assemble revision 001 of AGC program LMY99 by NASA 2021112-061
048359,000031: ## 16:27 JULY 14, 1969
048360,000032:
Page 1133 |
048362,000034: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
048363,000035:
048364,000036: # CALLING SEQUENCE
048365,000037: # L-1 CALL
048366,000038: # L LAT-LONG
048367,000039:
048368,000040: # SUBROUTINES USED
048369,000041: # R-TO-RP, ARCTAN, SETGAMMA, SETRE
048370,000042:
048371,000043: # ERASABLE INIT. REQ.
048372,000044: # AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
048373,000045: # ALPHAV = POSITION VECTOR METERS B-29
048374,000046: # MPAC -- TIME (CSECS B-28)
048375,000047: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
048376,000048: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
048377,000049:
048378,000050: # OUTPUT
048379,000051: # LATITUDE IN LAT (REVS. B-0)
048380,000052: # LONGITUDE IN LONG (REVS. B-0)
048381,000053: # ALTITUDE IN ALT METERS B-29
048382,000054:
048383,000055: 30,3775 BANK 30
048384,000056: 13,2000 SETLOC LATLONG
048385,000057: 13,2000 BANK
048386,000058:
048387,000059: 13,2351 COUNT* $$/LT-LG
048388,000060: 13,2351 E4,1431 EBANK= ALPHAV
048389,000061: 13,2351 40220 LAT-LONG STQ SETPD
048390,000062: 13,2352 03674 INCORPEX
048391,000063: 13,2353 00001 0D
048392,000064: 13,2354 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
048393,000065: 13,2355 02032 ALPHAV
048394,000066: 13,2356 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
048395,000067: 13,2357 16070 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
048396,000068: 13,2360 24007 ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
048397,000069: 13,2361 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
048398,000070: 13,2362 01743 LUNAFLAG # 0=EARTH, 1=MOON
048399,000071: 13,2363 26364 CALLRTRP
048400,000072: 13,2364 77624 CALLRTRP CALL
048401,000073: 13,2365 51670 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
048402,000074: 13,2366 77656 UNIT # UNIT RP B-1
048403,000075: 13,2367 36032 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
048404,000076: 13,2370 26550 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
048405,000077: 13,2371 77624 CALL # SCALED B-1
048406,000078: 13,2372 26560 SETRE # CALC RE METERS B-29
048407,000079: 13,2373 63545 DLOAD DSQ
048408,000080: 13,2374 02032 ALPHAV
048409,000081: 13,2375 63525 PDDL DSQ
048410,000082: 13,2376 02034 ALPHAV +2
048411,000083: 13,2377 75415 DAD SQRT
Page 1134 |
048413,000085: 13,2400 76405 DMP SL1R
048414,000086: 13,2401 00011 GAMRP
048415,000087: 13,2402 14021 STODL COSTH # COS(LAT) B-1
048416,000088: 13,2403 02036 ALPHAV +4
048417,000089: 13,2404 34023 STCALL SINTH # SIN(LAT) B-1
048418,000090: 13,2405 26510 ARCTAN
048419,000091: 13,2406 15121 STODL LAT # LAT B0
048420,000092: 13,2407 02032 ALPHAV
048421,000093: 13,2410 14021 STODL COSTH # COS(LONG) B-1
048422,000094: 13,2411 02034 ALPHAV +2
048423,000095: 13,2412 34023 STCALL SINTH # SIN(LONG) B-1
048424,000096: 13,2413 26510 ARCTAN
048425,000097: 13,2414 15123 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
048426,000098: 13,2415 02070 ALPHAM
048427,000099: 13,2416 77625 DSU # ALT= R-RE METERS B-29
048428,000100: 13,2417 03673 ERADM
048429,000101: 13,2420 35125 STCALL ALT # EXIT WITH ALT METERS B-29
048430,000102: 13,2421 03674 INCORPEX
Page 1135 |
048432,000104: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
048433,000105:
048434,000106: # CALLING SEQUENCE
048435,000107: # L-1 CALL
048436,000108: # L LALOTORV
048437,000109:
048438,000110: # SUBROUTINES USED
048439,000111: # SETGAMMA, SETRE, RP-TO-R
048440,000112:
048441,000113: # ERASABLE INIT. REQ.
048442,000114: # AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
048443,000115: # LAT -- LATITUDE (REVS B0)
048444,000116: # LONG -- LONGITUDE (REVS B0)
048445,000117: # ALT -- ALTITUDE (METERS) B-29
048446,000118: # MPAC -- TIME (CSECS B-28)
048447,000119: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
048448,000120: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
048449,000121:
048450,000122: # OUTPUT
048451,000123: # R-VECTOR IN ALPHAV (METERS B-29)
048452,000124:
048453,000125: 13,2422 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
048454,000126: 13,2423 03674 INCORPEX
048455,000127: 13,2424 00001 0D
048456,000128: 13,2425 34007 STCALL 6D # 6-7D= TIME FOR RP-TO-R
048457,000129: 13,2426 26550 SETGAMMA # GAMMA=B2/A2 FOR EARTH, 1 FOR MOON B-1
048458,000130: 13,2427 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
048459,000131: 13,2430 01121 LAT # UNIT RP = SIN(LONG)COS(LAT) 2-3D
048460,000132: 13,2431 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
048461,000133: 13,2432 00011 GAMRP
048462,000134: 13,2433 01121 LAT # 0-1D = GAMMA*SIN(LAT) B-2
048463,000135: 13,2434 65346 COS PDDL # PD4 2-3D = COS(LAT) B-1 TEMPORARILY
048464,000136: 13,2435 01123 LONG
048465,000137: 13,2436 57356 SIN DMPR # PD 2
048466,000138: 13,2437 71525 PDDL COS # PD 4 2-3D = SIN(LONG)COS(LAT) B-2
048467,000139: 13,2440 01121 LAT
048468,000140: 13,2441 71525 PDDL COS # PD 6 4-5D = COS(LAT) B-1 TEMPORARILY
048469,000141: 13,2442 01123 LONG
048470,000142: 13,2443 55475 DMPR VDEF # PD 4 MPAC = COS(LONG)COS(LAT) B-2
048471,000143: 13,2444 41456 UNIT PUSH # 0-5D= UNIT RP FOR RP-TO-R SUBR.
048472,000144: 13,2445 36032 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
048473,000145: 13,2446 26560 SETRE # RE METERS B-29
048474,000146: 13,2447 43145 DLOAD BOFF # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
048475,000147: 13,2450 24007 ZEROVEC
048476,000148: 13,2451 01743 LUNAFLAG
048477,000149: 13,2452 26454 CALLRPRT
048478,000150: 13,2453 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
048479,000151: 13,2454 77624 CALLRPRT CALL
048480,000152: 13,2455 55716 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
048481,000153: 13,2456 16032 STODL ALPHAV
048482,000154: 13,2457 03673 ERADM
Page 1136 |
048484,000156: 13,2460 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
048485,000157: 13,2461 01125 ALT
048486,000158: 13,2462 02032 ALPHAV
048487,000159: 13,2463 77772 VSL1 # R METERS B-29
048488,000160: 13,2464 36032 STCALL ALPHAV # EXIT WITH R IN METERS B-29
048489,000161: 13,2465 03674 INCORPEX
048490,000162:
048491,000163: # SUBROUTINE TO COMPUTE EARTH RADIUS
048492,000164:
048493,000165: # INPUT
048494,000166: # 1/2 SIN LAT IN ALPHAV +4
048495,000167:
048496,000168: # OUTPUT
048497,000169: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
048498,000170:
048499,000171: 13,2466 63545 GETERAD DLOAD DSQ
048500,000172: 13,2467 02036 ALPHAV +4 # SIN**2(L)
048501,000173: 13,2470 44352 SL1 BDSU
048502,000174: 13,2471 24005 DP1/2 # COS**2(L)
048503,000175: 13,2472 44275 DMPR BDSU
048504,000176: 13,2473 26507 EE
048505,000177: 13,2474 24005 DP1/2
048506,000178: 13,2475 75465 BDDV SQRT
048507,000179: 13,2476 26503 B2XSC
048508,000180: 13,2477 77622 SR4R
048509,000181: 13,2500 03673 STORE ERADM
048510,000182: 13,2501 77616 RVQ
048511,000183:
048512,000184: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
048513,000185: # B2XSC = B**2 SCALED B-51
048514,000186: # B2/A2 = B**2/A**2 SCALED B-1
048515,000187: # EE = (1-B**2/A**2) SCALED B-0
048516,000188:
048517,000189: 13,2502 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
048518,000190: 13,2504 12,2004 DP1/2 = XUNIT
048519,000191: 13,2504 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
048520,000192: 13,2506 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
048521,000193:
Page 1137 |
048523,000195: # ARCTAN SUBROUTINE
048524,000196:
048525,000197: # CALLING SEQUENCE
048526,000198: # SIN THETA IN SINTH B-1
048527,000199: # COS THETA IN COSTH B-1
048528,000200: # CALL ARCTAN
048529,000201:
048530,000202: # OUTPUT
048531,000203: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
048532,000204:
048533,000205: 13,2510 77600 ARCTAN BOV
048534,000206: 13,2511 26512 CLROVFLW
048535,000207: 13,2512 63545 CLROVFLW DLOAD DSQ
048536,000208: 13,2513 00023 SINTH
048537,000209: 13,2514 63525 PDDL DSQ
048538,000210: 13,2515 00021 COSTH
048539,000211: 13,2516 77615 DAD
048540,000212: 13,2517 75454 BZE SQRT
048541,000213: 13,2520 26536 ARCTANXX # ATAN=0/0 SET THETA=0
048542,000214: 13,2521 40065 BDDV BOV
048543,000215: 13,2522 00023 SINTH
048544,000216: 13,2523 26543 ATAN=90
048545,000217: 13,2524 67542 SR1 ASIN
048546,000218: 13,2525 00025 STORE THETA
048547,000219: 13,2526 50125 PDDL BMN
048548,000220: 13,2527 00021 COSTH
048549,000221: 13,2530 26532 NEGCOS
048550,000222: 13,2531 43545 DLOAD RVQ
048551,000223: 13,2532 57545 NEGCOS DLOAD DCOMP
048552,000224: 13,2533 43244 BPL DAD
048553,000225: 13,2534 26540 NEGOUT
048554,000226: 13,2535 24005 DP1/2
048555,000227: 13,2536 00025 ARCTANXX STORE THETA
048556,000228: 13,2537 77616 RVQ
048557,000229:
048558,000230: 13,2540 52025 NEGOUT DSU GOTO
048559,000231: 13,2541 24005 DP1/2
048560,000232: 13,2542 26536 ARCTANXX
048561,000233: 13,2543 75345 ATAN=90 DLOAD SIGN
048562,000234: 13,2544 11037 LODP1/4
048563,000235: 13,2545 00023 SINTH
048564,000236: 13,2546 00025 STORE THETA
048565,000237: 13,2547 77616 RVQ
048566,000238:
048567,000239: 13,2550 12,2006 2DZERO = DPZERO
048568,000240:
Page 1138 |
048570,000242: # ..... SETGAMMA SUBROUTINE .....
048571,000243: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
048572,000244:
048573,000245: # GAMMA = B**2/A**2 FOR EARTH (B-1)
048574,000246: # GAMMA = 1 FOR MOON (B-1)
048575,000247:
048576,000248: # CALLING SEQUENCE
048577,000249: # L CALL
048578,000250: # L+1 SETGAMMA
048579,000251:
048580,000252: # INPUT
048581,000253: # LUNAFLAG=0 FOR EARTH, =1 FOR MOON
048582,000254:
048583,000255: # OUTPUT
048584,000256: # GAMMA IN GAMRP (B-1)
048585,000257:
048586,000258: 13,2550 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
048587,000259: 13,2551 26505 B2/A2 # EARTH GAMMA
048588,000260: 13,2552 01743 LUNAFLAG
048589,000261: 13,2553 26556 SETGMEX
048590,000262: 13,2554 77735 SLOAD
048591,000263: 13,2555 24005 1B1 # MOON GAMMA
048592,000264: 13,2556 00011 SETGMEX STORE GAMRP
048593,000265: 13,2557 77616 RVQ
048594,000266: 13,2560 GAMRP = 8D
048595,000267:
Page 1139 |
048597,000269: # ..... SETRE SUBROUTINE .....
048598,000270: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
048599,000271:
048600,000272: # RE = RM FOR MOON
048601,000273: # RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
048602,000274:
048603,000275: # CALLING SEQUENCE
048604,000276: # L CALL
048605,000277: # L+1 SETRE
048606,000278:
048607,000279: # SUBROUTINES USED
048608,000280: # GETERAD
048609,000281:
048610,000282: # INPUT
048611,000283: # ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
048612,000284: # ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
048613,000285: # LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
048614,000286:
048615,000287: # OUTPUT
048616,000288: # ERADM = 504RM FOR MOON (METERS B-29)
048617,000289: # ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
048618,000290:
048619,000291: 13,2560 71220 SETRE STQ DLOAD
048620,000292: 13,2561 00051 SETREX
048621,000293: 13,2562 10003 504RM
048622,000294: 13,2563 71214 BON DLOAD # BRANCH FOR MOON
048623,000295: 13,2564 01703 LUNAFLAG
048624,000296: 13,2565 26575 TSTRLSRM
048625,000297: 13,2566 10001 ERAD
048626,000298: 13,2567 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
048627,000299: 13,2570 00742 ERADFLAG
048628,000300: 13,2571 26573 SETRXX
048629,000301: 13,2572 26466 GETERAD
048630,000302: 13,2573 37673 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
048631,000303: 13,2574 00051 SETREX
048632,000304: 13,2575 77214 TSTRLSRM BON VLOAD # ERADFLAG=0, SET R0=RLS
048633,000305: 13,2576 00702 ERADFLAG # =1 R0=RM
048634,000306: 13,2577 26573 SETRXX
048635,000307: 13,2600 02023 RLS
048636,000308: 13,2601 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
048637,000309: 13,2602 77650 GOTO
048638,000310: 13,2603 26573 SETRXX
048639,000311: 13,2604 0000051 SETREX = S2
048640,000312:
048641,000313:
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc