Source Code
This is a reconstructed version of Luminary 130, the initial AGC program released
in November 1969 for the Apollo 13 LM. Three more releases
followed before the flown revision was finally manufactured in February 1970.
This reconstruction was created from a previous transcription of the original listing of Luminary 131, combined with Luminary memo #129 which describes the small difference between the Luminary 130 and 131. The reconstructed source code was verified by matching memory-bank checksums to those listed for Luminary 130 in drawing 2021152G. In this source code, program comments from the original (Luminary 131) code are prefixed with '#', while those added later by the Virtual AGC project are prefixed with '##'. |
047471,000002: ## Copyright: Public domain.
047472,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
047473,000004: ## Purpose: A section of the reconstructed source code for Luminary 130.
047474,000005: ## This was the original program released for the Apollo 13 LM,
047475,000006: ## although several more revisions would follow. It has been
047476,000007: ## reconstructed from a listing of Luminary 131, from which it
047477,000008: ## differs on only two lines in P70-P71. The difference is
047478,000009: ## described in detail in Luminary memo #129, which was used
047479,000010: ## to perform the reconstruction. This file is intended to be a
047480,000011: ## faithful reconstruction, except that the code format has been
047481,000012: ## changed to conform to the requirements of the yaYUL assembler
047482,000013: ## rather than the original YUL assembler.
047483,000014: ## Reference: pp. 1127-1133
047484,000015: ## Contact: Ron Burkey <info@sandroid.org>.
047485,000016: ## Website: www.ibiblio.org/apollo/index.html
047486,000017: ## Mod history: 05/31/03 RSB. Began transcribing.
047487,000018: ## 05/14/05 RSB Corrected website reference above.
047488,000019: ## 2011-01-05 JL Fixed indentation of RVQ instruction.
047489,000020: ## 2017-01-06 RSB Page numbers now agree with those on the
047490,000021: ## original harcopy, as opposed to the PDF page
047491,000022: ## numbers in 1701.pdf.
047492,000023: ## 2017-02-05 RSB Back-ported comment corrections
047493,000024: ## identified while proofing Artemis 072.
047494,000025: ## 2017-02-27 RSB Proofed comment text using octopus/ProoferComments.
047495,000026: ## 2017-03-13 RSB Comment-text fixes noted in proofing Luminary 116.
047496,000027: ## 2017-03-15 RSB Comment-text fixes identified in 5-way
047497,000028: ## side-by-side diff of Luminary 69/99/116/131/210.
047498,000029: ## 2018-09-04 MAS Copied from Luminary 131 for Luminary 130.
047499,000030:
Page 1127 |
047501,000032: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
047502,000033:
047503,000034: # CALLING SEQUENCE
047504,000035: # L-1 CALL
047505,000036: # L LAT-LONG
047506,000037:
047507,000038: # SUBROUTINES USED
047508,000039: # R-TO-RP, ARCTAN, SETGAMMA, SETRE
047509,000040:
047510,000041: # ERASABLE INIT. REQ.
047511,000042: # AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
047512,000043: # ALPHAV = POSITION VECTOR METERS B-29
047513,000044: # MPAC -- TIME (CSECS B-28)
047514,000045: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
047515,000046: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
047516,000047:
047517,000048: # OUTPUT
047518,000049: # LATITUDE IN LAT (REVS. B-0)
047519,000050: # LONGITUDE IN LONG (REVS. B-0)
047520,000051: # ALTITUDE IN ALT METERS B-29
047521,000052:
047522,000053: 30,3766 BANK 30
047523,000054: 13,2000 SETLOC LATLONG
047524,000055: 13,2000 BANK
047525,000056:
047526,000057: 13,2347 COUNT* $$/LT-LG
047527,000058: 13,2347 E4,1431 EBANK= ALPHAV
047528,000059: 13,2347 40220 LAT-LONG STQ SETPD
047529,000060: 13,2350 03674 INCORPEX
047530,000061: 13,2351 00001 0D
047531,000062: 13,2352 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
047532,000063: 13,2353 02032 ALPHAV
047533,000064: 13,2354 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
047534,000065: 13,2355 16070 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
047535,000066: 13,2356 24007 ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
047536,000067: 13,2357 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
047537,000068: 13,2360 01743 LUNAFLAG # 0=EARTH, 1=MOON
047538,000069: 13,2361 26362 CALLRTRP
047539,000070: 13,2362 77624 CALLRTRP CALL
047540,000071: 13,2363 51700 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
047541,000072: 13,2364 77656 UNIT # UNIT RP B-1
047542,000073: 13,2365 36032 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
047543,000074: 13,2366 26546 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
047544,000075: 13,2367 77624 CALL # SCALED B-1
047545,000076: 13,2370 26556 SETRE # CALC RE METERS B-29
047546,000077: 13,2371 63545 DLOAD DSQ
047547,000078: 13,2372 02032 ALPHAV
047548,000079: 13,2373 63525 PDDL DSQ
047549,000080: 13,2374 02034 ALPHAV +2
047550,000081: 13,2375 75415 DAD SQRT
Page 1128 |
047552,000083: 13,2376 76405 DMP SL1R
047553,000084: 13,2377 00011 GAMRP
047554,000085: 13,2400 14021 STODL COSTH # COS(LAT) B-1
047555,000086: 13,2401 02036 ALPHAV +4
047556,000087: 13,2402 34023 STCALL SINTH # SIN(LAT) B-1
047557,000088: 13,2403 26506 ARCTAN
047558,000089: 13,2404 15120 STODL LAT # LAT B0
047559,000090: 13,2405 02032 ALPHAV
047560,000091: 13,2406 14021 STODL COSTH # COS(LONG) B-1
047561,000092: 13,2407 02034 ALPHAV +2
047562,000093: 13,2410 34023 STCALL SINTH # SIN(LONG) B-1
047563,000094: 13,2411 26506 ARCTAN
047564,000095: 13,2412 15122 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
047565,000096: 13,2413 02070 ALPHAM
047566,000097: 13,2414 77625 DSU # ALT= R-RE METERS B-29
047567,000098: 13,2415 03673 ERADM
047568,000099: 13,2416 35124 STCALL ALT # EXIT WITH ALT METERS B-29
047569,000100: 13,2417 03674 INCORPEX
Page 1129 |
047571,000102: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
047572,000103:
047573,000104: # CALLING SEQUENCE
047574,000105: # L-1 CALL
047575,000106: # L LALOTORV
047576,000107:
047577,000108: # SUBROUTINES USED
047578,000109: # SETGAMMA, SETRE, RP-TO-R
047579,000110:
047580,000111: # ERASABLE INIT. REQ.
047581,000112: # AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
047582,000113: # LAT -- LATITUDE (REVS B0)
047583,000114: # LONG -- LONGITUDE (REVS B0)
047584,000115: # ALT -- ALTITUDE (METERS) B-29
047585,000116: # MPAC -- TIME (CSECS B-28)
047586,000117: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
047587,000118: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
047588,000119:
047589,000120: # OUTPUT
047590,000121: # R-VECTOR IN ALPHAV (METERS B-29)
047591,000122:
047592,000123: 13,2420 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
047593,000124: 13,2421 03674 INCORPEX
047594,000125: 13,2422 00001 0D
047595,000126: 13,2423 34007 STCALL 6D # 6-7D= TIME FOR RP-TO-R
047596,000127: 13,2424 26546 SETGAMMA # GAMMA=B2/A2 FOR EARTH, 1 FOR MOON B-1
047597,000128: 13,2425 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
047598,000129: 13,2426 01120 LAT # UNIT RP = SIN(LONG)COS(LAT) 2-3D
047599,000130: 13,2427 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
047600,000131: 13,2430 00011 GAMRP
047601,000132: 13,2431 01120 LAT # 0-1D= GAMMA*SIN(LAT) B-2
047602,000133: 13,2432 65346 COS PDDL # PD4 2-3D= COS(LAT) B-1 TEMPORARILY
047603,000134: 13,2433 01122 LONG
047604,000135: 13,2434 57356 SIN DMPR # PD 2
047605,000136: 13,2435 71525 PDDL COS # PD 4 2-3D = SIN(LONG)COS(LAT) B-2
047606,000137: 13,2436 01120 LAT
047607,000138: 13,2437 71525 PDDL COS # PD 6 4-5D = COS(LAT) B-1 TEMPORARILY
047608,000139: 13,2440 01122 LONG
047609,000140: 13,2441 55475 DMPR VDEF # PD4 MPAC= COS(LONG)COS(LAT) B-2
047610,000141: 13,2442 41456 UNIT PUSH # 0-5D= UNIT RP FOR RP-TO-R SUBR.
047611,000142: 13,2443 36032 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
047612,000143: 13,2444 26556 SETRE # RE METERS B-29
047613,000144: 13,2445 43145 DLOAD BOFF # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
047614,000145: 13,2446 24007 ZEROVEC
047615,000146: 13,2447 01743 LUNAFLAG
047616,000147: 13,2450 26452 CALLRPRT
047617,000148: 13,2451 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
047618,000149: 13,2452 77624 CALLRPRT CALL
047619,000150: 13,2453 55716 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
047620,000151: 13,2454 16032 STODL ALPHAV
047621,000152: 13,2455 03673 ERADM
Page 1130 |
047623,000154: 13,2456 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
047624,000155: 13,2457 01124 ALT
047625,000156: 13,2460 02032 ALPHAV
047626,000157: 13,2461 77772 VSL1 # R METERS B-29
047627,000158: 13,2462 36032 STCALL ALPHAV # EXIT WITH R IN METERS B-29
047628,000159: 13,2463 03674 INCORPEX
047629,000160:
047630,000161: # SUBROUTINE TO COMPUTE EARTH RADIUS
047631,000162:
047632,000163: # INPUT
047633,000164: # 1/2 SIN LAT IN ALPHAV +4
047634,000165:
047635,000166: # OUTPUT
047636,000167: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
047637,000168:
047638,000169: 13,2464 63545 GETERAD DLOAD DSQ
047639,000170: 13,2465 02036 ALPHAV +4 # SIN**2(L)
047640,000171: 13,2466 44352 SL1 BDSU
047641,000172: 13,2467 24005 DP1/2 # COS**2(L)
047642,000173: 13,2470 44275 DMPR BDSU
047643,000174: 13,2471 26505 EE
047644,000175: 13,2472 24005 DP1/2
047645,000176: 13,2473 75465 BDDV SQRT
047646,000177: 13,2474 26501 B2XSC
047647,000178: 13,2475 77622 SR4R
047648,000179: 13,2476 03673 STORE ERADM
047649,000180: 13,2477 77616 RVQ
047650,000181:
047651,000182: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
047652,000183: # B2XSC = B**2 SCALED B-51
047653,000184: # B2/A2 = B**2/A**2 SCALED B-1
047654,000185: # EE = (1-B**2/A**2) SCALED B-0
047655,000186:
047656,000187: 13,2500 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
047657,000188: 13,2502 12,2004 DP1/2 = XUNIT
047658,000189: 13,2502 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
047659,000190: 13,2504 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
047660,000191:
Page 1131 |
047662,000193: # ARCTAN SUBROUTINE
047663,000194:
047664,000195: # CALLING SEQUENCE
047665,000196: # SIN THETA IN SINTH B-1
047666,000197: # COS THETA IN COSTH B-1
047667,000198: # CALL ARCTAN
047668,000199:
047669,000200: # OUTPUT
047670,000201: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
047671,000202:
047672,000203: 13,2506 77600 ARCTAN BOV
047673,000204: 13,2507 26510 CLROVFLW
047674,000205: 13,2510 63545 CLROVFLW DLOAD DSQ
047675,000206: 13,2511 00023 SINTH
047676,000207: 13,2512 63525 PDDL DSQ
047677,000208: 13,2513 00021 COSTH
047678,000209: 13,2514 77615 DAD
047679,000210: 13,2515 75454 BZE SQRT
047680,000211: 13,2516 26534 ARCTANXX # ATAN=0/0 SET THETA=0
047681,000212: 13,2517 40065 BDDV BOV
047682,000213: 13,2520 00023 SINTH
047683,000214: 13,2521 26541 ATAN=90
047684,000215: 13,2522 67542 SR1 ASIN
047685,000216: 13,2523 00025 STORE THETA
047686,000217: 13,2524 50125 PDDL BMN
047687,000218: 13,2525 00021 COSTH
047688,000219: 13,2526 26530 NEGCOS
047689,000220: 13,2527 43545 DLOAD RVQ
047690,000221: 13,2530 57545 NEGCOS DLOAD DCOMP
047691,000222: 13,2531 43244 BPL DAD
047692,000223: 13,2532 26536 NEGOUT
047693,000224: 13,2533 24005 DP1/2
047694,000225: 13,2534 00025 ARCTANXX STORE THETA
047695,000226: 13,2535 77616 RVQ
047696,000227:
047697,000228: 13,2536 52025 NEGOUT DSU GOTO
047698,000229: 13,2537 24005 DP1/2
047699,000230: 13,2540 26534 ARCTANXX
047700,000231: 13,2541 75345 ATAN=90 DLOAD SIGN
047701,000232: 13,2542 11003 LODP1/4
047702,000233: 13,2543 00023 SINTH
047703,000234: 13,2544 00025 STORE THETA
047704,000235: 13,2545 77616 RVQ
047705,000236:
047706,000237: 13,2546 12,2006 2DZERO = DPZERO
047707,000238:
Page 1132 |
047709,000240: # ..... SETGAMMA SUBROUTINE .....
047710,000241: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
047711,000242:
047712,000243: # GAMMA = B**2/A**2 FOR EARTH (B-1)
047713,000244: # GAMMA = 1 FOR MOON (B-1)
047714,000245:
047715,000246: # CALLING SEQUENCE
047716,000247: # L CALL
047717,000248: # L+1 SETGAMMA
047718,000249:
047719,000250: # INPUT
047720,000251: # LUNAFLAG=0 FOR EARTH, =1 FOR MOON
047721,000252:
047722,000253: # OUTPUT
047723,000254: # GAMMA IN GAMRP (B-1)
047724,000255:
047725,000256: 13,2546 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
047726,000257: 13,2547 26503 B2/A2 # EARTH GAMMA
047727,000258: 13,2550 01743 LUNAFLAG
047728,000259: 13,2551 26554 SETGMEX
047729,000260: 13,2552 77735 SLOAD
047730,000261: 13,2553 24005 1B1 # MOON GAMMA
047731,000262: 13,2554 00011 SETGMEX STORE GAMRP
047732,000263: 13,2555 77616 RVQ
047733,000264: 13,2556 GAMRP = 8D
047734,000265:
Page 1133 |
047736,000267: # ..... SETRE SUBROUTINE .....
047737,000268: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
047738,000269:
047739,000270: # RE = RM FOR MOON
047740,000271: # RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
047741,000272:
047742,000273: # CALLING SEQUENCE
047743,000274: # L CALL
047744,000275: # L+1 SETRE
047745,000276:
047746,000277: # SUBROUTINES USED
047747,000278: # GETERAD
047748,000279:
047749,000280: # INPUT
047750,000281: # ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
047751,000282: # ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
047752,000283: # LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
047753,000284:
047754,000285: # OUTPUT
047755,000286: # ERADM = 504RM FOR MOON (METERS B-29)
047756,000287: # ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
047757,000288:
047758,000289: 13,2556 71220 SETRE STQ DLOAD
047759,000290: 13,2557 00051 SETREX
047760,000291: 13,2560 10003 504RM
047761,000292: 13,2561 71214 BON DLOAD # BRANCH FOR MOON
047762,000293: 13,2562 01703 LUNAFLAG
047763,000294: 13,2563 26573 TSTRLSRM
047764,000295: 13,2564 10001 ERAD
047765,000296: 13,2565 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
047766,000297: 13,2566 00742 ERADFLAG
047767,000298: 13,2567 26571 SETRXX
047768,000299: 13,2570 26464 GETERAD
047769,000300: 13,2571 37673 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
047770,000301: 13,2572 00051 SETREX
047771,000302: 13,2573 77214 TSTRLSRM BON VLOAD # ERADFLAG=0, SET R0=RLS
047772,000303: 13,2574 00702 ERADFLAG # =1 R0=RM
047773,000304: 13,2575 26571 SETRXX
047774,000305: 13,2576 02023 RLS
047775,000306: 13,2577 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
047776,000307: 13,2600 77650 GOTO
047777,000308: 13,2601 26571 SETRXX
047778,000309: 13,2602 0000051 SETREX = S2
047779,000310:
047780,000311:
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc