Source Code

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

They have been adapted from sources files for Comanche 55, and updated via disassembly of binary dumps of original core rope memory modules, part numbers 2003972-1081, 2003972-1091, 2003972-1111, 2003972-1121, 2003972-1131, and 2003972-1141.

Since only binary dumps (rather than listings) of Comanche 67 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.

051207,000002:                                                                                                  ## Copyright:   Public domain.
051208,000003:                                                                                                  ## Filename:    LATITUDE_LONGITUDE_SUBROUTINES.agc
051209,000004:                                                                                                  ## Purpose:     A section of Comanche revision 067.
051210,000005:                                                                                                  ##              It is part of the reconstructed source code for the flight
051211,000006:                                                                                                  ##              software for the Command Module's (CM) Apollo Guidance Computer
051212,000007:                                                                                                  ##              (AGC) for Apollo 12. No original listings of this program are
051213,000008:                                                                                                  ##              available; instead, this file was created via dissassembly of
051214,000009:                                                                                                  ##              dumps of Comanche 067 core rope modules and comparison with
051215,000010:                                                                                                  ##              other AGC programs.
051216,000011:                                                                                                  ## Assembler:   yaYUL
051217,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
051218,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
051219,000014:                                                                                                  ## Mod history: 2023-08-16 MAS  Created from Comanche 055.
051220,000015: 
051221,000016:                                                                                                  #  SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
051222,000017: 
051223,000018:                                                                                                  #  CALLING SEQUENCE
051224,000019:                                                                                                  #        L-1     CALL
051225,000020:                                                                                                  #        L               LAT-LONG
051226,000021: 
051227,000022:                                                                                                  #  SUBROUTINES USED
051228,000023:                                                                                                  #        R-TO-RP, ARCTAN, SETGAMMA, SETRE
051229,000024: 
051230,000025:                                                                                                  #  ERASABLE INIT. REQ.
051231,000026:                                                                                                  #        AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
051232,000027:                                                                                                  #        ALPHAV = POSITION VECTOR METERS B-29
051233,000028:                                                                                                  #        MPAC -- TIME (CSECS B-28)
051234,000029:                                                                                                  #        ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
051235,000030:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
051236,000031: 
051237,000032:                                                                                                  #  OUTPUT
051238,000033:                                                                                                  #        LATITUDE IN LAT         (REVS. B-0)
051239,000034:                                                                                                  #        LONGITUDE IN LONG       (REVS. B-0)
051240,000035:                                                                                                  #        ALTITUDE IN ALT METERS  B-29
051241,000036: 
051242,000037: 30,3750                                           BANK     30                                    
051243,000038: 13,2000                                           SETLOC   LATLONG                               
051244,000039: 13,2000                                           BANK                                           
051245,000040: 
051246,000041: 13,2400                                           COUNT    13/LT-LG                              
051247,000042: 
051248,000043: 13,2400  E4,1551                                  EBANK=   ALPHAV                                
051249,000044: 13,2400           40220        LAT-LONG           STQ      SETPD                                 
051250,000045: 13,2401           02242                                    INCORPEX                              
051251,000046: 13,2402           00001                                    0D                                    
051252,000047: 13,2403           24007                           STOVL    6D                                    #  SAVE TIME IN 6-7D FOR R-TO-RP
051253,000048: 13,2404           02152                                    ALPHAV                                
051254,000049: 13,2405           51406                           PUSH     ABVAL                                 #  0-5D= R FOR R-TO-RP
051255,000050: 13,2406           16310                           STODL    ALPHAM                                #  ABS. VALUE OF R FOR ALT FORMULA BELOW
051256,000051: 13,2407           11566                                    ZEROVEC                               #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
051257,000052: 13,2410           71414                           BOFF     COS                                   #  USE COS(0) TO GET NON-ZERO IN MPAC
051258,000053: 13,2411           01743                                    LUNAFLAG                              #  0=EARTH, 1=MOON
051259,000054: 13,2412           26413                                    CALLRTRP                              
051260,000055: 13,2413           77624        CALLRTRP           CALL                                           
051261,000056: 13,2414           55370                                    R-TO-RP                               #  RP VECTOR CONVERTED FROM R B-29
051262,000057: 13,2415           77656                           UNIT                                           #  UNIT RP B-1
051263,000058: 13,2416           36152                           STCALL   ALPHAV                                #  U2= 1/2 SINL FOR SETRE SUBR BELOW
051264,000059: 13,2417           26601                                    SETGAMMA                              #        SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
051265,000060: 13,2420           77624                           CALL                                           #        SCALED B-1
051266,000061: 13,2421           26611                                    SETRE                                 #  CALC RE METERS B-29
051267,000062: 13,2422           63545                           DLOAD    DSQ                                   
051268,000063: 13,2423           02152                                    ALPHAV                                
051269,000064: 13,2424           63525                           PDDL     DSQ                                   
051270,000065: 13,2425           02154                                    ALPHAV     +2                         
051271,000066: 13,2426           75415                           DAD      SQRT                                  
051272,000067: 13,2427           76405                           DMP      SL1R                                  
051273,000068: 13,2430           00011                                    GAMRP                                 
051274,000069: 13,2431           14021                           STODL    COSTH                                 #  COS(LAT) B-1
051275,000070: 13,2432           02156                                    ALPHAV     +4                         
051276,000071: 13,2433           34023                           STCALL   SINTH                                 #  SIN(LAT) B-1
051277,000072: 13,2434           26541                                    ARCTAN                                
051278,000073: 13,2435           15104                           STODL    LAT                                   #  LAT B0
051279,000074: 13,2436           02152                                    ALPHAV                                
051280,000075: 13,2437           14021                           STODL    COSTH                                 #  COS(LONG) B-1
051281,000076: 13,2440           02154                                    ALPHAV     +2                         
051282,000077: 13,2441           34023                           STCALL   SINTH                                 #  SIN(LONG) B-1
051283,000078: 13,2442           26541                                    ARCTAN                                
051284,000079: 13,2443           15106                           STODL    LONG                                  #  LONG. REVS B-0 IN RANGE -1/2 TO 1/2
051285,000080: 13,2444           02310                                    ALPHAM                                
051286,000081: 13,2445           77625                           DSU                                            #  ALT= R-RE METERS B-29
051287,000082: 13,2446           02241                                    ERADM                                 
051288,000083: 13,2447           35110                           STCALL   ALT                                   #  EXIT WITH ALT METERS B-29
051289,000084: 13,2450           02242                                    INCORPEX                              
051290,000085:                                                                                                  #  SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
051291,000086: 
051292,000087:                                                                                                  #  CALLING SEQUENCE
051293,000088:                                                                                                  #        L-1     CALL
051294,000089:                                                                                                  #        L               LALOTORV
051295,000090: 
051296,000091:                                                                                                  #  SUBROUTINES USED
051297,000092:                                                                                                  #        SETGAMMA, SETRE, RP-TO-R
051298,000093: 
051299,000094:                                                                                                  #  ERASABLE INIT. REQ.
051300,000095:                                                                                                  #        AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
051301,000096:                                                                                                  #        LAT -- LATITUDE         (REVS B0)
051302,000097:                                                                                                  #        LONG -- LONGITUDE       (REVS B0)
051303,000098:                                                                                                  #        ALT -- ALTITUDE         (METERS) B-29
051304,000099:                                                                                                  #        MPAC -- TIME            (CSECS B-28)
051305,000100:                                                                                                  #        ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
051306,000101:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
051307,000102: 
051308,000103:                                                                                                  #  OUTPUT
051309,000104:                                                                                                  #        R-VECTOR IN ALPHAV      (METERS B-29)
051310,000105: 
051311,000106: 13,2451           40220        LALOTORV           STQ      SETPD                                 #  LAT,LONG,ALT TO R VECTOR
051312,000107: 13,2452           02242                                    INCORPEX                              
051313,000108: 13,2453           00001                                    0D                                    
051314,000109: 13,2454           34007                           STCALL   6D                                    #      6-7D = TIME FOR RP-TO-R
051315,000110: 13,2455           26601                                    SETGAMMA                              #     GAMMA = B2/A2 FOR EARTH, 1 FOR MOON B-1
051316,000111: 13,2456           73545                           DLOAD    SIN                                   #            COS(LONG)COS(LAT) IN MPAC
051317,000112: 13,2457           01104                                    LAT                                   #  UNIT  RP = SIN(LONG)COS(LAT)    2-3D
051318,000113: 13,2460           65275                           DMPR     PDDL                                  #  PD 2      GAMMA*SIN(LAT)       0-1D
051319,000114: 13,2461           00011                                    GAMRP                                 
051320,000115: 13,2462           01104                                    LAT                                   #      0-1D = GAMMA*SIN(LAT) B-2
051321,000116: 13,2463           65346                           COS      PDDL                                  #  PD4 2-3D= COS(LAT) B-1 TEMPORARILY
051322,000117: 13,2464           01106                                    LONG                                  
051323,000118: 13,2465           57356                           SIN      DMPR                                  #  PD 2
051324,000119: 13,2466           71525                           PDDL     COS                                   #  PD 4 2-3D= SIN(LONG)COS(LAT) B-2
051325,000120: 13,2467           01104                                    LAT                                   
051326,000121: 13,2470           71525                           PDDL     COS                                   #  PD 6 4-5D= COS(LAT) B-1 TEMPORARILY
051327,000122: 13,2471           01106                                    LONG                                  
051328,000123: 13,2472           55475                           DMPR     VDEF                                  #  PD4 MPAC = COS(LONG)COS(LAT) B-2
051329,000124: 13,2473           41456                           UNIT     PUSH                                  #      0-5D = UNIT RP FOR RP-TO-R SUBR.
051330,000125: 13,2474           36152                           STCALL   ALPHAV                                #  ALPHAV +4= SINL FOR SETRE SUBR.
051331,000126: 13,2475           26611                                    SETRE                                 #  RE METERS B-29
051332,000127: 13,2476           43145                           DLOAD    BOFF                                  #  SET MPAC = 0 FOR EARTH, NON-ZERO FOR MOON
051333,000128: 13,2477           11566                                    ZEROVEC                               
051334,000129: 13,2500           01743                                    LUNAFLAG                              
051335,000130: 13,2501           26503                                    CALLRPRT                              
051336,000131: 13,2502           77746                           COS                                            #  USE COS(0) TO GET NON-ZERO IN MPAC
051337,000132: 13,2503           77624        CALLRPRT           CALL                                           
051338,000133: 13,2504           55343                                    RP-TO-R                               #  EXIT WITH UNIT R VECTOR IN MPAC
051339,000134: 13,2505           16152                           STODL    ALPHAV                                
051340,000135: 13,2506           02241                                    ERADM                                 
051341,000136: 13,2507           74215                           DAD      VXSC                                  #  (RE + ALT)(UNIT R) METERS B-30
051342,000137: 13,2510           01110                                    ALT                                   
051343,000138: 13,2511           02152                                    ALPHAV                                
051344,000139: 13,2512           77772                           VSL1                                           #  R METERS B-29
051345,000140: 13,2513           36152                           STCALL   ALPHAV                                #  EXIT WITH R IN METERS B-29
051346,000141: 13,2514           02242                                    INCORPEX                              
051347,000142: 
051348,000143:                                                                                                  #  SUBROUTINE TO COMPUTE EARTH RADIUS
051349,000144: 
051350,000145:                                                                                                  #  INPUT
051351,000146:                                                                                                  #        1/2 SIN LAT IN ALPHAV +4
051352,000147: 
051353,000148:                                                                                                  #  OUTPUT
051354,000149:                                                                                                  #        EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
051355,000150: 
051356,000151: 13,2515           63545        GETERAD            DLOAD    DSQ                                   
051357,000152: 13,2516           02156                                    ALPHAV     +4                         #  SIN**2(L)
051358,000153: 13,2517           44352                           SL1      BDSU                                  
051359,000154: 13,2520           11564                                    DP1/2                                 #  COS**2(L)
051360,000155: 13,2521           44275                           DMPR     BDSU                                  
051361,000156: 13,2522           26536                                    EE                                    
051362,000157: 13,2523           11564                                    DP1/2                                 
051363,000158: 13,2524           75465                           BDDV     SQRT                                  
051364,000159: 13,2525           26532                                    B2XSC                                 
051365,000160: 13,2526           77622                           SR4R                                           
051366,000161: 13,2527           02241                           STORE    ERADM                                 
051367,000162: 13,2530           77616                           RVQ                                            
051368,000163: 
051369,000164:                                                                                                  #  THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
051370,000165:                                                                                                  #  B2XSC = B**2 SCALED B-51
051371,000166:                                                                                                  #  B2/A2 = B**2/A**2 SCALED B-1
051372,000167:                                                                                                  #  EE = (1-B**2/A**2) SCALED B-0
051373,000168: 
051374,000169: 13,2531           00446 00305  B2XSC              2DEC     .0179450689                            #  B**2 SCALED B-51
051375,000170: 
051376,000171: 13,2533  04,3563               DP1/2              =        XUNIT                                 
051377,000172: 13,2533           17711 05254  B2/A2              2DEC     .9933064884 B-1                        #  GAMMA= B**2/A**2 B-1
051378,000173: 
051379,000174: 13,2535           00155 25250  EE                 2DEC     6.6935116  E-3                        #  (1-B**2/A**2) B-0
051380,000175: 
051381,000176: 13,2537           00302 17755  ERAD               2DEC     6373338    B-29                       #  PAD RADIUS
051382,000177: 
051383,000178:                                                                                                  #  ARCTAN SUBROUTINE
051384,000179: 
051385,000180:                                                                                                  #  CALLING SEQUENCE
051386,000181:                                                                                                  #        SIN THETA IN SINTH B-1
051387,000182:                                                                                                  #        COS THETA IN COSTH B-1
051388,000183:                                                                                                  #        CALL ARCTAN
051389,000184: 
051390,000185:                                                                                                  #  OUTPUT
051391,000186:                                                                                                  #        ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
051392,000187: 
051393,000188: 13,2541           77600        ARCTAN             BOV                                            
051394,000189: 13,2542           26543                                    CLROVFLW                              
051395,000190: 13,2543           63545        CLROVFLW           DLOAD    DSQ                                   
051396,000191: 13,2544           00023                                    SINTH                                 
051397,000192: 13,2545           63525                           PDDL     DSQ                                   
051398,000193: 13,2546           00021                                    COSTH                                 
051399,000194: 13,2547           77615                           DAD                                            
051400,000195: 13,2550           75454                           BZE      SQRT                                  
051401,000196: 13,2551           26567                                    ARCTANXX                              #  ATAN=0/0  SET THETA=0
051402,000197: 13,2552           40065                           BDDV     BOV                                   
051403,000198: 13,2553           00023                                    SINTH                                 
051404,000199: 13,2554           26574                                    ATAN=90                               
051405,000200: 13,2555           67542                           SR1      ASIN                                  
051406,000201: 13,2556           00025                           STORE    THETA                                 
051407,000202: 13,2557           50125                           PDDL     BMN                                   
051408,000203: 13,2560           00021                                    COSTH                                 
051409,000204: 13,2561           26563                                    NEGCOS                                
051410,000205: 13,2562           43545                           DLOAD    RVQ                                   
051411,000206: 13,2563           57545        NEGCOS             DLOAD    DCOMP                                 
051412,000207: 13,2564           43244                           BPL      DAD                                   
051413,000208: 13,2565           26571                                    NEGOUT                                
051414,000209: 13,2566           11564                                    DP1/2                                 
051415,000210: 13,2567           00025        ARCTANXX           STORE    THETA                                 
051416,000211: 13,2570           77616                           RVQ                                            
051417,000212: 
051418,000213: 13,2571           52025        NEGOUT             DSU      GOTO                                  
051419,000214: 13,2572           11564                                    DP1/2                                 
051420,000215: 13,2573           26567                                    ARCTANXX                              
051421,000216: 13,2574           75345        ATAN=90            DLOAD    SIGN                                  
051422,000217: 13,2575           11612                                    LODP1/4                               
051423,000218: 13,2576           00023                                    SINTH                                 
051424,000219: 13,2577           00025                           STORE    THETA                                 
051425,000220: 13,2600           77616                           RVQ                                            
051426,000221: 
051427,000222: 13,2601  04,3565               2DZERO             =        DPZERO                                
051428,000223: 
051429,000224:                                                                                                  #  ..... SETGAMMA SUBROUTINE .....
051430,000225:                                                                                                  #  SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
051431,000226: 
051432,000227:                                                                                                  #  GAMMA = B**2/A**2 FOR EARTH (B-1)
051433,000228:                                                                                                  #  GAMMA = 1 FOR MOON (B-1)
051434,000229: 
051435,000230:                                                                                                  #  CALLING SEQUENCE
051436,000231:                                                                                                  #        L       CALL
051437,000232:                                                                                                  #        L+1             SETGAMMA
051438,000233: 
051439,000234:                                                                                                  #  INPUT
051440,000235:                                                                                                  #        LUNAFLAG=0 FOR EARTH, =1 FOR MOON
051441,000236: 
051442,000237:                                                                                                  #  OUTPUT
051443,000238:                                                                                                  #        GAMMA IN GAMRP (B-1)
051444,000239: 
051445,000240: 13,2601           43145        SETGAMMA           DLOAD    BOFF                                  #  BRANCH FOR EARTH
051446,000241: 13,2602           26534                                    B2/A2                                 #  EARTH GAMMA
051447,000242: 13,2603           01743                                    LUNAFLAG                              
051448,000243: 13,2604           26607                                    SETGMEX                               
051449,000244: 13,2605           77735                           SLOAD                                          
051450,000245: 13,2606           11564                                    1B1                                   #  MOON GAMMA
051451,000246: 13,2607           00011        SETGMEX            STORE    GAMRP                                 
051452,000247: 13,2610           77616                           RVQ                                            
051453,000248: 13,2611                        GAMRP              =        8D                                    
051454,000249: 
051455,000250:                                                                                                  #  ..... SETRE SUBROUTINE .....
051456,000251:                                                                                                  #  SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
051457,000252: 
051458,000253:                                                                                                  #        RE = RM FOR MOON
051459,000254:                                                                                                  #        RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
051460,000255: 
051461,000256:                                                                                                  #  CALLING SEQUENCE
051462,000257:                                                                                                  #        L       CALL
051463,000258:                                                                                                  #        L+1             SETRE
051464,000259: 
051465,000260:                                                                                                  #  SUBROUTINES USED
051466,000261:                                                                                                  #        GETERAD
051467,000262: 
051468,000263:                                                                                                  #  INPUT
051469,000264:                                                                                                  #        ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
051470,000265:                                                                                                  #        ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
051471,000266:                                                                                                  #        LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
051472,000267: 
051473,000268:                                                                                                  #  OUTPUT
051474,000269:                                                                                                  #        ERADM = 504RM FOR MOON (METERS B-29)
051475,000270:                                                                                                  #        ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
051476,000271: 
051477,000272: 13,2611           71220        SETRE              STQ      DLOAD                                 
051478,000273: 13,2612           00051                                    SETREX                                
051479,000274: 13,2613           26636                                    504RM                                 
051480,000275: 13,2614           71214                           BON      DLOAD                                 #  BRANCH FOR MOON
051481,000276: 13,2615           01703                                    LUNAFLAG                              
051482,000277: 13,2616           26626                                    TSTRLSRM                              
051483,000278: 13,2617           26540                                    ERAD                                  
051484,000279: 13,2620           45014                           BOFF     CALL                                  #  ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
051485,000280: 13,2621           00742                                    ERADFLAG                              
051486,000281: 13,2622           26624                                    SETRXX                                
051487,000282: 13,2623           26515                                    GETERAD                               
051488,000283: 13,2624           36241        SETRXX             STCALL   ERADM                                 #  EXIT WITH RE OR RM METERS B-29
051489,000284: 13,2625           00051                                    SETREX                                
051490,000285: 13,2626           77214        TSTRLSRM           BON      VLOAD                                 #  ERADFLAG=0, SET R0=RLS
051491,000286: 13,2627           00702                                    ERADFLAG                              #          =1      R0=RM
051492,000287: 13,2630           26624                                    SETRXX                                
051493,000288: 13,2631           02026                                    RLS                                   
051494,000289: 13,2632           64446                           ABVAL    SR2R                                  #  SCALE FROM B-27 TO B-29
051495,000290: 13,2633           77650                           GOTO                                           
051496,000291: 13,2634           26624                                    SETRXX                                
051497,000292: 13,2635  0000051               SETREX             =        S2                                    
051498,000293: 13,2635           00065 01265  504RM              2DEC     1738090    B-29                       #  METERS B-29 (MOON RADIUS)
051499,000294: 
051500,000295: 
051501,000296: 
051502,000297: 

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