Source Code

These source-code files are part of a reconstructed copy of Comanche 72, the first release of the Apollo Guidance Computer (AGC) Command Module (CM) software for Apollo 13.

They have been adapted from sources files created from a listing of Comanche 55. These source files were updated to match binary dumps of a set of Comanche 67 rope modules. They were then further modified by applying known changes between Comanche 67 and Comanche 72. A binary dump of module B2 of Comanche 72, part number 2010802-021, was also used to validate changes made to banks 05-13. 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 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.

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

End of include-file LATITUDE_LONGITUDE_SUBROUTINES.agc.  Parent file is MAIN.agc