Source Code
This is a reconstruction of the AGC program Luminary 99 Rev 0. It was the third release
of the Lunar Module flight software targeted for use in Apollo 11, after Luminary 96 and 97.
A bug (which had been around since at least Apollo 10, Luminary 69) was
discovered in Rev 0 shortly before the Apollo 11 flight, resulting in a last minute
revision into Rev 1,
which is what actually flew rather than
the Rev 0 presented here. A hardcopy of Rev 0 is known to
exist — it belonged to AGC developer Allan Klumpp for many years — but
unfortunately the Virtual AGC Project has not had access to that hardcopy. Thus
the code you see here had been reconstructed (we believe accurately) rather than
transcribed. The first step of the reconstruction of the Rev 0 source code was
the transcription of the Rev 1 source code from a hardcopy in the MIT Museum collection.
The process of reverting the active portion of the source code (i.e., other than
program comments) from Rev 1 to Rev 0 was very minor, consisting
only of moving the position of the STARTSB1 label in
FRESH START AND RESTART. Allan had previously given
us the checksums of the memory banks of Rev 0, and we have verified the program presented here has checksums
identical to all banks of Allan's listing of Rev 0. The notations on Allan's Rev 0 program listing read,
in part:GAP: ASSEMBLE REVISION 099 OF AGC PROGRAM LUMINARY BY NASA 2021112-051 A single program comment is known to differ between Rev 0 and Rev 1, but these are harder to reconstruct and verify than changes to the active portion of the code. Thus it is possible that there are additional differences between the program comments in Rev 0 and Rev 1 that are unknown to us, and therefore are not reflected in the code presented here. |
049226,000002: ## Copyright: Public domain.
049227,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
049228,000004: ## Purpose: Part of the reconstructed source code for LMY99 Rev 0,
049229,000005: ## otherwise known as Luminary Rev 99, the third release
049230,000006: ## of the Apollo Guidance Computer (AGC) software for Apollo 11.
049231,000007: ## It differs from LMY99 Rev 1 (the flown version) only in the
049232,000008: ## placement of a single label. The corrections shown here have
049233,000009: ## been verified to have the same bank checksums as AGC developer
049234,000010: ## Allan Klumpp's copy of Luminary Rev 99, and so are believed
049235,000011: ## to be accurate. This file is intended to be a faithful
049236,000012: ## recreation, except that the code format has been changed to
049237,000013: ## conform to the requirements of the yaYUL assembler rather than
049238,000014: ## the original YUL assembler.
049239,000015: ##
049240,000016: ## Assembler: yaYUL
049241,000017: ## Contact: Jim Lawton <jim DOT lawton AT gmail DOT com>
049242,000018: ## Website: www.ibiblio.org/apollo.
049243,000019: ## Pages: 1133-1139
049244,000020: ## Mod history: 2009-05-28 JL Updated from page images.
049245,000021: ## 2011-01-06 JL Fixed interpretive indentation.
049246,000022: ## 2016-12-17 RSB Proofed text comments with octopus/ProoferComments
049247,000023: ## and corrected the errors found.
049248,000024: ## 2017-03-15 RSB Comment-text fixes identified in 5-way
049249,000025: ## side-by-side diff of Luminary 69/99/116/131/210.
049250,000026: ## 2017-08-01 MAS Created from LMY99 Rev 1.
049251,000027:
049252,000028: ## This source code has been transcribed or otherwise adapted from
049253,000029: ## digitized images of a hardcopy from the MIT Museum. The digitization
049254,000030: ## was performed by Paul Fjeld, and arranged for by Deborah Douglas of
049255,000031: ## the Museum. Many thanks to both. The images (with suitable reduction
049256,000032: ## in storage size and consequent reduction in image quality as well) are
049257,000033: ## available online at www.ibiblio.org/apollo. If for some reason you
049258,000034: ## find that the images are illegible, contact me at info@sandroid.org
049259,000035: ## about getting access to the (much) higher-quality images which Paul
049260,000036: ## actually created.
049261,000037: ##
049262,000038: ## The code has been modified to match LMY99 Revision 0, otherwise
049263,000039: ## known as Luminary Revision 99, the Apollo 11 software release preceeding
049264,000040: ## the listing from which it was transcribed. It has been verified to
049265,000041: ## contain the same bank checksums as AGC developer Allan Klumpp's listing
049266,000042: ## of Luminary Revision 99 (for which we do not have scans).
049267,000043: ##
049268,000044: ## Notations on Allan Klumpp's listing read, in part:
049269,000045: ##
049270,000046: ## ASSEMBLE REVISION 099 OF AGC PROGRAM LUMINARY BY NASA 2021112-51
049271,000047:
Page 1133 |
049273,000049: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
049274,000050:
049275,000051: # CALLING SEQUENCE
049276,000052: # L-1 CALL
049277,000053: # L LAT-LONG
049278,000054:
049279,000055: # SUBROUTINES USED
049280,000056: # R-TO-RP, ARCTAN, SETGAMMA, SETRE
049281,000057:
049282,000058: # ERASABLE INIT. REQ.
049283,000059: # AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
049284,000060: # ALPHAV = POSITION VECTOR METERS B-29
049285,000061: # MPAC -- TIME (CSECS B-28)
049286,000062: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
049287,000063: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
049288,000064:
049289,000065: # OUTPUT
049290,000066: # LATITUDE IN LAT (REVS. B-0)
049291,000067: # LONGITUDE IN LONG (REVS. B-0)
049292,000068: # ALTITUDE IN ALT METERS B-29
049293,000069:
049294,000070: 30,3775 BANK 30
049295,000071: 13,2000 SETLOC LATLONG
049296,000072: 13,2000 BANK
049297,000073:
049298,000074: 13,2351 COUNT* $$/LT-LG
049299,000075: 13,2351 E4,1431 EBANK= ALPHAV
049300,000076: 13,2351 40220 LAT-LONG STQ SETPD
049301,000077: 13,2352 03674 INCORPEX
049302,000078: 13,2353 00001 0D
049303,000079: 13,2354 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
049304,000080: 13,2355 02032 ALPHAV
049305,000081: 13,2356 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
049306,000082: 13,2357 16070 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
049307,000083: 13,2360 24007 ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
049308,000084: 13,2361 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
049309,000085: 13,2362 01743 LUNAFLAG # 0=EARTH, 1=MOON
049310,000086: 13,2363 26364 CALLRTRP
049311,000087: 13,2364 77624 CALLRTRP CALL
049312,000088: 13,2365 51670 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
049313,000089: 13,2366 77656 UNIT # UNIT RP B-1
049314,000090: 13,2367 36032 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
049315,000091: 13,2370 26550 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
049316,000092: 13,2371 77624 CALL # SCALED B-1
049317,000093: 13,2372 26560 SETRE # CALC RE METERS B-29
049318,000094: 13,2373 63545 DLOAD DSQ
049319,000095: 13,2374 02032 ALPHAV
049320,000096: 13,2375 63525 PDDL DSQ
049321,000097: 13,2376 02034 ALPHAV +2
049322,000098: 13,2377 75415 DAD SQRT
Page 1134 |
049324,000100: 13,2400 76405 DMP SL1R
049325,000101: 13,2401 00011 GAMRP
049326,000102: 13,2402 14021 STODL COSTH # COS(LAT) B-1
049327,000103: 13,2403 02036 ALPHAV +4
049328,000104: 13,2404 34023 STCALL SINTH # SIN(LAT) B-1
049329,000105: 13,2405 26510 ARCTAN
049330,000106: 13,2406 15121 STODL LAT # LAT B0
049331,000107: 13,2407 02032 ALPHAV
049332,000108: 13,2410 14021 STODL COSTH # COS(LONG) B-1
049333,000109: 13,2411 02034 ALPHAV +2
049334,000110: 13,2412 34023 STCALL SINTH # SIN(LONG) B-1
049335,000111: 13,2413 26510 ARCTAN
049336,000112: 13,2414 15123 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
049337,000113: 13,2415 02070 ALPHAM
049338,000114: 13,2416 77625 DSU # ALT= R-RE METERS B-29
049339,000115: 13,2417 03673 ERADM
049340,000116: 13,2420 35125 STCALL ALT # EXIT WITH ALT METERS B-29
049341,000117: 13,2421 03674 INCORPEX
Page 1135 |
049343,000119: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
049344,000120:
049345,000121: # CALLING SEQUENCE
049346,000122: # L-1 CALL
049347,000123: # L LALOTORV
049348,000124:
049349,000125: # SUBROUTINES USED
049350,000126: # SETGAMMA, SETRE, RP-TO-R
049351,000127:
049352,000128: # ERASABLE INIT. REQ.
049353,000129: # AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
049354,000130: # LAT -- LATITUDE (REVS B0)
049355,000131: # LONG -- LONGITUDE (REVS B0)
049356,000132: # ALT -- ALTITUDE (METERS) B-29
049357,000133: # MPAC -- TIME (CSECS B-28)
049358,000134: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
049359,000135: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
049360,000136:
049361,000137: # OUTPUT
049362,000138: # R-VECTOR IN ALPHAV (METERS B-29)
049363,000139:
049364,000140: 13,2422 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
049365,000141: 13,2423 03674 INCORPEX
049366,000142: 13,2424 00001 0D
049367,000143: 13,2425 34007 STCALL 6D # 6-7D= TIME FOR RP-TO-R
049368,000144: 13,2426 26550 SETGAMMA # GAMMA=B2/A2 FOR EARTH, 1 FOR MOON B-1
049369,000145: 13,2427 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
049370,000146: 13,2430 01121 LAT # UNIT RP = SIN(LONG)COS(LAT) 2-3D
049371,000147: 13,2431 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
049372,000148: 13,2432 00011 GAMRP
049373,000149: 13,2433 01121 LAT # 0-1D = GAMMA*SIN(LAT) B-2
049374,000150: 13,2434 65346 COS PDDL # PD4 2-3D = COS(LAT) B-1 TEMPORARILY
049375,000151: 13,2435 01123 LONG
049376,000152: 13,2436 57356 SIN DMPR # PD 2
049377,000153: 13,2437 71525 PDDL COS # PD 4 2-3D = SIN(LONG)COS(LAT) B-2
049378,000154: 13,2440 01121 LAT
049379,000155: 13,2441 71525 PDDL COS # PD 6 4-5D = COS(LAT) B-1 TEMPORARILY
049380,000156: 13,2442 01123 LONG
049381,000157: 13,2443 55475 DMPR VDEF # PD 4 MPAC = COS(LONG)COS(LAT) B-2
049382,000158: 13,2444 41456 UNIT PUSH # 0-5D= UNIT RP FOR RP-TO-R SUBR.
049383,000159: 13,2445 36032 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
049384,000160: 13,2446 26560 SETRE # RE METERS B-29
049385,000161: 13,2447 43145 DLOAD BOFF # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
049386,000162: 13,2450 24007 ZEROVEC
049387,000163: 13,2451 01743 LUNAFLAG
049388,000164: 13,2452 26454 CALLRPRT
049389,000165: 13,2453 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
049390,000166: 13,2454 77624 CALLRPRT CALL
049391,000167: 13,2455 55716 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
049392,000168: 13,2456 16032 STODL ALPHAV
049393,000169: 13,2457 03673 ERADM
Page 1136 |
049395,000171: 13,2460 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
049396,000172: 13,2461 01125 ALT
049397,000173: 13,2462 02032 ALPHAV
049398,000174: 13,2463 77772 VSL1 # R METERS B-29
049399,000175: 13,2464 36032 STCALL ALPHAV # EXIT WITH R IN METERS B-29
049400,000176: 13,2465 03674 INCORPEX
049401,000177:
049402,000178: # SUBROUTINE TO COMPUTE EARTH RADIUS
049403,000179:
049404,000180: # INPUT
049405,000181: # 1/2 SIN LAT IN ALPHAV +4
049406,000182:
049407,000183: # OUTPUT
049408,000184: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
049409,000185:
049410,000186: 13,2466 63545 GETERAD DLOAD DSQ
049411,000187: 13,2467 02036 ALPHAV +4 # SIN**2(L)
049412,000188: 13,2470 44352 SL1 BDSU
049413,000189: 13,2471 24005 DP1/2 # COS**2(L)
049414,000190: 13,2472 44275 DMPR BDSU
049415,000191: 13,2473 26507 EE
049416,000192: 13,2474 24005 DP1/2
049417,000193: 13,2475 75465 BDDV SQRT
049418,000194: 13,2476 26503 B2XSC
049419,000195: 13,2477 77622 SR4R
049420,000196: 13,2500 03673 STORE ERADM
049421,000197: 13,2501 77616 RVQ
049422,000198:
049423,000199: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
049424,000200: # B2XSC = B**2 SCALED B-51
049425,000201: # B2/A2 = B**2/A**2 SCALED B-1
049426,000202: # EE = (1-B**2/A**2) SCALED B-0
049427,000203:
049428,000204: 13,2502 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
049429,000205: 13,2504 12,2004 DP1/2 = XUNIT
049430,000206: 13,2504 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
049431,000207: 13,2506 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
049432,000208:
Page 1137 |
049434,000210: # ARCTAN SUBROUTINE
049435,000211:
049436,000212: # CALLING SEQUENCE
049437,000213: # SIN THETA IN SINTH B-1
049438,000214: # COS THETA IN COSTH B-1
049439,000215: # CALL ARCTAN
049440,000216:
049441,000217: # OUTPUT
049442,000218: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
049443,000219:
049444,000220: 13,2510 77600 ARCTAN BOV
049445,000221: 13,2511 26512 CLROVFLW
049446,000222: 13,2512 63545 CLROVFLW DLOAD DSQ
049447,000223: 13,2513 00023 SINTH
049448,000224: 13,2514 63525 PDDL DSQ
049449,000225: 13,2515 00021 COSTH
049450,000226: 13,2516 77615 DAD
049451,000227: 13,2517 75454 BZE SQRT
049452,000228: 13,2520 26536 ARCTANXX # ATAN=0/0 SET THETA=0
049453,000229: 13,2521 40065 BDDV BOV
049454,000230: 13,2522 00023 SINTH
049455,000231: 13,2523 26543 ATAN=90
049456,000232: 13,2524 67542 SR1 ASIN
049457,000233: 13,2525 00025 STORE THETA
049458,000234: 13,2526 50125 PDDL BMN
049459,000235: 13,2527 00021 COSTH
049460,000236: 13,2530 26532 NEGCOS
049461,000237: 13,2531 43545 DLOAD RVQ
049462,000238: 13,2532 57545 NEGCOS DLOAD DCOMP
049463,000239: 13,2533 43244 BPL DAD
049464,000240: 13,2534 26540 NEGOUT
049465,000241: 13,2535 24005 DP1/2
049466,000242: 13,2536 00025 ARCTANXX STORE THETA
049467,000243: 13,2537 77616 RVQ
049468,000244:
049469,000245: 13,2540 52025 NEGOUT DSU GOTO
049470,000246: 13,2541 24005 DP1/2
049471,000247: 13,2542 26536 ARCTANXX
049472,000248: 13,2543 75345 ATAN=90 DLOAD SIGN
049473,000249: 13,2544 11037 LODP1/4
049474,000250: 13,2545 00023 SINTH
049475,000251: 13,2546 00025 STORE THETA
049476,000252: 13,2547 77616 RVQ
049477,000253:
049478,000254: 13,2550 12,2006 2DZERO = DPZERO
049479,000255:
Page 1138 |
049481,000257: # ..... SETGAMMA SUBROUTINE .....
049482,000258: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
049483,000259:
049484,000260: # GAMMA = B**2/A**2 FOR EARTH (B-1)
049485,000261: # GAMMA = 1 FOR MOON (B-1)
049486,000262:
049487,000263: # CALLING SEQUENCE
049488,000264: # L CALL
049489,000265: # L+1 SETGAMMA
049490,000266:
049491,000267: # INPUT
049492,000268: # LUNAFLAG=0 FOR EARTH, =1 FOR MOON
049493,000269:
049494,000270: # OUTPUT
049495,000271: # GAMMA IN GAMRP (B-1)
049496,000272:
049497,000273: 13,2550 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
049498,000274: 13,2551 26505 B2/A2 # EARTH GAMMA
049499,000275: 13,2552 01743 LUNAFLAG
049500,000276: 13,2553 26556 SETGMEX
049501,000277: 13,2554 77735 SLOAD
049502,000278: 13,2555 24005 1B1 # MOON GAMMA
049503,000279: 13,2556 00011 SETGMEX STORE GAMRP
049504,000280: 13,2557 77616 RVQ
049505,000281: 13,2560 GAMRP = 8D
049506,000282:
Page 1139 |
049508,000284: # ..... SETRE SUBROUTINE .....
049509,000285: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
049510,000286:
049511,000287: # RE = RM FOR MOON
049512,000288: # RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
049513,000289:
049514,000290: # CALLING SEQUENCE
049515,000291: # L CALL
049516,000292: # L+1 SETRE
049517,000293:
049518,000294: # SUBROUTINES USED
049519,000295: # GETERAD
049520,000296:
049521,000297: # INPUT
049522,000298: # ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
049523,000299: # ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
049524,000300: # LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
049525,000301:
049526,000302: # OUTPUT
049527,000303: # ERADM = 504RM FOR MOON (METERS B-29)
049528,000304: # ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
049529,000305:
049530,000306: 13,2560 71220 SETRE STQ DLOAD
049531,000307: 13,2561 00051 SETREX
049532,000308: 13,2562 10003 504RM
049533,000309: 13,2563 71214 BON DLOAD # BRANCH FOR MOON
049534,000310: 13,2564 01703 LUNAFLAG
049535,000311: 13,2565 26575 TSTRLSRM
049536,000312: 13,2566 10001 ERAD
049537,000313: 13,2567 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
049538,000314: 13,2570 00742 ERADFLAG
049539,000315: 13,2571 26573 SETRXX
049540,000316: 13,2572 26466 GETERAD
049541,000317: 13,2573 37673 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
049542,000318: 13,2574 00051 SETREX
049543,000319: 13,2575 77214 TSTRLSRM BON VLOAD # ERADFLAG=0, SET R0=RLS
049544,000320: 13,2576 00702 ERADFLAG # =1 R0=RM
049545,000321: 13,2577 26573 SETRXX
049546,000322: 13,2600 02023 RLS
049547,000323: 13,2601 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
049548,000324: 13,2602 77650 GOTO
049549,000325: 13,2603 26573 SETRXX
049550,000326: 13,2604 0000051 SETREX = S2
049551,000327:
049552,000328:
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc