Source Code
These source-code files are part of a reconstructed copy of Comanche 72/3 (AKA Manche72 revision 3),
the final, flown mission release of the Apollo Guidance Computer (AGC) Command Module (CM) software
for Apollo 13.
The starting point was the source code of Comanche 72 (itself previously reconstructed). Comanche 72 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 72 and 72/3. The resulting code assembles to have identical memory-bank checksums as those specified in NASA drawing 2021153G; this gives reasonably high confidence that the changes that have been made are correct. In places where ambiguity exists, this ambiguity is discussed in "## Reconstruction:" comments. Since no contemporary listings of Comanche 72/3 are available as source material, all comments and labels are approximate. They have been taken from other AGC programs where possible, or, in some places, written from scratch to match what we believe would have been in the original listing. |
051535,000002: ## Copyright: Public domain.
051536,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
051537,000004: ## Purpose: A section of Manche72 revision 3.
051538,000005: ## It is part of the reconstructed source code for the final, flown
051539,000006: ## release of the software for the Command Module's (CM) Apollo
051540,000007: ## Guidance Computer (AGC) for Apollo 13. No original listings
051541,000008: ## of this program are available; instead, this file was recreated
051542,000009: ## from a reconstructed copy of Comanche 072. It has been adapted
051543,000010: ## such that the resulting bugger words exactly match those
051544,000011: ## specified for Manche72 revision 3 in NASA drawing 2021153G,
051545,000012: ## which gives relatively high confidence that the reconstruction
051546,000013: ## is correct.
051547,000014: ## Assembler: yaYUL
051548,000015: ## Contact: Ron Burkey <info@sandroid.org>.
051549,000016: ## Website: www.ibiblio.org/apollo/index.html
051550,000017: ## Mod history: 2024-05-19 MAS Created from Comanche 072.
051551,000018:
051552,000019: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
051553,000020:
051554,000021: # CALLING SEQUENCE
051555,000022: # L-1 CALL
051556,000023: # L LAT-LONG
051557,000024:
051558,000025: # SUBROUTINES USED
051559,000026: # R-TO-RP, ARCTAN, SETGAMMA, SETRE
051560,000027:
051561,000028: # ERASABLE INIT. REQ.
051562,000029: # AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
051563,000030: # ALPHAV = POSITION VECTOR METERS B-29
051564,000031: # MPAC -- TIME (CSECS B-28)
051565,000032: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
051566,000033: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
051567,000034:
051568,000035: # OUTPUT
051569,000036: # LATITUDE IN LAT (REVS. B-0)
051570,000037: # LONGITUDE IN LONG (REVS. B-0)
051571,000038: # ALTITUDE IN ALT METERS B-29
051572,000039:
051573,000040: 30,3750 BANK 30
051574,000041: 13,2000 SETLOC LATLONG
051575,000042: 13,2000 BANK
051576,000043:
051577,000044: 13,2376 COUNT 13/LT-LG
051578,000045:
051579,000046: 13,2376 E4,1551 EBANK= ALPHAV
051580,000047: 13,2376 40220 LAT-LONG STQ SETPD
051581,000048: 13,2377 02242 INCORPEX
051582,000049: 13,2400 00001 0D
051583,000050: 13,2401 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
051584,000051: 13,2402 02152 ALPHAV
051585,000052: 13,2403 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
051586,000053: 13,2404 16310 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
051587,000054: 13,2405 11566 ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
051588,000055: 13,2406 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
051589,000056: 13,2407 01743 LUNAFLAG # 0=EARTH, 1=MOON
051590,000057: 13,2410 26411 CALLRTRP
051591,000058: 13,2411 77624 CALLRTRP CALL
051592,000059: 13,2412 55370 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
051593,000060: 13,2413 77656 UNIT # UNIT RP B-1
051594,000061: 13,2414 36152 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
051595,000062: 13,2415 26577 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
051596,000063: 13,2416 77624 CALL # SCALED B-1
051597,000064: 13,2417 26607 SETRE # CALC RE METERS B-29
051598,000065: 13,2420 63545 DLOAD DSQ
051599,000066: 13,2421 02152 ALPHAV
051600,000067: 13,2422 63525 PDDL DSQ
051601,000068: 13,2423 02154 ALPHAV +2
051602,000069: 13,2424 75415 DAD SQRT
051603,000070: 13,2425 76405 DMP SL1R
051604,000071: 13,2426 00011 GAMRP
051605,000072: 13,2427 14021 STODL COSTH # COS(LAT) B-1
051606,000073: 13,2430 02156 ALPHAV +4
051607,000074: 13,2431 34023 STCALL SINTH # SIN(LAT) B-1
051608,000075: 13,2432 26537 ARCTAN
051609,000076: 13,2433 15104 STODL LAT # LAT B0
051610,000077: 13,2434 02152 ALPHAV
051611,000078: 13,2435 14021 STODL COSTH # COS(LONG) B-1
051612,000079: 13,2436 02154 ALPHAV +2
051613,000080: 13,2437 34023 STCALL SINTH # SIN(LONG) B-1
051614,000081: 13,2440 26537 ARCTAN
051615,000082: 13,2441 15106 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
051616,000083: 13,2442 02310 ALPHAM
051617,000084: 13,2443 77625 DSU # ALT= R-RE METERS B-29
051618,000085: 13,2444 02241 ERADM
051619,000086: 13,2445 35110 STCALL ALT # EXIT WITH ALT METERS B-29
051620,000087: 13,2446 02242 INCORPEX
051621,000088: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
051622,000089:
051623,000090: # CALLING SEQUENCE
051624,000091: # L-1 CALL
051625,000092: # L LALOTORV
051626,000093:
051627,000094: # SUBROUTINES USED
051628,000095: # SETGAMMA, SETRE, RP-TO-R
051629,000096:
051630,000097: # ERASABLE INIT. REQ.
051631,000098: # AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
051632,000099: # LAT -- LATITUDE (REVS B0)
051633,000100: # LONG -- LONGITUDE (REVS B0)
051634,000101: # ALT -- ALTITUDE (METERS) B-29
051635,000102: # MPAC -- TIME (CSECS B-28)
051636,000103: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
051637,000104: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
051638,000105:
051639,000106: # OUTPUT
051640,000107: # R-VECTOR IN ALPHAV (METERS B-29)
051641,000108:
051642,000109: 13,2447 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
051643,000110: 13,2450 02242 INCORPEX
051644,000111: 13,2451 00001 0D
051645,000112: 13,2452 34007 STCALL 6D # 6-7D = TIME FOR RP-TO-R
051646,000113: 13,2453 26577 SETGAMMA # GAMMA = B2/A2 FOR EARTH, 1 FOR MOON B-1
051647,000114: 13,2454 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
051648,000115: 13,2455 01104 LAT # UNIT RP = SIN(LONG)COS(LAT) 2-3D
051649,000116: 13,2456 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
051650,000117: 13,2457 00011 GAMRP
051651,000118: 13,2460 01104 LAT # 0-1D = GAMMA*SIN(LAT) B-2
051652,000119: 13,2461 65346 COS PDDL # PD4 2-3D= COS(LAT) B-1 TEMPORARILY
051653,000120: 13,2462 01106 LONG
051654,000121: 13,2463 57356 SIN DMPR # PD 2
051655,000122: 13,2464 71525 PDDL COS # PD 4 2-3D= SIN(LONG)COS(LAT) B-2
051656,000123: 13,2465 01104 LAT
051657,000124: 13,2466 71525 PDDL COS # PD 6 4-5D= COS(LAT) B-1 TEMPORARILY
051658,000125: 13,2467 01106 LONG
051659,000126: 13,2470 55475 DMPR VDEF # PD4 MPAC = COS(LONG)COS(LAT) B-2
051660,000127: 13,2471 41456 UNIT PUSH # 0-5D = UNIT RP FOR RP-TO-R SUBR.
051661,000128: 13,2472 36152 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
051662,000129: 13,2473 26607 SETRE # RE METERS B-29
051663,000130: 13,2474 43145 DLOAD BOFF # SET MPAC = 0 FOR EARTH, NON-ZERO FOR MOON
051664,000131: 13,2475 11566 ZEROVEC
051665,000132: 13,2476 01743 LUNAFLAG
051666,000133: 13,2477 26501 CALLRPRT
051667,000134: 13,2500 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
051668,000135: 13,2501 77624 CALLRPRT CALL
051669,000136: 13,2502 55343 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
051670,000137: 13,2503 16152 STODL ALPHAV
051671,000138: 13,2504 02241 ERADM
051672,000139: 13,2505 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
051673,000140: 13,2506 01110 ALT
051674,000141: 13,2507 02152 ALPHAV
051675,000142: 13,2510 77772 VSL1 # R METERS B-29
051676,000143: 13,2511 36152 STCALL ALPHAV # EXIT WITH R IN METERS B-29
051677,000144: 13,2512 02242 INCORPEX
051678,000145:
051679,000146: # SUBROUTINE TO COMPUTE EARTH RADIUS
051680,000147:
051681,000148: # INPUT
051682,000149: # 1/2 SIN LAT IN ALPHAV +4
051683,000150:
051684,000151: # OUTPUT
051685,000152: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
051686,000153:
051687,000154: 13,2513 63545 GETERAD DLOAD DSQ
051688,000155: 13,2514 02156 ALPHAV +4 # SIN**2(L)
051689,000156: 13,2515 44352 SL1 BDSU
051690,000157: 13,2516 11564 DP1/2 # COS**2(L)
051691,000158: 13,2517 44275 DMPR BDSU
051692,000159: 13,2520 26534 EE
051693,000160: 13,2521 11564 DP1/2
051694,000161: 13,2522 75465 BDDV SQRT
051695,000162: 13,2523 26530 B2XSC
051696,000163: 13,2524 77622 SR4R
051697,000164: 13,2525 02241 STORE ERADM
051698,000165: 13,2526 77616 RVQ
051699,000166:
051700,000167: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
051701,000168: # B2XSC = B**2 SCALED B-51
051702,000169: # B2/A2 = B**2/A**2 SCALED B-1
051703,000170: # EE = (1-B**2/A**2) SCALED B-0
051704,000171:
051705,000172: 13,2527 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
051706,000173:
051707,000174: 13,2531 04,3563 DP1/2 = XUNIT
051708,000175: 13,2531 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
051709,000176:
051710,000177: 13,2533 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
051711,000178:
051712,000179: 13,2535 00302 17755 ERAD 2DEC 6373338 B-29 # PAD RADIUS
051713,000180:
051714,000181: # ARCTAN SUBROUTINE
051715,000182:
051716,000183: # CALLING SEQUENCE
051717,000184: # SIN THETA IN SINTH B-1
051718,000185: # COS THETA IN COSTH B-1
051719,000186: # CALL ARCTAN
051720,000187:
051721,000188: # OUTPUT
051722,000189: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
051723,000190:
051724,000191: 13,2537 77600 ARCTAN BOV
051725,000192: 13,2540 26541 CLROVFLW
051726,000193: 13,2541 63545 CLROVFLW DLOAD DSQ
051727,000194: 13,2542 00023 SINTH
051728,000195: 13,2543 63525 PDDL DSQ
051729,000196: 13,2544 00021 COSTH
051730,000197: 13,2545 77615 DAD
051731,000198: 13,2546 75454 BZE SQRT
051732,000199: 13,2547 26565 ARCTANXX # ATAN=0/0 SET THETA=0
051733,000200: 13,2550 40065 BDDV BOV
051734,000201: 13,2551 00023 SINTH
051735,000202: 13,2552 26572 ATAN=90
051736,000203: 13,2553 67542 SR1 ASIN
051737,000204: 13,2554 00025 STORE THETA
051738,000205: 13,2555 50125 PDDL BMN
051739,000206: 13,2556 00021 COSTH
051740,000207: 13,2557 26561 NEGCOS
051741,000208: 13,2560 43545 DLOAD RVQ
051742,000209: 13,2561 57545 NEGCOS DLOAD DCOMP
051743,000210: 13,2562 43244 BPL DAD
051744,000211: 13,2563 26567 NEGOUT
051745,000212: 13,2564 11564 DP1/2
051746,000213: 13,2565 00025 ARCTANXX STORE THETA
051747,000214: 13,2566 77616 RVQ
051748,000215:
051749,000216: 13,2567 52025 NEGOUT DSU GOTO
051750,000217: 13,2570 11564 DP1/2
051751,000218: 13,2571 26565 ARCTANXX
051752,000219: 13,2572 75345 ATAN=90 DLOAD SIGN
051753,000220: 13,2573 11612 LODP1/4
051754,000221: 13,2574 00023 SINTH
051755,000222: 13,2575 00025 STORE THETA
051756,000223: 13,2576 77616 RVQ
051757,000224:
051758,000225: 13,2577 04,3565 2DZERO = DPZERO
051759,000226:
051760,000227: # ..... SETGAMMA SUBROUTINE .....
051761,000228: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
051762,000229:
051763,000230: # GAMMA = B**2/A**2 FOR EARTH (B-1)
051764,000231: # GAMMA = 1 FOR MOON (B-1)
051765,000232:
051766,000233: # CALLING SEQUENCE
051767,000234: # L CALL
051768,000235: # L+1 SETGAMMA
051769,000236:
051770,000237: # INPUT
051771,000238: # LUNAFLAG=0 FOR EARTH, =1 FOR MOON
051772,000239:
051773,000240: # OUTPUT
051774,000241: # GAMMA IN GAMRP (B-1)
051775,000242:
051776,000243: 13,2577 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
051777,000244: 13,2600 26532 B2/A2 # EARTH GAMMA
051778,000245: 13,2601 01743 LUNAFLAG
051779,000246: 13,2602 26605 SETGMEX
051780,000247: 13,2603 77735 SLOAD
051781,000248: 13,2604 11564 1B1 # MOON GAMMA
051782,000249: 13,2605 00011 SETGMEX STORE GAMRP
051783,000250: 13,2606 77616 RVQ
051784,000251: 13,2607 GAMRP = 8D
051785,000252:
051786,000253: # ..... SETRE SUBROUTINE .....
051787,000254: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
051788,000255:
051789,000256: # RE = RM FOR MOON
051790,000257: # RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
051791,000258:
051792,000259: # CALLING SEQUENCE
051793,000260: # L CALL
051794,000261: # L+1 SETRE
051795,000262:
051796,000263: # SUBROUTINES USED
051797,000264: # GETERAD
051798,000265:
051799,000266: # INPUT
051800,000267: # ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
051801,000268: # ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
051802,000269: # LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
051803,000270:
051804,000271: # OUTPUT
051805,000272: # ERADM = 504RM FOR MOON (METERS B-29)
051806,000273: # ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
051807,000274:
051808,000275: 13,2607 71220 SETRE STQ DLOAD
051809,000276: 13,2610 00051 SETREX
051810,000277: 13,2611 26634 504RM
051811,000278: 13,2612 71214 BON DLOAD # BRANCH FOR MOON
051812,000279: 13,2613 01703 LUNAFLAG
051813,000280: 13,2614 26624 TSTRLSRM
051814,000281: 13,2615 26536 ERAD
051815,000282: 13,2616 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
051816,000283: 13,2617 00742 ERADFLAG
051817,000284: 13,2620 26622 SETRXX
051818,000285: 13,2621 26513 GETERAD
051819,000286: 13,2622 36241 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
051820,000287: 13,2623 00051 SETREX
051821,000288: 13,2624 77214 TSTRLSRM BON VLOAD # ERADFLAG=0, SET R0=RLS
051822,000289: 13,2625 00702 ERADFLAG # =1 R0=RM
051823,000290: 13,2626 26622 SETRXX
051824,000291: 13,2627 02026 RLS
051825,000292: 13,2630 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
051826,000293: 13,2631 77650 GOTO
051827,000294: 13,2632 26622 SETRXX
051828,000295: 13,2633 0000051 SETREX = S2
051829,000296: 13,2633 00065 01265 504RM 2DEC 1738090 B-29 # METERS B-29 (MOON RADIUS)
051830,000297:
051831,000298:
051832,000299:
051833,000300:
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc