Source Code
These source-code files are part of a reconstructed copy of Luminary 178, the
final release of the Apollo 14 Lunar Module (LM) Apollo Guidance Computer
(AGC) software.
The reconstruction began with source code of Zerlina 56, Luminary 210, and Luminary 131, previously transcribed from digitized copies of those programs. The code was created by combining the three, using Zerlina 56 as a base, since it was based off of Luminary 183. The differences between the three were carefully merged using the Luminary memos as a guide, with all changes made after Luminary 178 being backed out. The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021152N. Note that page numbers in the reconstructed code match those for the baseline log section mentioned in each file's changelog; the page numbers for a real Luminary 178 listing would be different. Comments from the original source code are prefixed with a single '#' symbol, whereas comments added later are prefixed by "##" or "###". Report any errors noted by creating an issue report at the Virtual AGC project's GitHub repository. |
047737,000002: ## Copyright: Public domain.
047738,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
047739,000004: ## Purpose: A section of Luminary revision 178.
047740,000005: ## It is part of the reconstructed source code for the final
047741,000006: ## release of the flight software for the Lunar Module's
047742,000007: ## (LM) Apollo Guidance Computer (AGC) for Apollo 14. The
047743,000008: ## code has been recreated from copies of Zerlina 56, Luminary
047744,000009: ## 210, and Luminary 131, as well as many Luminary memos.
047745,000010: ## It has been adapted such that the resulting bugger words
047746,000011: ## exactly match those specified for Luminary 178 in NASA
047747,000012: ## drawing 2021152N, which gives relatively high confidence
047748,000013: ## that the reconstruction is correct.
047749,000014: ## Reference: pp. 1124-1130
047750,000015: ## Assembler: yaYUL
047751,000016: ## Contact: Ron Burkey <info@sandroid.org>.
047752,000017: ## Website: www.ibiblio.org/apollo/index.html
047753,000018: ## Mod history: 2019-08-14 MAS Created from Zerlina 56.
047754,000019:
Page 1124 |
047756,000021: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
047757,000022:
047758,000023: # CALLING SEQUENCE
047759,000024:
047760,000025: # L-1 CALL
047761,000026: # L LAT-LONG
047762,000027: # SUBROUTINES USED
047763,000028:
047764,000029: # R-TO-RP,ARCTAN,SETGAMMA,SETRE
047765,000030: # ERASABLE INIT. REQ.
047766,000031:
047767,000032: # AXO,-AYO,AZO,TEPHEM (SET AT LAUNCH TIME)
047768,000033: # ALPHAV = POSITION VECTOR METERS B-29
047769,000034: # MPAC-- TIME (CSECS B-28)
047770,000035: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
047771,000036: # LUNAFLAG=0 FOR EARTH,1 FOR MOON
047772,000037: # OUTPUT
047773,000038:
047774,000039: # LATITUDE IN LAT (REVS. B-0)
047775,000040: # LONGITUDE IN LONG (REVS. B-0)
047776,000041: # ALTITUDE IN ALT METERS B-29
047777,000042: 30,3757 BANK 30
047778,000043: 13,2000 SETLOC LATLONG
047779,000044: 13,2000 BANK
047780,000045:
047781,000046: 13,2347 COUNT* $$/LT-LG
047782,000047: 13,2347 E4,1431 EBANK= ALPHAV
047783,000048: 13,2347 40220 LAT-LONG STQ SETPD
047784,000049: 13,2350 03674 INCORPEX
047785,000050: 13,2351 00001 0D
047786,000051: 13,2352 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
047787,000052: 13,2353 02032 ALPHAV
047788,000053: 13,2354 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
047789,000054: 13,2355 16070 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
047790,000055: 13,2356 24007 ZEROVEC # SET MPAC=0 FOR EARTH,NON-ZERO FOR MOON
047791,000056: 13,2357 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
047792,000057: 13,2360 01743 LUNAFLAG # 0=EARTH,1=MOON
047793,000058: 13,2361 26362 CALLRTRP
047794,000059: 13,2362 77624 CALLRTRP CALL
047795,000060: 13,2363 51642 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
047796,000061: 13,2364 77656 UNIT # UNIT RP B-1
047797,000062: 13,2365 36032 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
047798,000063: 13,2366 26546 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH,=1 FOR MOON
047799,000064: 13,2367 77624 CALL # SCALED B-1
047800,000065: 13,2370 26556 SETRE # CALC RE METERS B-29
047801,000066: 13,2371 63545 DLOAD DSQ
047802,000067: 13,2372 02032 ALPHAV
047803,000068: 13,2373 63525 PDDL DSQ
047804,000069: 13,2374 02034 ALPHAV +2
047805,000070: 13,2375 75415 DAD SQRT
Page 1125 |
047807,000072: 13,2376 76405 DMP SL1R
047808,000073: 13,2377 00011 GAMRP
047809,000074: 13,2400 14021 STODL COSTH # COS(LAT) B-1
047810,000075: 13,2401 02036 ALPHAV +4
047811,000076: 13,2402 34023 STCALL SINTH # SIN(LAT) B-1
047812,000077: 13,2403 26506 ARCTAN
047813,000078: 13,2404 15120 STODL LAT # LAT B0
047814,000079: 13,2405 02032 ALPHAV
047815,000080: 13,2406 14021 STODL COSTH # COS(LONG) B-1
047816,000081: 13,2407 02034 ALPHAV +2
047817,000082: 13,2410 34023 STCALL SINTH # SIN(LONG) B-1
047818,000083: 13,2411 26506 ARCTAN
047819,000084: 13,2412 15122 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
047820,000085: 13,2413 02070 ALPHAM
047821,000086: 13,2414 77625 DSU # ALT= R-RE METERS B-29
047822,000087: 13,2415 03673 ERADM
047823,000088: 13,2416 35124 STCALL ALT # EXIT WITH ALT METERS B-29
047824,000089: 13,2417 03674 INCORPEX
047825,000090:
Page 1126 |
047827,000092: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
047828,000093: # CALLING SEQUENCE
047829,000094:
047830,000095: # L-1 CALL
047831,000096: # L LALOTORV
047832,000097: # SUBROUTINES USED
047833,000098:
047834,000099: # SETGAMMA,SETRE,RP-TO-R
047835,000100: # ERASABLE INIT. REQ.
047836,000101:
047837,000102: # AXO,AYO,AZO,TEPHEM SET AT LAUNCH TIME
047838,000103: # LAT-- LATITUDE (REVS B0)
047839,000104: # LONG-- LONGITUDE (REVS B0)
047840,000105: # ALT--ALTITUDE (METERS) B-29
047841,000106: # MPAC-- TIME (CSECS B-28)
047842,000107: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
047843,000108: # LUNAFLAG=0 FOR EARTH,1 FOR MOON
047844,000109: # OUTPUT
047845,000110:
047846,000111: # R-VECTOR IN ALPHAV (METERS B-29)
047847,000112: 13,2420 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
047848,000113: 13,2421 03674 INCORPEX
047849,000114: 13,2422 00001 0D
047850,000115: 13,2423 34007 STCALL 6D # 6-7D= TIME FOR RP-TO-R
047851,000116: 13,2424 26546 SETGAMMA # GAMMA=B2/A2 FOR EARTH,1 FOR MOON B-1
047852,000117: 13,2425 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
047853,000118: 13,2426 01120 LAT # UNIT RP= SIN(LONG)COS(LAT) 2-3D
047854,000119: 13,2427 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
047855,000120: 13,2430 00011 GAMRP
047856,000121: 13,2431 01120 LAT # 0-1D= GAMMA*SIN(LAT) B-2
047857,000122: 13,2432 65346 COS PDDL # PD4 2-3D=COS(LAT) B-1 TEMPORARILY
047858,000123: 13,2433 01122 LONG
047859,000124: 13,2434 57356 SIN DMPR # PD 2
047860,000125: 13,2435 71525 PDDL COS # PD 4 2-3D=SIN(LONG)COS(LAT) B-2
047861,000126: 13,2436 01120 LAT
047862,000127: 13,2437 71525 PDDL COS # PD 6 4-5D=COS(LAT) B-1 TEMPORARILY
047863,000128: 13,2440 01122 LONG
047864,000129: 13,2441 55475 DMPR VDEF # PD 4 MPAC= COS(LONG)COS(LAT) B-2
047865,000130: 13,2442 41456 UNIT PUSH # 0-5D= UNIT RP FOR RP-TO-R SUBR.
047866,000131: 13,2443 36032 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
047867,000132: 13,2444 26556 SETRE # RE METERS B-29
047868,000133: 13,2445 43145 DLOAD BOFF # SET MPAC=0 FOR EARTH,NON-ZERO FOR MOON
047869,000134: 13,2446 24007 ZEROVEC
047870,000135: 13,2447 01743 LUNAFLAG
047871,000136: 13,2450 26452 CALLRPRT
047872,000137: 13,2451 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
047873,000138: 13,2452 77624 CALLRPRT CALL
047874,000139: 13,2453 55720 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
047875,000140: 13,2454 16032 STODL ALPHAV
047876,000141: 13,2455 03673 ERADM
Page 1127 |
047878,000143: 13,2456 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
047879,000144: 13,2457 01124 ALT
047880,000145: 13,2460 02032 ALPHAV
047881,000146: 13,2461 77772 VSL1 # R METERS B-29
047882,000147: 13,2462 36032 STCALL ALPHAV # EXIT WITH R IN METERS B-29
047883,000148: 13,2463 03674 INCORPEX
047884,000149: # SUBROUTINE TO COMPUTE EARTH RADIUS
047885,000150:
047886,000151: # INPUT
047887,000152:
047888,000153: # 1/2 SIN LAT IN ALPHAV +4
047889,000154:
047890,000155: # OUTPUT
047891,000156:
047892,000157: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
047893,000158:
047894,000159: 13,2464 63545 GETERAD DLOAD DSQ
047895,000160: 13,2465 02036 ALPHAV +4 # SIN**2(L)
047896,000161: 13,2466 44352 SL1 BDSU
047897,000162: 13,2467 24005 DP1/2 # COS**2(L)
047898,000163: 13,2470 44275 DMPR BDSU
047899,000164: 13,2471 26505 EE
047900,000165: 13,2472 24005 DP1/2
047901,000166: 13,2473 75465 BDDV SQRT
047902,000167: 13,2474 26501 B2XSC
047903,000168: 13,2475 77622 SR4R
047904,000169: 13,2476 03673 STORE ERADM
047905,000170: 13,2477 77616 RVQ
047906,000171:
047907,000172: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166,B=6356784 METERS
047908,000173: # B2XSC= B**2 SCALED B-51
047909,000174: # B2/A2= B**2/A**2 SCALED B-1
047910,000175: # EE=(1-B**2/A**2) SCALED B-0
047911,000176: 13,2500 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
047912,000177:
047913,000178: 13,2502 12,2004 DP1/2 = XUNIT
047914,000179: 13,2502 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
047915,000180:
047916,000181: 13,2504 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
047917,000182:
Page 1128 |
047919,000184: # ARCTAN SUBROUTINE
047920,000185:
047921,000186:
047922,000187: # CALLING SEQUENCE
047923,000188:
047924,000189: # SIN THETA IN SINTH B-1
047925,000190: # COS THETA IN COSTH B-1
047926,000191: # CALL ARCTAN
047927,000192:
047928,000193: # OUTPUT
047929,000194: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
047930,000195:
047931,000196:
047932,000197: 13,2506 77600 ARCTAN BOV
047933,000198: 13,2507 26510 CLROVFLW
047934,000199: 13,2510 63545 CLROVFLW DLOAD DSQ
047935,000200: 13,2511 00023 SINTH
047936,000201: 13,2512 63525 PDDL DSQ
047937,000202: 13,2513 00021 COSTH
047938,000203: 13,2514 77615 DAD
047939,000204: 13,2515 75454 BZE SQRT
047940,000205: 13,2516 26534 ARCTANXX # ATAN=0/0 SET THETA=0
047941,000206: 13,2517 40065 BDDV BOV
047942,000207: 13,2520 00023 SINTH
047943,000208: 13,2521 26541 ATAN=90
047944,000209: 13,2522 67542 SR1 ASIN
047945,000210: 13,2523 00025 STORE THETA
047946,000211: 13,2524 50125 PDDL BMN
047947,000212: 13,2525 00021 COSTH
047948,000213: 13,2526 26530 NEGCOS
047949,000214: 13,2527 43545 DLOAD RVQ
047950,000215: 13,2530 57545 NEGCOS DLOAD DCOMP
047951,000216: 13,2531 43244 BPL DAD
047952,000217: 13,2532 26536 NEGOUT
047953,000218: 13,2533 24005 DP1/2
047954,000219: 13,2534 00025 ARCTANXX STORE THETA
047955,000220: 13,2535 77616 RVQ
047956,000221:
047957,000222: 13,2536 52025 NEGOUT DSU GOTO
047958,000223: 13,2537 24005 DP1/2
047959,000224: 13,2540 26534 ARCTANXX
047960,000225: 13,2541 75345 ATAN=90 DLOAD SIGN
047961,000226: 13,2542 11011 LODP1/4
047962,000227: 13,2543 00023 SINTH
047963,000228: 13,2544 00025 STORE THETA
047964,000229: 13,2545 77616 RVQ
047965,000230:
047966,000231: 13,2546 12,2006 2DZERO = DPZERO
047967,000232:
Page 1129 |
047969,000234: # ..... SETGAMMA SUBROUTINE .....
047970,000235: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
047971,000236:
047972,000237: # GAMMA = B**2/A**2 FOR EARTH (B-1)
047973,000238: # GAMMA = 1 FOR MOON (B-1)
047974,000239:
047975,000240: # CALLING SEQUENCE
047976,000241: # L CALL
047977,000242: # L+1 SETGAMMA
047978,000243:
047979,000244: # INPUT
047980,000245: # LUNAFLAG=0 FOR EARTH,=1 FOR MOON
047981,000246:
047982,000247: # OUTPUT
047983,000248: # GAMMA IN GAMRP (B-1)
047984,000249:
047985,000250: 13,2546 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
047986,000251: 13,2547 26503 B2/A2 # EARTH GAMMA
047987,000252: 13,2550 01743 LUNAFLAG
047988,000253: 13,2551 26554 SETGMEX
047989,000254: 13,2552 77735 SLOAD
047990,000255: 13,2553 24005 1B1 # MOON GAMMA
047991,000256: 13,2554 00011 SETGMEX STORE GAMRP
047992,000257: 13,2555 77616 RVQ
047993,000258: 13,2556 GAMRP = 8D
047994,000259:
Page 1130 |
047996,000261: # .....SETRE SUBROUTINE .....
047997,000262: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
047998,000263:
047999,000264: # RE= RM FOR MOON
048000,000265: # RE= RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
048001,000266:
048002,000267: # CALLING SEQUENCE
048003,000268: # L CALL
048004,000269: # L+1 SETRE
048005,000270:
048006,000271: # SUBROUTINES USED
048007,000272: # GETERAD
048008,000273:
048009,000274: # INPUT
048010,000275: # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED RE
048011,000276: # ALPHAV +4= 1/2 SINL IF GETERAD IS CALLED
048012,000277: # LUNAFLAG=0 FOR EARTH,=1 FOR MOON
048013,000278:
048014,000279: # OUTPUT
048015,000280: # ERADM= 504RM FOR MOON (METERS B-29)
048016,000281: # ERADM= ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
048017,000282:
048018,000283: 13,2556 71220 SETRE STQ DLOAD
048019,000284: 13,2557 00051 SETREX
048020,000285: 13,2560 10003 504RM
048021,000286: 13,2561 71214 BON DLOAD # BRANCH FOR MOON
048022,000287: 13,2562 01703 LUNAFLAG
048023,000288: 13,2563 26573 TSTRLSRM
048024,000289: 13,2564 10001 ERAD
048025,000290: 13,2565 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE,1 FOR COMPUTED
048026,000291: 13,2566 00742 ERADFLAG
048027,000292: 13,2567 26571 SETRXX
048028,000293: 13,2570 26464 GETERAD
048029,000294: 13,2571 37673 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
048030,000295: 13,2572 00051 SETREX
048031,000296: 13,2573 77214 TSTRLSRM BON VLOAD # ERADFLAG=0,SET R0=RLS
048032,000297: 13,2574 00702 ERADFLAG # =1 R0=RM
048033,000298: 13,2575 26571 SETRXX
048034,000299: 13,2576 02021 RLS
048035,000300: 13,2577 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
048036,000301: 13,2600 77650 GOTO
048037,000302: 13,2601 26571 SETRXX
048038,000303: 13,2602 0000051 SETREX = S2
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc