Source Code
This is the source-code for the Apollo 9 Command Module's Guidance Computer.
These files were derived originally from the scan from MIT's Dibner Institute's
now-discontinued website titled "History of Recent Science and Technology", which
in turn was originally created by Gary Neff, though his high-quality scans were
unfortunately reduced in legibility when presented online.
The markings on the front of the
printout imply that it was the original AGC developer Norm Brodeur's copy.
A scan by Ron Burkey has superceded it, made from a more-legible copy from the collection of original
AGC developer Fred Martin. The source code was transcribed from
those images by Ron Burkey. Note that the page images
presented online are of reduced quality, and that higher-quality images
are available. Report any conversion errors or legibility
problems in page images to info@sandroid.org.
Notations on the program listing read, in part:ASSEMBLE REVISION 249 OF AGC PROGRAM COLOSSUS BY NASA 2021111-041 20'35 OCT. 28,1968Note that the date is the date of the printout, not the date of the program revision. |
052677,000002: ## Copyright: Public domain.
052678,000003: ## Filename: LATITUDE_LONGITUDE_SUBROUTINES.agc
052679,000004: ## Purpose: Part of the source code for Colossus, build 249.
052680,000005: ## It is part of the source code for the Command Module's (CM)
052681,000006: ## Apollo Guidance Computer (AGC), for Apollo 9.
052682,000007: ## Assembler: yaYUL
052683,000008: ## Reference: Begins on p. 1206
052684,000009: ## Contact: Ron Burkey <info@sandroid.org>.
052685,000010: ## Website: www.ibiblio.org/apollo.
052686,000011: ## Mod history: 08/28/04 RSB. Adapted from corresponding Luminary131 file.
052687,000012: ## 2010-10-25 JL Indentation fix.
052688,000013: ## 2017-01-06 RSB Page numbers now agree with those on the
052689,000014: ## original harcopy, as opposed to the PDF page
052690,000015: ## numbers in 1701.pdf.
052691,000016: ## 2017-01-15 RSB Cross-diff'd comment text (not whitespace)
052692,000017: ## vs the already-proofed corresponding Colossus
052693,000018: ## 237 and Comanche 55 source-code files
052694,000019: ## and corrected errors found. There were no
052695,000020: ## differences between the comment text in the
052696,000021: ## different versions after these corrections.
052697,000022: ## 2017-02-05 RSB Back-ported comment corrections
052698,000023: ## identified while proofing Artemis 072.
052699,000024: ## 2017-03-15 RSB Comment-text fixes identified in 5-way
052700,000025: ## side-by-side diff of Luminary 69/99/116/131/210.
052701,000026:
052702,000027: ## The contents of the "Colossus249" files, in general, are transcribed
052703,000028: ## from a scanned copy of the program listing. Notations on this
052704,000029: ## document read, in part:
052705,000030: ##
052706,000031: ## Assemble revision 249 of AGC program Colossus by NASA
052707,000032: ## 2021111-041. October 28, 1968.
052708,000033: ##
052709,000034: ## This AGC program shall also be referred to as
052710,000035: ## Colossus 1A
052711,000036: ##
052712,000037: ## Prepared by
052713,000038: ## Massachusetts Institute of Technology
052714,000039: ## 75 Cambridge Parkway
052715,000040: ## Cambridge, Massachusetts
052716,000041: ## under NASA contract NAS 9-4065.
052717,000042: ##
052718,000043: ## Refer directly to the online document mentioned above for further information.
052719,000044: ## Please report any errors (relative to the scanned pages) to info@sandroid.org.
052720,000045: ##
052721,000046: ## In some cases, where the source code for Luminary 131 overlaps that of
052722,000047: ## Colossus 249, this code is instead copied from the corresponding Luminary 131
052723,000048: ## source file, and then is proofed to incorporate any changes.
052724,000049:
Page 1206 |
052726,000051: # SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
052727,000052:
052728,000053: # CALLING SEQUENCE
052729,000054: # L-1 CALL
052730,000055: # L LAT-LONG
052731,000056:
052732,000057: # SUBROUTINES USED
052733,000058: # R-TO-RP, ARCTAN, SETGAMMA, SETRE
052734,000059:
052735,000060: # ERASABLE INIT. REQ.
052736,000061: # AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
052737,000062: # ALPHAV = POSITION VECTOR METERS B-29
052738,000063: # MPAC -- TIME (CSECS B-28)
052739,000064: # ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
052740,000065: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
052741,000066:
052742,000067: # OUTPUT
052743,000068: # LATITUDE IN LAT (REVS. B-0)
052744,000069: # LONGITUDE IN LONG (REVS. B-0)
052745,000070: # ALTITUDE IN ALT METERS B-29
052746,000071:
052747,000072: 30,3776 BANK 30
052748,000073: 13,2000 SETLOC LATLONG
052749,000074: 13,2000 BANK
052750,000075:
052751,000076: 13,2322 COUNT 13/LT-LG
052752,000077:
052753,000078: 13,2322 E4,1551 EBANK= ALPHAV
052754,000079: 13,2322 40220 LAT-LONG STQ SETPD
052755,000080: 13,2323 02242 INCORPEX
052756,000081: 13,2324 00001 0D
052757,000082: 13,2325 24007 STOVL 6D # SAVE TIME IN 6-7D FOR R-TO-RP
052758,000083: 13,2326 02152 ALPHAV
052759,000084: 13,2327 51406 PUSH ABVAL # 0-5D= R FOR R-TO-RP
052760,000085: 13,2330 16310 STODL ALPHAM # ABS. VALUE OF R FOR ALT FORMULA BELOW
052761,000086: 13,2331 11456 ZEROVEC # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
052762,000087: 13,2332 71414 BOFF COS # USE COS(0) TO GET NON-ZERO IN MPAC
052763,000088: 13,2333 01743 LUNAFLAG # 0=EARTH, 1=MOON
052764,000089: 13,2334 26335 CALLRTRP
052765,000090: 13,2335 77624 CALLRTRP CALL
052766,000091: 13,2336 55366 R-TO-RP # RP VECTOR CONVERTED FROM R B-29
052767,000092: 13,2337 77656 UNIT # UNIT RP B-1
052768,000093: 13,2340 36152 STCALL ALPHAV # U2= 1/2 SINL FOR SETRE SUBR BELOW
052769,000094: 13,2341 26523 SETGAMMA # SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
052770,000095: 13,2342 77624 CALL # SCALED B-1
052771,000096: 13,2343 26533 SETRE # CALC RE METERS B-29
052772,000097: 13,2344 63545 DLOAD DSQ
052773,000098: 13,2345 02152 ALPHAV
052774,000099: 13,2346 63525 PDDL DSQ
052775,000100: 13,2347 02154 ALPHAV +2
Page 1207 |
052777,000102: 13,2350 75415 DAD SQRT
052778,000103: 13,2351 76405 DMP SL1R
052779,000104: 13,2352 00011 GAMRP
052780,000105: 13,2353 14021 STODL COSTH # COS(LAT) B-1
052781,000106: 13,2354 02156 ALPHAV +4
052782,000107: 13,2355 34023 STCALL SINTH # SIN(LAT) B-1
052783,000108: 13,2356 26463 ARCTAN
052784,000109: 13,2357 15104 STODL LAT # LAT B0
052785,000110: 13,2360 02152 ALPHAV
052786,000111: 13,2361 14021 STODL COSTH # COS(LONG) B-1
052787,000112: 13,2362 02154 ALPHAV +2
052788,000113: 13,2363 34023 STCALL SINTH # SIN(LONG) B-1
052789,000114: 13,2364 26463 ARCTAN
052790,000115: 13,2365 15106 STODL LONG # LONG. REVS B-0 IN RANGE -1/2 TO 1/2
052791,000116: 13,2366 02310 ALPHAM
052792,000117: 13,2367 77625 DSU # ALT= R-RE METERS B-29
052793,000118: 13,2370 02241 ERADM
052794,000119: 13,2371 35110 STCALL ALT # EXIT WITH ALT METERS B-29
052795,000120: 13,2372 02242 INCORPEX
Page 1208 |
052797,000122: # SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
052798,000123:
052799,000124: # CALLING SEQUENCE
052800,000125: # L-1 CALL
052801,000126: # L LALOTORV
052802,000127:
052803,000128: # SUBROUTINES USED
052804,000129: # SETGAMMA, SETRE, RP-TO-R
052805,000130:
052806,000131: # ERASABLE INIT. REQ.
052807,000132: # AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
052808,000133: # LAT -- LATITUDE (REVS B0)
052809,000134: # LONG -- LONGITUDE (REVS B0)
052810,000135: # ALT -- ALTITUDE (METERS) B-29
052811,000136: # MPAC -- TIME (CSECS B-28)
052812,000137: # ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
052813,000138: # LUNAFLAG=0 FOR EARTH, 1 FOR MOON
052814,000139:
052815,000140: # OUTPUT
052816,000141: # R-VECTOR IN ALPHAV (METERS B-29)
052817,000142:
052818,000143: 13,2373 40220 LALOTORV STQ SETPD # LAT,LONG,ALT TO R VECTOR
052819,000144: 13,2374 02242 INCORPEX
052820,000145: 13,2375 00001 0D
052821,000146: 13,2376 34007 STCALL 6D # 6-7D= TIME FOR RP-TO-R
052822,000147: 13,2377 26523 SETGAMMA # GAMMA=B2/A2 FOR EARTH, 1 FOR MOON B-1
052823,000148: 13,2400 73545 DLOAD SIN # COS(LONG)COS(LAT) IN MPAC
052824,000149: 13,2401 01104 LAT # UNIT RP = SIN(LONG)COS(LAT) 2-3D
052825,000150: 13,2402 65275 DMPR PDDL # PD 2 GAMMA*SIN(LAT) 0-1D
052826,000151: 13,2403 00011 GAMRP
052827,000152: 13,2404 01104 LAT # 0-1D= GAMMA*SIN(LAT) B-2
052828,000153: 13,2405 65346 COS PDDL # PD4 2-3D= COS(LAT) B-1 TEMPORARILY
052829,000154: 13,2406 01106 LONG
052830,000155: 13,2407 57356 SIN DMPR # PD 2
052831,000156: 13,2410 71525 PDDL COS # PD 4 2-3D = SIN(LONG)COS(LAT) B-2
052832,000157: 13,2411 01104 LAT
052833,000158: 13,2412 71525 PDDL COS # PD 6 4-5D = COS(LAT) B-1 TEMPORARILY
052834,000159: 13,2413 01106 LONG
052835,000160: 13,2414 55475 DMPR VDEF # PD4 MPAC= COS(LONG)COS(LAT) B-2
052836,000161: 13,2415 41456 UNIT PUSH # 0-5D= UNIT RP FOR RP-TO-R SUBR.
052837,000162: 13,2416 36152 STCALL ALPHAV # ALPHAV +4= SINL FOR SETRE SUBR.
052838,000163: 13,2417 26533 SETRE # RE METERS B-29
052839,000164: 13,2420 43145 DLOAD BOFF # SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
052840,000165: 13,2421 11456 ZEROVEC
052841,000166: 13,2422 01743 LUNAFLAG
052842,000167: 13,2423 26425 CALLRPRT
052843,000168: 13,2424 77746 COS # USE COS(0) TO GET NON-ZERO IN MPAC
052844,000169: 13,2425 77624 CALLRPRT CALL
052845,000170: 13,2426 55341 RP-TO-R # EXIT WITH UNIT R VECTOR IN MPAC
052846,000171: 13,2427 16152 STODL ALPHAV
052847,000172: 13,2430 02241 ERADM
Page 1209 |
052849,000174: 13,2431 74215 DAD VXSC # (RE + ALT)(UNIT R) METERS B-30
052850,000175: 13,2432 01110 ALT
052851,000176: 13,2433 02152 ALPHAV
052852,000177: 13,2434 77772 VSL1 # R METERS B-29
052853,000178: 13,2435 36152 STCALL ALPHAV # EXIT WITH R IN METERS B-29
052854,000179: 13,2436 02242 INCORPEX
052855,000180:
052856,000181: # SUBROUTINE TO COMPUTE EARTH RADIUS
052857,000182:
052858,000183: # INPUT
052859,000184: # 1/2 SIN LAT IN ALPHAV +4
052860,000185:
052861,000186: # OUTPUT
052862,000187: # EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
052863,000188:
052864,000189: 13,2437 63545 GETERAD DLOAD DSQ
052865,000190: 13,2440 02156 ALPHAV +4 # SIN**2(L)
052866,000191: 13,2441 44352 SL1 BDSU
052867,000192: 13,2442 11454 DP1/2 # COS**2(L)
052868,000193: 13,2443 44275 DMPR BDSU
052869,000194: 13,2444 26460 EE
052870,000195: 13,2445 11454 DP1/2
052871,000196: 13,2446 75465 BDDV SQRT
052872,000197: 13,2447 26454 B2XSC
052873,000198: 13,2450 77622 SR4R
052874,000199: 13,2451 02241 STORE ERADM
052875,000200: 13,2452 77616 RVQ
052876,000201:
052877,000202: # THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
052878,000203: # B2XSC = B**2 SCALED B-51
052879,000204: # B2/A2 = B**2/A**2 SCALED B-1
052880,000205: # EE = (1-B**2/A**2) SCALED B-0
052881,000206:
052882,000207: 13,2453 00446 00305 B2XSC 2DEC .0179450689 # B**2 SCALED B-51
052883,000208: 13,2455 04,3453 DP1/2 = XUNIT
052884,000209: 13,2455 17711 05254 B2/A2 2DEC .9933064884 B-1 # GAMMA= B**2/A**2 B-1
052885,000210: 13,2457 00155 25250 EE 2DEC 6.6935116 E-3 # (1-B**2/A**2) B-0
052886,000211: 13,2461 00302 17755 ERAD 2DEC 6373338 B-29 # PAD RADIUS
052887,000212:
Page 1210 |
052889,000214: # ARCTAN SUBROUTINE
052890,000215:
052891,000216: # CALLING SEQUENCE
052892,000217: # SIN THETA IN SINTH B-1
052893,000218: # COS THETA IN COSTH B-1
052894,000219: # CALL ARCTAN
052895,000220:
052896,000221: # OUTPUT
052897,000222: # ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
052898,000223:
052899,000224: 13,2463 77600 ARCTAN BOV
052900,000225: 13,2464 26465 CLROVFLW
052901,000226: 13,2465 63545 CLROVFLW DLOAD DSQ
052902,000227: 13,2466 00023 SINTH
052903,000228: 13,2467 63525 PDDL DSQ
052904,000229: 13,2470 00021 COSTH
052905,000230: 13,2471 77615 DAD
052906,000231: 13,2472 75454 BZE SQRT
052907,000232: 13,2473 26511 ARCTANXX # ATAN=0/0 SET THETA=0
052908,000233: 13,2474 40065 BDDV BOV
052909,000234: 13,2475 00023 SINTH
052910,000235: 13,2476 26516 ATAN=90
052911,000236: 13,2477 67542 SR1 ASIN
052912,000237: 13,2500 00025 STORE THETA
052913,000238: 13,2501 50125 PDDL BMN
052914,000239: 13,2502 00021 COSTH
052915,000240: 13,2503 26505 NEGCOS
052916,000241: 13,2504 43545 DLOAD RVQ
052917,000242: 13,2505 57545 NEGCOS DLOAD DCOMP
052918,000243: 13,2506 43244 BPL DAD
052919,000244: 13,2507 26513 NEGOUT
052920,000245: 13,2510 11454 DP1/2
052921,000246: 13,2511 00025 ARCTANXX STORE THETA
052922,000247: 13,2512 77616 RVQ
052923,000248:
052924,000249: 13,2513 52025 NEGOUT DSU GOTO
052925,000250: 13,2514 11454 DP1/2
052926,000251: 13,2515 26511 ARCTANXX
052927,000252: 13,2516 75345 ATAN=90 DLOAD SIGN
052928,000253: 13,2517 11502 LODP1/4
052929,000254: 13,2520 00023 SINTH
052930,000255: 13,2521 00025 STORE THETA
052931,000256: 13,2522 77616 RVQ
052932,000257:
052933,000258: 13,2523 04,3455 2DZERO = DPZERO
052934,000259:
Page 1211 |
052936,000261: # ..... SETGAMMA SUBROUTINE .....
052937,000262: # SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
052938,000263:
052939,000264: # GAMMA = B**2/A**2 FOR EARTH (B-1)
052940,000265: # GAMMA = 1 FOR MOON (B-1)
052941,000266:
052942,000267: # CALLING SEQUENCE
052943,000268: # L CALL
052944,000269: # L+1 SETGAMMA
052945,000270:
052946,000271: # INPUT
052947,000272: # LUNAFLAG=0 FOR EARTH, =1 FOR MOON
052948,000273:
052949,000274: # OUTPUT
052950,000275: # GAMMA IN GAMRP (B-1)
052951,000276:
052952,000277: 13,2523 43145 SETGAMMA DLOAD BOFF # BRANCH FOR EARTH
052953,000278: 13,2524 26456 B2/A2 # EARTH GAMMA
052954,000279: 13,2525 01743 LUNAFLAG
052955,000280: 13,2526 26531 SETGMEX
052956,000281: 13,2527 77735 SLOAD
052957,000282: 13,2530 11454 1B1 # MOON GAMMA
052958,000283: 13,2531 00011 SETGMEX STORE GAMRP
052959,000284: 13,2532 77616 RVQ
052960,000285: 13,2533 GAMRP = 8D
052961,000286:
Page 1212 |
052963,000288: # ..... SETRE SUBROUTINE .....
052964,000289: # SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
052965,000290:
052966,000291: # RE = RM FOR MOON
052967,000292: # RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
052968,000293:
052969,000294: # CALLING SEQUENCE
052970,000295: # L CALL
052971,000296: # L+1 SETRE
052972,000297:
052973,000298: # SUBROUTINES USED
052974,000299: # GETERAD
052975,000300:
052976,000301: # INPUT
052977,000302: # ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
052978,000303: # ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
052979,000304: # LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
052980,000305:
052981,000306: # OUTPUT
052982,000307: # ERADM = 504RM FOR MOON (METERS B-29)
052983,000308: # ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
052984,000309:
052985,000310: 13,2533 71220 SETRE STQ DLOAD
052986,000311: 13,2534 00051 SETREX
052987,000312: 13,2535 26560 504RM
052988,000313: 13,2536 71214 BON DLOAD # BRANCH FOR MOON
052989,000314: 13,2537 01703 LUNAFLAG
052990,000315: 13,2540 26550 TSTRLSRM
052991,000316: 13,2541 26462 ERAD
052992,000317: 13,2542 45014 BOFF CALL # ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
052993,000318: 13,2543 00742 ERADFLAG
052994,000319: 13,2544 26546 SETRXX
052995,000320: 13,2545 26437 GETERAD
052996,000321: 13,2546 36241 SETRXX STCALL ERADM # EXIT WITH RE OR RM METERS B-29
052997,000322: 13,2547 00051 SETREX
052998,000323: 13,2550 77214 TSTRLSRM BON VLOAD # ERADFLAG=0, SET R0=RLS
052999,000324: 13,2551 00702 ERADFLAG # =1 R0=RM
053000,000325: 13,2552 26546 SETRXX
053001,000326: 13,2553 02026 RLS
053002,000327: 13,2554 64446 ABVAL SR2R # SCALE FROM B-27 TO B-29
053003,000328: 13,2555 77650 GOTO
053004,000329: 13,2556 26546 SETRXX
053005,000330: 13,2557 0000051 SETREX = S2
053006,000331: 13,2557 00065 01265 504RM 2DEC 1738090 B-29 # METERS B-29 (MOON RADIUS)
053007,000332:
053008,000333:
053009,000334:
053010,000335:
End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc. Parent file is MAIN.agc