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