Source Code
These source-code files are part of a reconstructed copy of Luminary 69/2,
the flown, final release of the Apollo 10 Lunar Module (LM) Apollo Guidance Computer (AGC) software.
The reconstruction is based on the source code of Luminary 69 — i.e., the initial, unflown version, "revision 0" — of which a contemporary listing was available. The code was then updated by incorporating the differences between Luminary 69 and Luminary 69/2, known from other contemporary documentation. The only such difference is the implementation in Luminary 69/2 of the "R-2 Lunar Potential Model", the source code for which was taken from program Luminary 99/1 (Apollo 11 LM), of which a contemporary listing was also available. Finally, the now-reconstructed Luminary 69/2 was then validated by assembling it to executable form and verifying that its memory banks had the correct checksums, known from still other contemporary documentation. Note that page numbers in the reconstructed code match those in the original Luminary 69 program listing, or in the ORBITAL INTEGRATION log section, in Luminary 99/1. Page numbers would certainly differ somewhat in a contemporary Luminary 69/2 listing. Moreover, annotations that were not present in the contemporary source code have been added to the reconstructed code to justify each change in Luminary 69/2 relative to Luminary 69. Here's a guide to the Apollo documentation referenced in those annotations:
|
048370,000002: ## Copyright: Public domain.
048371,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
048372,000004: ## Purpose: A section of LUM69 revision 2.
048373,000005: ## It is part of the reconstructed source code for the flown
048374,000006: ## version of the flight software for the Lunar Module's (LM)
048375,000007: ## Apollo Guidance Computer (AGC) for Apollo 10. The code has
048376,000008: ## been recreated from a copy of Luminary revsion 069, using
048377,000009: ## changes present in Luminary 099 which were described in
048378,000010: ## Luminary memos 75 and 78. The code has been adapted such
048379,000011: ## that the resulting bugger words exactly match those specified
048380,000012: ## for LUM69 revision 2 in NASA drawing 2021152B, which gives
048381,000013: ## relatively high confidence that the reconstruction is correct.
048382,000014: ## Reference: pp. 1128-1134
048383,000015: ## Assembler: yaYUL
048384,000016: ## Contact: Ron Burkey <info@sandroid.org>.
048385,000017: ## Website: www.ibiblio.org/apollo/index.html
048386,000018: ## Mod history: 2019-07-27 MAS Created from Luminary 69.
048387,000019:
Page 1128 |
048389,000021: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
048390,000022:
048391,000023: # CALLING SEQUENCE
048392,000024: # L-1 CALL
048393,000025: # L LAT-LONG
048394,000026:
048395,000027: # SUBROUTINES USED
048396,000028: # R-TO-RP,ARCTAN,SETGAMMA,SETRE
048397,000029:
048398,000030: # ERASABLE INIT. REQ.
048399,000031: # AXO,-AYO,AZO,TEPHEM (SET AT LAUNCH TIME)
048400,000032: # ALPHAV = POSITION VECTOR METERS B-29
048401,000033: # MPAC-- TIME (CSECS B-28)
048402,000034: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
048403,000035: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
048404,000036:
048405,000037: # OUTPUT
048406,000038: # LATITUDE IN LAT (REVS. B-0)
048407,000039: # LONGITUDE IN LONG (REVS. B-0)
048408,000040: # ALTITUDE IN ALT METERS B-29
048409,000041:
048410,000042: 30,3746 BANK 30
048411,000043: 13,2000 SETLOC LATLONG
048412,000044: 13,2000 BANK
048413,000045:
048414,000046: 13,2351 COUNT* $$/LT-LG
048415,000047: 13,2351 E4,1431 EBANK= ALPHAV
048416,000048: 13,2351 40220 LAT-LONG STQ SETPD
048417,000049: 13,2352 03672 INCORPEX
048418,000050: 13,2353 00001 0D
048419,000051: 13,2354 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
048420,000052: 13,2355 02032 ALPHAV
048421,000053: 13,2356 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
048422,000054: 13,2357 16070 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
048423,000055: 13,2360 22275 ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
048424,000056: 13,2361 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
048425,000057: 13,2362 01743 LUNAFLAG # 0=EARTH, 1=MOON
048426,000058: 13,2363 26364 CALLRTRP
048427,000059: 13,2364 77624 CALLRTRP CALL
048428,000060: 13,2365 51531 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
048429,000061: 13,2366 77656 UNIT # UNIT RP B-1
048430,000062: 13,2367 36032 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
048431,000063: 13,2370 26550 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH,=1 FOR MOON
048432,000064: 13,2371 77624 CALL # SCALED B-1
048433,000065: 13,2372 26560 SETRE # CALC RE METERS B-29
048434,000066: 13,2373 63545 DLOAD DSQ
048435,000067: 13,2374 02032 ALPHAV
048436,000068: 13,2375 63525 PDDL DSQ
048437,000069: 13,2376 02034 ALPHAV +2
048438,000070: 13,2377 75415 DAD SQRT
Page 1129 |
048440,000072: 13,2400 76405 DMP SL1R
048441,000073: 13,2401 00011 GAMRP
048442,000074: 13,2402 14021 STODL COSTH # COS(LAT) B-1
048443,000075: 13,2403 02036 ALPHAV +4
048444,000076: 13,2404 34023 STCALL SINTH # SIN(LAT) B-1
048445,000077: 13,2405 26510 ARCTAN
048446,000078: 13,2406 15121 STODL LAT # LAT B0
048447,000079: 13,2407 02032 ALPHAV
048448,000080: 13,2410 14021 STODL COSTH # COS(LONG) B-1
048449,000081: 13,2411 02034 ALPHAV +2
048450,000082: 13,2412 34023 STCALL SINTH # SIN(LONG) B-1
048451,000083: 13,2413 26510 ARCTAN
048452,000084: 13,2414 15123 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
048453,000085: 13,2415 02070 ALPHAM
048454,000086: 13,2416 77625 DSU # ALT= R-RE METERS B-29
048455,000087: 13,2417 03671 ERADM
048456,000088: 13,2420 35125 STCALL ALT # EXIT WITH ALT METERS B-29
048457,000089: 13,2421 03672 INCORPEX
Page 1130 |
048459,000091: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
048460,000092:
048461,000093: # CALLING SEQUENCE
048462,000094: # L-1 CALL
048463,000095: # L LALOTORV
048464,000096:
048465,000097: # SUBROUTINES USED
048466,000098: # SETGAMMA,SETRE,RP-TO-R
048467,000099:
048468,000100: # ERASABLE INIT. REQ.
048469,000101: # AXO,AYO,AZO,TEPHEM SET AT LAUNCH TIME
048470,000102: # LAT-- LATITUDE (REVS B0)
048471,000103: # LONG-- LONGITUDE (REVS B0)
048472,000104: # ALT--ALTITUDE (METERS) B-29
048473,000105: # MPAC-- TIME (CSECS B-28)
048474,000106: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
048475,000107: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
048476,000108:
048477,000109: # OUTPUT
048478,000110: # R-VECTOR IN ALPHAV (METERS B-29)
048479,000111:
048480,000112: 13,2422 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
048481,000113: 13,2423 03672 INCORPEX
048482,000114: 13,2424 00001 0D
048483,000115: 13,2425 34007 STCALL 6D # 6-7D= TIME FOR RP-TO-R
048484,000116: 13,2426 26550 SETGAMMA # GAMMA=B2/A2 FOR EARTH,1 FOR MOON B-1
048485,000117: 13,2427 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
048486,000118: 13,2430 01121 LAT # UNIT RP= SIN(LONG)COS(LAT) 2-3D
048487,000119: 13,2431 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
048488,000120: 13,2432 00011 GAMRP
048489,000121: 13,2433 01121 LAT # 0-1D= GAMMA*SIN(LAT) B-2
048490,000122: 13,2434 65346 COS PDDL # PD 4 2-3D=COS(LAT) B-1 TEMPORARILY
048491,000123: 13,2435 01123 LONG
048492,000124: 13,2436 57356 SIN DMPR # PD 2
048493,000125: 13,2437 71525 PDDL COS # PD 4 2-3D=SIN(LONG)COS(LAT) B-2
048494,000126: 13,2440 01121 LAT
048495,000127: 13,2441 71525 PDDL COS # PD 6 4-5D=COS(LAT) B-1 TEMPORARILY
048496,000128: 13,2442 01123 LONG
048497,000129: 13,2443 55475 DMPR VDEF # PD 4 MPAC= COS(LONG)COS(LAT) B-2
048498,000130: 13,2444 41456 UNIT PUSH # 0-5D= UNIT RP FOR RP-TO-R SUBR.
048499,000131: 13,2445 36032 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
048500,000132: 13,2446 26560 SETRE # RE METERS B-29
048501,000133: 13,2447 43145 DLOAD BOFF # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
048502,000134: 13,2450 22275 ZEROVEC
048503,000135: 13,2451 01743 LUNAFLAG
048504,000136: 13,2452 26454 CALLRPRT
048505,000137: 13,2453 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
048506,000138: 13,2454 77624 CALLRPRT CALL
048507,000139: 13,2455 51504 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
048508,000140: 13,2456 16032 STODL ALPHAV
048509,000141: 13,2457 03671 ERADM
Page 1131 |
048511,000143: 13,2460 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
048512,000144: 13,2461 01125 ALT
048513,000145: 13,2462 02032 ALPHAV
048514,000146: 13,2463 77772 VSL1 # R METERS B-29
048515,000147: 13,2464 36032 STCALL ALPHAV # EXIT WITH R IN METERS B-29
048516,000148: 13,2465 03672 INCORPEX
048517,000149:
048518,000150: # SUBROUTINE TO COMPUTE EARTH RADIUS
048519,000151:
048520,000152: # INPUT
048521,000153: # 1/2 SIN LAT IN ALPHAV +4
048522,000154:
048523,000155: # OUTPUT
048524,000156: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
048525,000157:
048526,000158: 13,2466 63545 GETERAD DLOAD DSQ
048527,000159: 13,2467 02036 ALPHAV +4 # SIN**2(L)
048528,000160: 13,2470 44352 SL1 BDSU
048529,000161: 13,2471 22273 DP1/2 # COS**2(L)
048530,000162: 13,2472 44275 DMPR BDSU
048531,000163: 13,2473 26507 EE
048532,000164: 13,2474 22273 DP1/2
048533,000165: 13,2475 75465 BDDV SQRT
048534,000166: 13,2476 26503 B2XSC
048535,000167: 13,2477 77622 SR4R
048536,000168: 13,2500 03671 STORE ERADM
048537,000169: 13,2501 77616 RVQ
048538,000170:
048539,000171: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
048540,000172: # B2XSC= B**2 SCALED B-51
048541,000173: # B2/A2= B**2/A**2 SCALED B-1
048542,000174: # EE=(1-B**2/A**2) SCALED B-0
048543,000175:
048544,000176: 13,2502 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
048545,000177: 13,2504 11,2272 DP1/2 = XUNIT
048546,000178: 13,2504 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
048547,000179: 13,2506 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
048548,000180:
Page 1132 |
048550,000182: # ARCTAN SUBROUTINE
048551,000183:
048552,000184: # CALLING SEQUENCE
048553,000185: # SIN THETA IN SINTH B-1
048554,000186: # COS THETA IN COSTH B-1
048555,000187: # CALL ARCTAN
048556,000188:
048557,000189: # OUTPUT
048558,000190: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
048559,000191:
048560,000192: 13,2510 77600 ARCTAN BOV
048561,000193: 13,2511 26512 CLROVFLW
048562,000194: 13,2512 63545 CLROVFLW DLOAD DSQ
048563,000195: 13,2513 00023 SINTH
048564,000196: 13,2514 63525 PDDL DSQ
048565,000197: 13,2515 00021 COSTH
048566,000198: 13,2516 77615 DAD
048567,000199: 13,2517 75454 BZE SQRT
048568,000200: 13,2520 26536 ARCTANXX # ATAN=0/0 SET THETA=0
048569,000201: 13,2521 40065 BDDV BOV
048570,000202: 13,2522 00023 SINTH
048571,000203: 13,2523 26543 ATAN=90
048572,000204: 13,2524 67542 SR1 ASIN
048573,000205: 13,2525 00025 STORE THETA
048574,000206: 13,2526 50125 PDDL BMN
048575,000207: 13,2527 00021 COSTH
048576,000208: 13,2530 26532 NEGCOS
048577,000209: 13,2531 43545 DLOAD RVQ
048578,000210: 13,2532 57545 NEGCOS DLOAD DCOMP
048579,000211: 13,2533 43244 BPL DAD
048580,000212: 13,2534 26540 NEGOUT
048581,000213: 13,2535 22273 DP1/2
048582,000214: 13,2536 00025 ARCTANXX STORE THETA
048583,000215: 13,2537 77616 RVQ
048584,000216:
048585,000217: 13,2540 52025 NEGOUT DSU GOTO
048586,000218: 13,2541 22273 DP1/2
048587,000219: 13,2542 26536 ARCTANXX
048588,000220: 13,2543 75345 ATAN=90 DLOAD SIGN
048589,000221: 13,2544 10760 LODP1/4
048590,000222: 13,2545 00023 SINTH
048591,000223: 13,2546 00025 STORE THETA
048592,000224: 13,2547 77616 RVQ
048593,000225:
048594,000226: 13,2550 11,2274 2DZERO = DPZERO
048595,000227:
Page 1133 |
048597,000229: # ..... SETGAMMA SUBROUTINE .....
048598,000230: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
048599,000231:
048600,000232: # GAMMA = B**2/A**2 FOR EARTH (B-1)
048601,000233: # GAMMA = 1 FOR MOON (B-1)
048602,000234:
048603,000235: # CALLING SEQUENCE
048604,000236: # L CALL
048605,000237: # L+1 SETGAMMA
048606,000238:
048607,000239: # INPUT
048608,000240: # LUNAFLAG=0 FOR EARTH,=1 FOR MOON
048609,000241:
048610,000242: # OUTPUT
048611,000243: # GAMMA IN GAMRP (B-1)
048612,000244:
048613,000245: 13,2550 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
048614,000246: 13,2551 26505 B2/A2 # EARTH GAMMA
048615,000247: 13,2552 01743 LUNAFLAG
048616,000248: 13,2553 26556 SETGMEX
048617,000249: 13,2554 77735 SLOAD
048618,000250: 13,2555 22273 1B1 # MOON GAMMA
048619,000251: 13,2556 00011 SETGMEX STORE GAMRP
048620,000252: 13,2557 77616 RVQ
048621,000253: 13,2560 GAMRP = 8D
048622,000254:
Page 1134 |
048624,000256: # ..... SETRE SUBROUTINE .....
048625,000257: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
048626,000258:
048627,000259: # RE= RM FOR MOON
048628,000260: # RE= RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
048629,000261:
048630,000262: # CALLING SEQUENCE
048631,000263: # L CALL
048632,000264: # L+1 SETRE
048633,000265:
048634,000266: # SUBROUTINES USED
048635,000267: # GETERAD
048636,000268:
048637,000269: # INPUT
048638,000270: # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED RE
048639,000271: # ALPHAV +4= 1/2 SINL IF GETERAD IS CALLED
048640,000272: # LUNAFLAG=0 FOR EARTH,=1 FOR MOON
048641,000273:
048642,000274: # OUTPUT
048643,000275: # ERADM= 504RM FOR MOON (METERS B-29)
048644,000276: # ERADM= ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
048645,000277:
048646,000278: 13,2560 71220 SETRE STQ DLOAD
048647,000279: 13,2561 00051 SETREX
048648,000280: 13,2562 10003 504RM
048649,000281: 13,2563 71214 BON DLOAD # BRANCH FOR MOON
048650,000282: 13,2564 01703 LUNAFLAG
048651,000283: 13,2565 26575 TSTRLSRM
048652,000284: 13,2566 10001 ERAD
048653,000285: 13,2567 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
048654,000286: 13,2570 00742 ERADFLAG
048655,000287: 13,2571 26573 SETRXX
048656,000288: 13,2572 26466 GETERAD
048657,000289: 13,2573 37671 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
048658,000290: 13,2574 00051 SETREX
048659,000291: 13,2575 77214 TSTRLSRM BON VLOAD # ERADFLAG=0, SET R0=RLS
048660,000292: 13,2576 00702 ERADFLAG # =1 R0=RM
048661,000293: 13,2577 26573 SETRXX
048662,000294: 13,2600 02023 RLS
048663,000295: 13,2601 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
048664,000296: 13,2602 77650 GOTO
048665,000297: 13,2603 26573 SETRXX
048666,000298: 13,2604 0000051 SETREX = S2
048667,000299:
048668,000300:
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc