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