Source Code
These source-code files are part of a reconstructed copy of Luminary 96, the
original release of the Apollo 11 Lunar Module (LM) Apollo Guidance Computer
(AGC) software.
The reconstruction began with reconstructed source code for Luminary 97. Changes between revisions 96 and 97 were backed out, as described by anomal report LNY-59. transcribed from a digitized copy of that program. The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021152D. Note that page numbers in the reconstructed code match those on the Luminary 099 revision 001 printout, although the added code would likely have changed page numbers for a real Luminary 96 listing. 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. |
047281,000002: ## Copyright: Public domain.
047282,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
047283,000004: ## Purpose: A section of Luminary revision 96.
047284,000005: ## It is part of the reconstructed source code for the
047285,000006: ## original release of the flight software for the Lunar
047286,000007: ## Module's (LM) Apollo Guidance Computer (AGC) for Apollo 11.
047287,000008: ## The code has been recreated from a previously reconstructed
047288,000009: ## copy of Luminary 97 by undoing changes described in anomaly
047289,000010: ## report LNY-59. The code has been adapted such that the
047290,000011: ## resulting bugger words exactly match those specified for
047291,000012: ## Luminary 96 in NASA drawing 2021152D, which gives relatively
047292,000013: ## high confidence that the reconstruction is correct.
047293,000014: ## Reference: pp. 1133-1139
047294,000015: ## Assembler: yaYUL
047295,000016: ## Contact: Ron Burkey <info@sandroid.org>.
047296,000017: ## Website: www.ibiblio.org/apollo/index.html
047297,000018: ## Mod history: 2019-08-04 MAS Created from Luminary 97.
047298,000019:
Page 1133 |
047300,000021: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
047301,000022:
047302,000023: # CALLING SEQUENCE
047303,000024: # L-1 CALL
047304,000025: # L LAT-LONG
047305,000026:
047306,000027: # SUBROUTINES USED
047307,000028: # R-TO-RP, ARCTAN, SETGAMMA, SETRE
047308,000029:
047309,000030: # ERASABLE INIT. REQ.
047310,000031: # AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
047311,000032: # ALPHAV = POSITION VECTOR METERS B-29
047312,000033: # MPAC -- TIME (CSECS B-28)
047313,000034: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
047314,000035: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
047315,000036:
047316,000037: # OUTPUT
047317,000038: # LATITUDE IN LAT (REVS. B-0)
047318,000039: # LONGITUDE IN LONG (REVS. B-0)
047319,000040: # ALTITUDE IN ALT METERS B-29
047320,000041:
047321,000042: 30,3775 BANK 30
047322,000043: 13,2000 SETLOC LATLONG
047323,000044: 13,2000 BANK
047324,000045:
047325,000046: 13,2351 COUNT* $$/LT-LG
047326,000047: 13,2351 E4,1431 EBANK= ALPHAV
047327,000048: 13,2351 40220 LAT-LONG STQ SETPD
047328,000049: 13,2352 03674 INCORPEX
047329,000050: 13,2353 00001 0D
047330,000051: 13,2354 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
047331,000052: 13,2355 02032 ALPHAV
047332,000053: 13,2356 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
047333,000054: 13,2357 16070 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
047334,000055: 13,2360 24007 ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
047335,000056: 13,2361 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
047336,000057: 13,2362 01743 LUNAFLAG # 0=EARTH, 1=MOON
047337,000058: 13,2363 26364 CALLRTRP
047338,000059: 13,2364 77624 CALLRTRP CALL
047339,000060: 13,2365 51670 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
047340,000061: 13,2366 77656 UNIT # UNIT RP B-1
047341,000062: 13,2367 36032 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
047342,000063: 13,2370 26550 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
047343,000064: 13,2371 77624 CALL # SCALED B-1
047344,000065: 13,2372 26560 SETRE # CALC RE METERS B-29
047345,000066: 13,2373 63545 DLOAD DSQ
047346,000067: 13,2374 02032 ALPHAV
047347,000068: 13,2375 63525 PDDL DSQ
047348,000069: 13,2376 02034 ALPHAV +2
047349,000070: 13,2377 75415 DAD SQRT
Page 1134 |
047351,000072: 13,2400 76405 DMP SL1R
047352,000073: 13,2401 00011 GAMRP
047353,000074: 13,2402 14021 STODL COSTH # COS(LAT) B-1
047354,000075: 13,2403 02036 ALPHAV +4
047355,000076: 13,2404 34023 STCALL SINTH # SIN(LAT) B-1
047356,000077: 13,2405 26510 ARCTAN
047357,000078: 13,2406 15121 STODL LAT # LAT B0
047358,000079: 13,2407 02032 ALPHAV
047359,000080: 13,2410 14021 STODL COSTH # COS(LONG) B-1
047360,000081: 13,2411 02034 ALPHAV +2
047361,000082: 13,2412 34023 STCALL SINTH # SIN(LONG) B-1
047362,000083: 13,2413 26510 ARCTAN
047363,000084: 13,2414 15123 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
047364,000085: 13,2415 02070 ALPHAM
047365,000086: 13,2416 77625 DSU # ALT= R-RE METERS B-29
047366,000087: 13,2417 03673 ERADM
047367,000088: 13,2420 35125 STCALL ALT # EXIT WITH ALT METERS B-29
047368,000089: 13,2421 03674 INCORPEX
Page 1135 |
047370,000091: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
047371,000092:
047372,000093: # CALLING SEQUENCE
047373,000094: # L-1 CALL
047374,000095: # L LALOTORV
047375,000096:
047376,000097: # SUBROUTINES USED
047377,000098: # SETGAMMA, SETRE, RP-TO-R
047378,000099:
047379,000100: # ERASABLE INIT. REQ.
047380,000101: # AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
047381,000102: # LAT -- LATITUDE (REVS B0)
047382,000103: # LONG -- LONGITUDE (REVS B0)
047383,000104: # ALT -- ALTITUDE (METERS) B-29
047384,000105: # MPAC -- TIME (CSECS B-28)
047385,000106: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
047386,000107: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
047387,000108:
047388,000109: # OUTPUT
047389,000110: # R-VECTOR IN ALPHAV (METERS B-29)
047390,000111:
047391,000112: 13,2422 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
047392,000113: 13,2423 03674 INCORPEX
047393,000114: 13,2424 00001 0D
047394,000115: 13,2425 34007 STCALL 6D # 6-7D= TIME FOR RP-TO-R
047395,000116: 13,2426 26550 SETGAMMA # GAMMA=B2/A2 FOR EARTH, 1 FOR MOON B-1
047396,000117: 13,2427 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
047397,000118: 13,2430 01121 LAT # UNIT RP = SIN(LONG)COS(LAT) 2-3D
047398,000119: 13,2431 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
047399,000120: 13,2432 00011 GAMRP
047400,000121: 13,2433 01121 LAT # 0-1D = GAMMA*SIN(LAT) B-2
047401,000122: 13,2434 65346 COS PDDL # PD4 2-3D = COS(LAT) B-1 TEMPORARILY
047402,000123: 13,2435 01123 LONG
047403,000124: 13,2436 57356 SIN DMPR # PD 2
047404,000125: 13,2437 71525 PDDL COS # PD 4 2-3D = SIN(LONG)COS(LAT) B-2
047405,000126: 13,2440 01121 LAT
047406,000127: 13,2441 71525 PDDL COS # PD 6 4-5D = COS(LAT) B-1 TEMPORARILY
047407,000128: 13,2442 01123 LONG
047408,000129: 13,2443 55475 DMPR VDEF # PD 4 MPAC = COS(LONG)COS(LAT) B-2
047409,000130: 13,2444 41456 UNIT PUSH # 0-5D= UNIT RP FOR RP-TO-R SUBR.
047410,000131: 13,2445 36032 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
047411,000132: 13,2446 26560 SETRE # RE METERS B-29
047412,000133: 13,2447 43145 DLOAD BOFF # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
047413,000134: 13,2450 24007 ZEROVEC
047414,000135: 13,2451 01743 LUNAFLAG
047415,000136: 13,2452 26454 CALLRPRT
047416,000137: 13,2453 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
047417,000138: 13,2454 77624 CALLRPRT CALL
047418,000139: 13,2455 55716 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
047419,000140: 13,2456 16032 STODL ALPHAV
047420,000141: 13,2457 03673 ERADM
Page 1136 |
047422,000143: 13,2460 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
047423,000144: 13,2461 01125 ALT
047424,000145: 13,2462 02032 ALPHAV
047425,000146: 13,2463 77772 VSL1 # R METERS B-29
047426,000147: 13,2464 36032 STCALL ALPHAV # EXIT WITH R IN METERS B-29
047427,000148: 13,2465 03674 INCORPEX
047428,000149:
047429,000150: # SUBROUTINE TO COMPUTE EARTH RADIUS
047430,000151:
047431,000152: # INPUT
047432,000153: # 1/2 SIN LAT IN ALPHAV +4
047433,000154:
047434,000155: # OUTPUT
047435,000156: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
047436,000157:
047437,000158: 13,2466 63545 GETERAD DLOAD DSQ
047438,000159: 13,2467 02036 ALPHAV +4 # SIN**2(L)
047439,000160: 13,2470 44352 SL1 BDSU
047440,000161: 13,2471 24005 DP1/2 # COS**2(L)
047441,000162: 13,2472 44275 DMPR BDSU
047442,000163: 13,2473 26507 EE
047443,000164: 13,2474 24005 DP1/2
047444,000165: 13,2475 75465 BDDV SQRT
047445,000166: 13,2476 26503 B2XSC
047446,000167: 13,2477 77622 SR4R
047447,000168: 13,2500 03673 STORE ERADM
047448,000169: 13,2501 77616 RVQ
047449,000170:
047450,000171: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
047451,000172: # B2XSC = B**2 SCALED B-51
047452,000173: # B2/A2 = B**2/A**2 SCALED B-1
047453,000174: # EE = (1-B**2/A**2) SCALED B-0
047454,000175:
047455,000176: 13,2502 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
047456,000177: 13,2504 12,2004 DP1/2 = XUNIT
047457,000178: 13,2504 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
047458,000179: 13,2506 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
047459,000180:
Page 1137 |
047461,000182: # ARCTAN SUBROUTINE
047462,000183:
047463,000184: # CALLING SEQUENCE
047464,000185: # SIN THETA IN SINTH B-1
047465,000186: # COS THETA IN COSTH B-1
047466,000187: # CALL ARCTAN
047467,000188:
047468,000189: # OUTPUT
047469,000190: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
047470,000191:
047471,000192: 13,2510 77600 ARCTAN BOV
047472,000193: 13,2511 26512 CLROVFLW
047473,000194: 13,2512 63545 CLROVFLW DLOAD DSQ
047474,000195: 13,2513 00023 SINTH
047475,000196: 13,2514 63525 PDDL DSQ
047476,000197: 13,2515 00021 COSTH
047477,000198: 13,2516 77615 DAD
047478,000199: 13,2517 75454 BZE SQRT
047479,000200: 13,2520 26536 ARCTANXX # ATAN=0/0 SET THETA=0
047480,000201: 13,2521 40065 BDDV BOV
047481,000202: 13,2522 00023 SINTH
047482,000203: 13,2523 26543 ATAN=90
047483,000204: 13,2524 67542 SR1 ASIN
047484,000205: 13,2525 00025 STORE THETA
047485,000206: 13,2526 50125 PDDL BMN
047486,000207: 13,2527 00021 COSTH
047487,000208: 13,2530 26532 NEGCOS
047488,000209: 13,2531 43545 DLOAD RVQ
047489,000210: 13,2532 57545 NEGCOS DLOAD DCOMP
047490,000211: 13,2533 43244 BPL DAD
047491,000212: 13,2534 26540 NEGOUT
047492,000213: 13,2535 24005 DP1/2
047493,000214: 13,2536 00025 ARCTANXX STORE THETA
047494,000215: 13,2537 77616 RVQ
047495,000216:
047496,000217: 13,2540 52025 NEGOUT DSU GOTO
047497,000218: 13,2541 24005 DP1/2
047498,000219: 13,2542 26536 ARCTANXX
047499,000220: 13,2543 75345 ATAN=90 DLOAD SIGN
047500,000221: 13,2544 11037 LODP1/4
047501,000222: 13,2545 00023 SINTH
047502,000223: 13,2546 00025 STORE THETA
047503,000224: 13,2547 77616 RVQ
047504,000225:
047505,000226: 13,2550 12,2006 2DZERO = DPZERO
047506,000227:
Page 1138 |
047508,000229: # ..... SETGAMMA SUBROUTINE .....
047509,000230: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
047510,000231:
047511,000232: # GAMMA = B**2/A**2 FOR EARTH (B-1)
047512,000233: # GAMMA = 1 FOR MOON (B-1)
047513,000234:
047514,000235: # CALLING SEQUENCE
047515,000236: # L CALL
047516,000237: # L+1 SETGAMMA
047517,000238:
047518,000239: # INPUT
047519,000240: # LUNAFLAG=0 FOR EARTH, =1 FOR MOON
047520,000241:
047521,000242: # OUTPUT
047522,000243: # GAMMA IN GAMRP (B-1)
047523,000244:
047524,000245: 13,2550 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
047525,000246: 13,2551 26505 B2/A2 # EARTH GAMMA
047526,000247: 13,2552 01743 LUNAFLAG
047527,000248: 13,2553 26556 SETGMEX
047528,000249: 13,2554 77735 SLOAD
047529,000250: 13,2555 24005 1B1 # MOON GAMMA
047530,000251: 13,2556 00011 SETGMEX STORE GAMRP
047531,000252: 13,2557 77616 RVQ
047532,000253: 13,2560 GAMRP = 8D
047533,000254:
Page 1139 |
047535,000256: # ..... SETRE SUBROUTINE .....
047536,000257: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
047537,000258:
047538,000259: # RE = RM FOR MOON
047539,000260: # RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
047540,000261:
047541,000262: # CALLING SEQUENCE
047542,000263: # L CALL
047543,000264: # L+1 SETRE
047544,000265:
047545,000266: # SUBROUTINES USED
047546,000267: # GETERAD
047547,000268:
047548,000269: # INPUT
047549,000270: # ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
047550,000271: # ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
047551,000272: # LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
047552,000273:
047553,000274: # OUTPUT
047554,000275: # ERADM = 504RM FOR MOON (METERS B-29)
047555,000276: # ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
047556,000277:
047557,000278: 13,2560 71220 SETRE STQ DLOAD
047558,000279: 13,2561 00051 SETREX
047559,000280: 13,2562 10003 504RM
047560,000281: 13,2563 71214 BON DLOAD # BRANCH FOR MOON
047561,000282: 13,2564 01703 LUNAFLAG
047562,000283: 13,2565 26575 TSTRLSRM
047563,000284: 13,2566 10001 ERAD
047564,000285: 13,2567 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
047565,000286: 13,2570 00742 ERADFLAG
047566,000287: 13,2571 26573 SETRXX
047567,000288: 13,2572 26466 GETERAD
047568,000289: 13,2573 37673 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
047569,000290: 13,2574 00051 SETREX
047570,000291: 13,2575 77214 TSTRLSRM BON VLOAD # ERADFLAG=0, SET R0=RLS
047571,000292: 13,2576 00702 ERADFLAG # =1 R0=RM
047572,000293: 13,2577 26573 SETRXX
047573,000294: 13,2600 02023 RLS
047574,000295: 13,2601 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
047575,000296: 13,2602 77650 GOTO
047576,000297: 13,2603 26573 SETRXX
047577,000298: 13,2604 0000051 SETREX = S2
047578,000299:
047579,000300:
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc