Source Code
These source-code files are part of a reconstructed copy of Comanche 45, the
second release, though not the final mission release, of the Apollo 10
Command Module (CM) Apollo Guidance Computer (AGC) software. Comanche 45 was
preceded by Comanche 44 and followed by Comanche 45/2 (the flown release). The reconstruction
is believed to be exactly accurate, but in the absence of an actual Apollo-era
listing of Comanche 45, some explanation of the reconstruction process is needed
to insure confidence in that accuracy.
The starting point was the source code of Comanche 44 (itself previously accurately reconstructed). Comanche 44 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 44 and 45. The now-reconstructed Comanche 45 source code was verified by assembling it and checking that the assembled code had the expected known-correct memory-bank checksums. Note that page numbers in the reconstructed code tend to match those in the Comanche 55, the most-similar revision of Comanche for which we have access to an actual non-reconstructed hardcopy; the source code would likely have different page numbers in a contemporary Comanche 45 listing. Annotations that were not present in the contemporary source code have been added to the reconstructed code to justify each change relative to Comanche 44. Here's a guide to the Apollo documentation referenced in those annotations:
Comments expected to have been present in 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. |
052526,000002: ## Copyright: Public domain.
052527,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
052528,000004: ## Purpose: A section of Comanche revision 045.
052529,000005: ## It is part of the reconstructed source code for the
052530,000006: ## second release of the flight software for the Command
052531,000007: ## Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
052532,000008: ## The code has been recreated from a copy of Comanche 055. It
052533,000009: ## has been adapted such that the resulting bugger words
052534,000010: ## exactly match those specified for Comanche 45 in NASA drawing
052535,000011: ## 2021153D, which gives relatively high confidence that the
052536,000012: ## reconstruction is correct.
052537,000013: ## Assembler: yaYUL
052538,000014: ## Contact: Ron Burkey <info@sandroid.org>.
052539,000015: ## Website: www.ibiblio.org/apollo/index.html
052540,000016: ## Mod history: 2020-12-06 MAS Created from Comanche 44.
052541,000017:
Page 1236 |
052543,000019: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
052544,000020:
052545,000021: # CALLING SEQUENCE
052546,000022: # L-1 CALL
052547,000023: # L LAT-LONG
052548,000024:
052549,000025: # SUBROUTINES USED
052550,000026: # R-TO-RP, ARCTAN, SETGAMMA, SETRE
052551,000027:
052552,000028: # ERASABLE INIT. REQ.
052553,000029: # AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
052554,000030: # ALPHAV = POSITION VECTOR METERS B-29
052555,000031: # MPAC -- TIME (CSECS B-28)
052556,000032: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
052557,000033: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
052558,000034:
052559,000035: # OUTPUT
052560,000036: # LATITUDE IN LAT (REVS. B-0)
052561,000037: # LONGITUDE IN LONG (REVS. B-0)
052562,000038: # ALTITUDE IN ALT METERS B-29
052563,000039:
052564,000040: 30,3750 BANK 30
052565,000041: 13,2000 SETLOC LATLONG
052566,000042: 13,2000 BANK
052567,000043:
052568,000044: 13,2370 COUNT 13/LT-LG
052569,000045:
052570,000046: 13,2370 E4,1551 EBANK= ALPHAV
052571,000047: 13,2370 40220 LAT-LONG STQ SETPD
052572,000048: 13,2371 02242 INCORPEX
052573,000049: 13,2372 00001 0D
052574,000050: 13,2373 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
052575,000051: 13,2374 02152 ALPHAV
052576,000052: 13,2375 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
052577,000053: 13,2376 16310 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
052578,000054: 13,2377 11563 ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
052579,000055: 13,2400 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
052580,000056: 13,2401 01743 LUNAFLAG # 0=EARTH, 1=MOON
052581,000057: 13,2402 26403 CALLRTRP
052582,000058: 13,2403 77624 CALLRTRP CALL
052583,000059: 13,2404 55371 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
052584,000060: 13,2405 77656 UNIT # UNIT RP B-1
052585,000061: 13,2406 36152 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
052586,000062: 13,2407 26571 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
052587,000063: 13,2410 77624 CALL # SCALED B-1
052588,000064: 13,2411 26601 SETRE # CALC RE METERS B-29
052589,000065: 13,2412 63545 DLOAD DSQ
052590,000066: 13,2413 02152 ALPHAV
052591,000067: 13,2414 63525 PDDL DSQ
052592,000068: 13,2415 02154 ALPHAV +2
Page 1237 |
052594,000070: 13,2416 75415 DAD SQRT
052595,000071: 13,2417 76405 DMP SL1R
052596,000072: 13,2420 00011 GAMRP
052597,000073: 13,2421 14021 STODL COSTH # COS(LAT) B-1
052598,000074: 13,2422 02156 ALPHAV +4
052599,000075: 13,2423 34023 STCALL SINTH # SIN(LAT) B-1
052600,000076: 13,2424 26531 ARCTAN
052601,000077: 13,2425 15104 STODL LAT # LAT B0
052602,000078: 13,2426 02152 ALPHAV
052603,000079: 13,2427 14021 STODL COSTH # COS(LONG) B-1
052604,000080: 13,2430 02154 ALPHAV +2
052605,000081: 13,2431 34023 STCALL SINTH # SIN(LONG) B-1
052606,000082: 13,2432 26531 ARCTAN
052607,000083: 13,2433 15106 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
052608,000084: 13,2434 02310 ALPHAM
052609,000085: 13,2435 77625 DSU # ALT= R-RE METERS B-29
052610,000086: 13,2436 02241 ERADM
052611,000087: 13,2437 35110 STCALL ALT # EXIT WITH ALT METERS B-29
052612,000088: 13,2440 02242 INCORPEX
Page 1238 |
052614,000090: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
052615,000091:
052616,000092: # CALLING SEQUENCE
052617,000093: # L-1 CALL
052618,000094: # L LALOTORV
052619,000095:
052620,000096: # SUBROUTINES USED
052621,000097: # SETGAMMA, SETRE, RP-TO-R
052622,000098:
052623,000099: # ERASABLE INIT. REQ.
052624,000100: # AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
052625,000101: # LAT -- LATITUDE (REVS B0)
052626,000102: # LONG -- LONGITUDE (REVS B0)
052627,000103: # ALT -- ALTITUDE (METERS) B-29
052628,000104: # MPAC -- TIME (CSECS B-28)
052629,000105: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
052630,000106: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
052631,000107:
052632,000108: # OUTPUT
052633,000109: # R-VECTOR IN ALPHAV (METERS B-29)
052634,000110:
052635,000111: 13,2441 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
052636,000112: 13,2442 02242 INCORPEX
052637,000113: 13,2443 00001 0D
052638,000114: 13,2444 34007 STCALL 6D # 6-7D = TIME FOR RP-TO-R
052639,000115: 13,2445 26571 SETGAMMA # GAMMA = B2/A2 FOR EARTH, 1 FOR MOON B-1
052640,000116: 13,2446 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
052641,000117: 13,2447 01104 LAT # UNIT RP = SIN(LONG)COS(LAT) 2-3D
052642,000118: 13,2450 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
052643,000119: 13,2451 00011 GAMRP
052644,000120: 13,2452 01104 LAT # 0-1D = GAMMA*SIN(LAT) B-2
052645,000121: 13,2453 65346 COS PDDL # PD4 2-3D= COS(LAT) B-1 TEMPORARILY
052646,000122: 13,2454 01106 LONG
052647,000123: 13,2455 57356 SIN DMPR # PD 2
052648,000124: 13,2456 71525 PDDL COS # PD 4 2-3D= SIN(LONG)COS(LAT) B-2
052649,000125: 13,2457 01104 LAT
052650,000126: 13,2460 71525 PDDL COS # PD 6 4-5D= COS(LAT) B-1 TEMPORARILY
052651,000127: 13,2461 01106 LONG
052652,000128: 13,2462 55475 DMPR VDEF # PD4 MPAC = COS(LONG)COS(LAT) B-2
052653,000129: 13,2463 41456 UNIT PUSH # 0-5D = UNIT RP FOR RP-TO-R SUBR.
052654,000130: 13,2464 36152 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
052655,000131: 13,2465 26601 SETRE # RE METERS B-29
052656,000132: 13,2466 43145 DLOAD BOFF # SET MPAC = 0 FOR EARTH, NON-ZERO FOR MOON
052657,000133: 13,2467 11563 ZEROVEC
052658,000134: 13,2470 01743 LUNAFLAG
052659,000135: 13,2471 26473 CALLRPRT
052660,000136: 13,2472 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
052661,000137: 13,2473 77624 CALLRPRT CALL
052662,000138: 13,2474 55344 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
052663,000139: 13,2475 16152 STODL ALPHAV
052664,000140: 13,2476 02241 ERADM
Page 1239 |
052666,000142: 13,2477 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
052667,000143: 13,2500 01110 ALT
052668,000144: 13,2501 02152 ALPHAV
052669,000145: 13,2502 77772 VSL1 # R METERS B-29
052670,000146: 13,2503 36152 STCALL ALPHAV # EXIT WITH R IN METERS B-29
052671,000147: 13,2504 02242 INCORPEX
052672,000148:
052673,000149: # SUBROUTINE TO COMPUTE EARTH RADIUS
052674,000150:
052675,000151: # INPUT
052676,000152: # 1/2 SIN LAT IN ALPHAV +4
052677,000153:
052678,000154: # OUTPUT
052679,000155: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
052680,000156:
052681,000157: 13,2505 63545 GETERAD DLOAD DSQ
052682,000158: 13,2506 02156 ALPHAV +4 # SIN**2(L)
052683,000159: 13,2507 44352 SL1 BDSU
052684,000160: 13,2510 11561 DP1/2 # COS**2(L)
052685,000161: 13,2511 44275 DMPR BDSU
052686,000162: 13,2512 26526 EE
052687,000163: 13,2513 11561 DP1/2
052688,000164: 13,2514 75465 BDDV SQRT
052689,000165: 13,2515 26522 B2XSC
052690,000166: 13,2516 77622 SR4R
052691,000167: 13,2517 02241 STORE ERADM
052692,000168: 13,2520 77616 RVQ
052693,000169:
052694,000170: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
052695,000171: # B2XSC = B**2 SCALED B-51
052696,000172: # B2/A2 = B**2/A**2 SCALED B-1
052697,000173: # EE = (1-B**2/A**2) SCALED B-0
052698,000174:
052699,000175: 13,2521 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
052700,000176:
052701,000177: 13,2523 04,3560 DP1/2 = XUNIT
052702,000178: 13,2523 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
052703,000179:
052704,000180: 13,2525 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
052705,000181:
052706,000182: 13,2527 00302 17755 ERAD 2DEC 6373338 B-29 # PAD RADIUS
052707,000183:
Page 1240 |
052709,000185: # ARCTAN SUBROUTINE
052710,000186:
052711,000187: # CALLING SEQUENCE
052712,000188: # SIN THETA IN SINTH B-1
052713,000189: # COS THETA IN COSTH B-1
052714,000190: # CALL ARCTAN
052715,000191:
052716,000192: # OUTPUT
052717,000193: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
052718,000194:
052719,000195: 13,2531 77600 ARCTAN BOV
052720,000196: 13,2532 26533 CLROVFLW
052721,000197: 13,2533 63545 CLROVFLW DLOAD DSQ
052722,000198: 13,2534 00023 SINTH
052723,000199: 13,2535 63525 PDDL DSQ
052724,000200: 13,2536 00021 COSTH
052725,000201: 13,2537 77615 DAD
052726,000202: 13,2540 75454 BZE SQRT
052727,000203: 13,2541 26557 ARCTANXX # ATAN=0/0 SET THETA=0
052728,000204: 13,2542 40065 BDDV BOV
052729,000205: 13,2543 00023 SINTH
052730,000206: 13,2544 26564 ATAN=90
052731,000207: 13,2545 67542 SR1 ASIN
052732,000208: 13,2546 00025 STORE THETA
052733,000209: 13,2547 50125 PDDL BMN
052734,000210: 13,2550 00021 COSTH
052735,000211: 13,2551 26553 NEGCOS
052736,000212: 13,2552 43545 DLOAD RVQ
052737,000213: 13,2553 57545 NEGCOS DLOAD DCOMP
052738,000214: 13,2554 43244 BPL DAD
052739,000215: 13,2555 26561 NEGOUT
052740,000216: 13,2556 11561 DP1/2
052741,000217: 13,2557 00025 ARCTANXX STORE THETA
052742,000218: 13,2560 77616 RVQ
052743,000219:
052744,000220: 13,2561 52025 NEGOUT DSU GOTO
052745,000221: 13,2562 11561 DP1/2
052746,000222: 13,2563 26557 ARCTANXX
052747,000223: 13,2564 75345 ATAN=90 DLOAD SIGN
052748,000224: 13,2565 11607 LODP1/4
052749,000225: 13,2566 00023 SINTH
052750,000226: 13,2567 00025 STORE THETA
052751,000227: 13,2570 77616 RVQ
052752,000228:
052753,000229: 13,2571 04,3562 2DZERO = DPZERO
052754,000230:
Page 1241 |
052756,000232: # ..... SETGAMMA SUBROUTINE .....
052757,000233: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
052758,000234:
052759,000235: # GAMMA = B**2/A**2 FOR EARTH (B-1)
052760,000236: # GAMMA = 1 FOR MOON (B-1)
052761,000237:
052762,000238: # CALLING SEQUENCE
052763,000239: # L CALL
052764,000240: # L+1 SETGAMMA
052765,000241:
052766,000242: # INPUT
052767,000243: # LUNAFLAG=0 FOR EARTH, =1 FOR MOON
052768,000244:
052769,000245: # OUTPUT
052770,000246: # GAMMA IN GAMRP (B-1)
052771,000247:
052772,000248: 13,2571 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
052773,000249: 13,2572 26524 B2/A2 # EARTH GAMMA
052774,000250: 13,2573 01743 LUNAFLAG
052775,000251: 13,2574 26577 SETGMEX
052776,000252: 13,2575 77735 SLOAD
052777,000253: 13,2576 11561 1B1 # MOON GAMMA
052778,000254: 13,2577 00011 SETGMEX STORE GAMRP
052779,000255: 13,2600 77616 RVQ
052780,000256: 13,2601 GAMRP = 8D
052781,000257:
Page 1242 |
052783,000259: # ..... SETRE SUBROUTINE .....
052784,000260: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
052785,000261:
052786,000262: # RE = RM FOR MOON
052787,000263: # RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
052788,000264:
052789,000265: # CALLING SEQUENCE
052790,000266: # L CALL
052791,000267: # L+1 SETRE
052792,000268:
052793,000269: # SUBROUTINES USED
052794,000270: # GETERAD
052795,000271:
052796,000272: # INPUT
052797,000273: # ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
052798,000274: # ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
052799,000275: # LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
052800,000276:
052801,000277: # OUTPUT
052802,000278: # ERADM = 504RM FOR MOON (METERS B-29)
052803,000279: # ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
052804,000280:
052805,000281: 13,2601 71220 SETRE STQ DLOAD
052806,000282: 13,2602 00051 SETREX
052807,000283: 13,2603 26626 504RM
052808,000284: 13,2604 71214 BON DLOAD # BRANCH FOR MOON
052809,000285: 13,2605 01703 LUNAFLAG
052810,000286: 13,2606 26616 TSTRLSRM
052811,000287: 13,2607 26530 ERAD
052812,000288: 13,2610 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
052813,000289: 13,2611 00742 ERADFLAG
052814,000290: 13,2612 26614 SETRXX
052815,000291: 13,2613 26505 GETERAD
052816,000292: 13,2614 36241 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
052817,000293: 13,2615 00051 SETREX
052818,000294: 13,2616 77214 TSTRLSRM BON VLOAD # ERADFLAG=0, SET R0=RLS
052819,000295: 13,2617 00702 ERADFLAG # =1 R0=RM
052820,000296: 13,2620 26614 SETRXX
052821,000297: 13,2621 02026 RLS
052822,000298: 13,2622 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
052823,000299: 13,2623 77650 GOTO
052824,000300: 13,2624 26614 SETRXX
052825,000301: 13,2625 0000051 SETREX = S2
052826,000302: 13,2625 00065 01265 504RM 2DEC 1738090 B-29 # METERS B-29 (MOON RADIUS)
052827,000303:
052828,000304:
052829,000305:
052830,000306:
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc