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