Source Code
These source-code files derive from a printout of Luminary 116 (the Apollo 12
Lunar Module guidance computer program), from the personal library of
original AGC developer Don Eyles, digitally photographed at archive.org,
financially sponsored by Ron Burkey, and transcribed to source code by a
team of volunteers. This colorized, syntax-highlighted form was created
by assembling that transcribed source code. Note that the full page images
are available on the
Virtual AGC project page at archive.org, while reduced-size images
are presented at the VirtualAGC project website. Report or fix any
transcription errors at
the Virtual AGC project code repository. Notations on the program listing read, in part: GAP: ASSEMBLE REVISION 116 OF AGC PROGRAM LUMINARY BY NASA 2021112-071 19:09 AUG. 11,1969Note that the date is the date of the printout, not the date of the program revision. |
047515,000002: ## Copyright: Public domain.
047516,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
047517,000004: ## Purpose: A section of Luminary revision 116.
047518,000005: ## It is part of the source code for the Lunar Module's (LM)
047519,000006: ## Apollo Guidance Computer (AGC) for Apollo 12.
047520,000007: ## This file is intended to be a faithful transcription, except
047521,000008: ## that the code format has been changed to conform to the
047522,000009: ## requirements of the yaYUL assembler rather than the
047523,000010: ## original YUL assembler.
047524,000011: ## Reference: pp. 1125-1131
047525,000012: ## Assembler: yaYUL
047526,000013: ## Contact: Ron Burkey <info@sandroid.org>.
047527,000014: ## Website: www.ibiblio.org/apollo/index.html
047528,000015: ## Mod history: 2017-01-22 MAS Created from Luminary 99.
047529,000016: ## 2017-01-28 RRB Updated for Luminary 116.
047530,000017: ## 2017-03-13 RSB Proofed comment text via 3-way diff vs
047531,000018: ## Luminary 99 and 131 ... no problems found.
047532,000019: ## 2017-03-15 RSB Comment-text fixes identified in 5-way
047533,000020: ## side-by-side diff of Luminary 69/99/116/131/210.
047534,000021:
Page 1125 |
047536,000023: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
047537,000024:
047538,000025: # CALLING SEQUENCE
047539,000026:
047540,000027: # L-1 CALL
047541,000028: # L LAT-LONG
047542,000029: # SUBROUTINES USED
047543,000030:
047544,000031: # R-TO-RP,ARCTAN,SETGAMMA,SETRE
047545,000032: # ERASABLE INIT. REQ.
047546,000033:
047547,000034: # AXO,-AYO,AZO,TEPHEM (SET AT LAUNCH TIME)
047548,000035: # ALPHAV = POSITION VECTOR METERS B-29
047549,000036: # MPAC-- TIME (CSECS B-28)
047550,000037: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
047551,000038: # LUNAFLAG=0 FOR EARTH,1 FOR MOON
047552,000039: # OUTPUT
047553,000040:
047554,000041: # LATITUDE IN LAT (REVS. B-0)
047555,000042: # LONGITUDE IN LONG (REVS. B-0)
047556,000043: # ALTITUDE IN ALT METERS B-29
047557,000044:
047558,000045: 30,3762 BANK 30
047559,000046: 13,2000 SETLOC LATLONG
047560,000047: 13,2000 BANK
047561,000048:
047562,000049: 13,2351 COUNT* $$/LT-LG
047563,000050: 13,2351 E4,1431 EBANK= ALPHAV
047564,000051: 13,2351 40220 LAT-LONG STQ SETPD
047565,000052: 13,2352 03674 INCORPEX
047566,000053: 13,2353 00001 0D
047567,000054: 13,2354 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
047568,000055: 13,2355 02032 ALPHAV
047569,000056: 13,2356 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
047570,000057: 13,2357 16070 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
047571,000058: 13,2360 24007 ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
047572,000059: 13,2361 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
047573,000060: 13,2362 01743 LUNAFLAG # 0=EARTH, 1=MOON
047574,000061: 13,2363 26364 CALLRTRP
047575,000062: 13,2364 77624 CALLRTRP CALL
047576,000063: 13,2365 51677 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
047577,000064: 13,2366 77656 UNIT # UNIT RP B-1
047578,000065: 13,2367 36032 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
047579,000066: 13,2370 26550 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
047580,000067: 13,2371 77624 CALL # SCALED B-1
047581,000068: 13,2372 26560 SETRE # CALC RE METERS B-29
047582,000069: 13,2373 63545 DLOAD DSQ
047583,000070: 13,2374 02032 ALPHAV
047584,000071: 13,2375 63525 PDDL DSQ
047585,000072: 13,2376 02034 ALPHAV +2
047586,000073: 13,2377 75415 DAD SQRT
Page 1126 |
047588,000075: 13,2400 76405 DMP SL1R
047589,000076: 13,2401 00011 GAMRP
047590,000077: 13,2402 14021 STODL COSTH # COS(LAT) B-1
047591,000078: 13,2403 02036 ALPHAV +4
047592,000079: 13,2404 34023 STCALL SINTH # SIN(LAT) B-1
047593,000080: 13,2405 26510 ARCTAN
047594,000081: 13,2406 15120 STODL LAT # LAT B0
047595,000082: 13,2407 02032 ALPHAV
047596,000083: 13,2410 14021 STODL COSTH # COS(LONG) B-1
047597,000084: 13,2411 02034 ALPHAV +2
047598,000085: 13,2412 34023 STCALL SINTH # SIN(LONG) B-1
047599,000086: 13,2413 26510 ARCTAN
047600,000087: 13,2414 15122 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
047601,000088: 13,2415 02070 ALPHAM
047602,000089: 13,2416 77625 DSU # ALT= R-RE METERS B-29
047603,000090: 13,2417 03673 ERADM
047604,000091: 13,2420 35124 STCALL ALT # EXIT WITH ALT METERS B-29
047605,000092: 13,2421 03674 INCORPEX
Page 1127 |
047607,000094: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
047608,000095:
047609,000096: # CALLING SEQUENCE
047610,000097:
047611,000098: # L-1 CALL
047612,000099: # L LALOTORV
047613,000100: # SUBROUTINES USED
047614,000101:
047615,000102: # SETGAMMA,SETRE,RP-TO-R
047616,000103: # ERASABLE INIT. REQ.
047617,000104:
047618,000105: # AXO,AYO,AZO,TEPHEM SET AT LAUNCH TIME
047619,000106: # LAT-- LATITUDE (REVS B0)
047620,000107: # LONG-- LONGITUDE (REVS B0)
047621,000108: # ALT--ALTITUDE (METERS) B-29
047622,000109: # MPAC-- TIME (CSECS B-28)
047623,000110: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
047624,000111: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
047625,000112:
047626,000113: # OUTPUT
047627,000114:
047628,000115: # R-VECTOR IN ALPHAV (METERS B-29)
047629,000116:
047630,000117: 13,2422 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
047631,000118: 13,2423 03674 INCORPEX
047632,000119: 13,2424 00001 0D
047633,000120: 13,2425 34007 STCALL 6D # 6-7D= TIME FOR RP-TO-R
047634,000121: 13,2426 26550 SETGAMMA # GAMMA=B2/A2 FOR EARTH, 1 FOR MOON B-1
047635,000122: 13,2427 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
047636,000123: 13,2430 01120 LAT # UNIT RP= SIN(LONG)COS(LAT) 2-3D
047637,000124: 13,2431 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
047638,000125: 13,2432 00011 GAMRP
047639,000126: 13,2433 01120 LAT # 0-1D= GAMMA*SIN(LAT) B-2
047640,000127: 13,2434 65346 COS PDDL # PD4 2-3D=COS(LAT) B-1 TEMPORARILY
047641,000128: 13,2435 01122 LONG
047642,000129: 13,2436 57356 SIN DMPR # PD 2
047643,000130: 13,2437 71525 PDDL COS # PD 4 2-3D=SIN(LONG)COS(LAT) B-2
047644,000131: 13,2440 01120 LAT
047645,000132: 13,2441 71525 PDDL COS # PD 6 4-5D=COS(LAT) B-1 TEMPORARILY
047646,000133: 13,2442 01122 LONG
047647,000134: 13,2443 55475 DMPR VDEF # PD 4 MPAC= COS(LONG)COS(LAT) B-2
047648,000135: 13,2444 41456 UNIT PUSH # 0-5D= UNIT RP FOR RP-TO-R SUBR.
047649,000136: 13,2445 36032 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
047650,000137: 13,2446 26560 SETRE # RE METERS B-29
047651,000138: 13,2447 43145 DLOAD BOFF # SET MPAC=0 FOR EARTH,NON-ZERO FOR MOON
047652,000139: 13,2450 24007 ZEROVEC
047653,000140: 13,2451 01743 LUNAFLAG
047654,000141: 13,2452 26454 CALLRPRT
047655,000142: 13,2453 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
047656,000143: 13,2454 77624 CALLRPRT CALL
047657,000144: 13,2455 55716 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
047658,000145: 13,2456 16032 STODL ALPHAV
047659,000146: 13,2457 03673 ERADM
Page 1128 |
047661,000148: 13,2460 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
047662,000149: 13,2461 01124 ALT
047663,000150: 13,2462 02032 ALPHAV
047664,000151: 13,2463 77772 VSL1 # R METERS B-29
047665,000152: 13,2464 36032 STCALL ALPHAV # EXIT WITH R IN METERS B-29
047666,000153: 13,2465 03674 INCORPEX
047667,000154:
047668,000155: # SUBROUTINE TO COMPUTE EARTH RADIUS
047669,000156:
047670,000157: # INPUT
047671,000158:
047672,000159: # 1/2 SIN LAT IN ALPHAV +4
047673,000160:
047674,000161: # OUTPUT
047675,000162:
047676,000163: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
047677,000164:
047678,000165: 13,2466 63545 GETERAD DLOAD DSQ
047679,000166: 13,2467 02036 ALPHAV +4 # SIN**2(L)
047680,000167: 13,2470 44352 SL1 BDSU
047681,000168: 13,2471 24005 DP1/2 # COS**2(L)
047682,000169: 13,2472 44275 DMPR BDSU
047683,000170: 13,2473 26507 EE
047684,000171: 13,2474 24005 DP1/2
047685,000172: 13,2475 75465 BDDV SQRT
047686,000173: 13,2476 26503 B2XSC
047687,000174: 13,2477 77622 SR4R
047688,000175: 13,2500 03673 STORE ERADM
047689,000176: 13,2501 77616 RVQ
047690,000177:
047691,000178: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
047692,000179: # B2XSC = B**2 SCALED B-51
047693,000180: # B2/A2 = B**2/A**2 SCALED B-1
047694,000181: # EE = (1-B**2/A**2) SCALED B-0
047695,000182:
047696,000183: 13,2502 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
047697,000184: 13,2504 12,2004 DP1/2 = XUNIT
047698,000185: 13,2504 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
047699,000186: 13,2506 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
047700,000187:
Page 1129 |
047702,000189: # ARCTAN SUBROUTINE
047703,000190:
047704,000191: # CALLING SEQUENCE
047705,000192:
047706,000193: # SIN THETA IN SINTH B-1
047707,000194: # COS THETA IN COSTH B-1
047708,000195: # CALL ARCTAN
047709,000196:
047710,000197: # OUTPUT
047711,000198: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
047712,000199:
047713,000200: 13,2510 77600 ARCTAN BOV
047714,000201: 13,2511 26512 CLROVFLW
047715,000202: 13,2512 63545 CLROVFLW DLOAD DSQ
047716,000203: 13,2513 00023 SINTH
047717,000204: 13,2514 63525 PDDL DSQ
047718,000205: 13,2515 00021 COSTH
047719,000206: 13,2516 77615 DAD
047720,000207: 13,2517 75454 BZE SQRT
047721,000208: 13,2520 26536 ARCTANXX # ATAN=0/0 SET THETA=0
047722,000209: 13,2521 40065 BDDV BOV
047723,000210: 13,2522 00023 SINTH
047724,000211: 13,2523 26543 ATAN=90
047725,000212: 13,2524 67542 SR1 ASIN
047726,000213: 13,2525 00025 STORE THETA
047727,000214: 13,2526 50125 PDDL BMN
047728,000215: 13,2527 00021 COSTH
047729,000216: 13,2530 26532 NEGCOS
047730,000217: 13,2531 43545 DLOAD RVQ
047731,000218: 13,2532 57545 NEGCOS DLOAD DCOMP
047732,000219: 13,2533 43244 BPL DAD
047733,000220: 13,2534 26540 NEGOUT
047734,000221: 13,2535 24005 DP1/2
047735,000222: 13,2536 00025 ARCTANXX STORE THETA
047736,000223: 13,2537 77616 RVQ
047737,000224:
047738,000225: 13,2540 52025 NEGOUT DSU GOTO
047739,000226: 13,2541 24005 DP1/2
047740,000227: 13,2542 26536 ARCTANXX
047741,000228: 13,2543 75345 ATAN=90 DLOAD SIGN
047742,000229: 13,2544 11021 LODP1/4
047743,000230: 13,2545 00023 SINTH
047744,000231: 13,2546 00025 STORE THETA
047745,000232: 13,2547 77616 RVQ
047746,000233:
047747,000234: 13,2550 12,2006 2DZERO = DPZERO
047748,000235:
Page 1130 |
047750,000237: # ..... SETGAMMA SUBROUTINE .....
047751,000238: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
047752,000239:
047753,000240: # GAMMA = B**2/A**2 FOR EARTH (B-1)
047754,000241: # GAMMA = 1 FOR MOON (B-1)
047755,000242:
047756,000243: # CALLING SEQUENCE
047757,000244: # L CALL
047758,000245: # L+1 SETGAMMA
047759,000246:
047760,000247: # INPUT
047761,000248: # LUNAFLAG=0 FOR EARTH,=1 FOR MOON
047762,000249:
047763,000250: # OUTPUT
047764,000251: # GAMMA IN GAMRP (B-1)
047765,000252:
047766,000253: 13,2550 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
047767,000254: 13,2551 26505 B2/A2 # EARTH GAMMA
047768,000255: 13,2552 01743 LUNAFLAG
047769,000256: 13,2553 26556 SETGMEX
047770,000257: 13,2554 77735 SLOAD
047771,000258: 13,2555 24005 1B1 # MOON GAMMA
047772,000259: 13,2556 00011 SETGMEX STORE GAMRP
047773,000260: 13,2557 77616 RVQ
047774,000261: 13,2560 GAMRP = 8D
047775,000262:
Page 1131 |
047777,000264: # ..... SETRE SUBROUTINE .....
047778,000265: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
047779,000266:
047780,000267: # RE = RM FOR MOON
047781,000268: # RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
047782,000269:
047783,000270: # CALLING SEQUENCE
047784,000271: # L CALL
047785,000272: # L+1 SETRE
047786,000273:
047787,000274: # SUBROUTINES USED
047788,000275: # GETERAD
047789,000276:
047790,000277: # INPUT
047791,000278: # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED RE
047792,000279: # ALPHAV +4= 1/2 SINL IF GETERAD IS CALLED
047793,000280: # LUNAFLAG=0 FOR EARTH,=1 FOR MOON
047794,000281:
047795,000282: # OUTPUT
047796,000283: # ERADM= 504RM FOR MOON (METERS B-29)
047797,000284: # ERADM= ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
047798,000285:
047799,000286: 13,2560 71220 SETRE STQ DLOAD
047800,000287: 13,2561 00051 SETREX
047801,000288: 13,2562 10003 504RM
047802,000289: 13,2563 71214 BON DLOAD # BRANCH FOR MOON
047803,000290: 13,2564 01703 LUNAFLAG
047804,000291: 13,2565 26575 TSTRLSRM
047805,000292: 13,2566 10001 ERAD
047806,000293: 13,2567 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
047807,000294: 13,2570 00742 ERADFLAG
047808,000295: 13,2571 26573 SETRXX
047809,000296: 13,2572 26466 GETERAD
047810,000297: 13,2573 37673 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
047811,000298: 13,2574 00051 SETREX
047812,000299: 13,2575 77214 TSTRLSRM BON VLOAD # ERADFLAG=0,SET R0=RLS
047813,000300: 13,2576 00702 ERADFLAG # =1 R0=RM
047814,000301: 13,2577 26573 SETRXX
047815,000302: 13,2600 02023 RLS
047816,000303: 13,2601 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
047817,000304: 13,2602 77650 GOTO
047818,000305: 13,2603 26573 SETRXX
047819,000306: 13,2604 0000051 SETREX = S2
047820,000307:
047821,000308:
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc