Source Code

These source-code files are part of a reconstructed copy of Comanche 44, the initial release (though not the final mission release) of the Apollo 10 Command Module (CM) Apollo Guidance Computer (AGC) software. Subsequent releases were Comanche 45 and Comanche 45/2 (the flown release on Apollo 10). The reconstruction is believed to be exactly accurate, but in the absence of an actual Apollo-era listing of Comanche 44, some explanation of the reconstruction process is needed to insure confidence in that accuracy.

The starting point was the source code of Comanche 51 (separately previously reconstructed from an Apollo-era listing of Comanche 55, flown on Apollo 11). Comanche 51 source code was then modified by undoing changes known to have been made between revisions 44 and 51. The now-reconstructed Comanche 44 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 printout, although the source code would likely have different page numbers in a contemporary Comanche 44 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 51. Here's a guide to the Apollo documentation referenced in those annotations:
In most cases, only the titles (rather than the full texts) of PCRs are known. In addition to the explanatory annotations, there is also a step-by-step commentary about the reconstruction process.

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.

053027,000002:                                                                                                  ## Copyright:   Public domain.
053028,000003:                                                                                                  ## Filename:    LATITUDE_LONGITUDE_SUBROUTINES.agc
053029,000004:                                                                                                  ## Purpose:     A section of Comanche revision 044.
053030,000005:                                                                                                  ##              It is part of the reconstructed source code for the
053031,000006:                                                                                                  ##              original release of the flight software for the Command
053032,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
053033,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
053034,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
053035,000010:                                                                                                  ##              exactly match those specified for Comanche 44 in NASA drawing
053036,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
053037,000012:                                                                                                  ##              reconstruction is correct.
053038,000013:                                                                                                  ## Assembler:   yaYUL
053039,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
053040,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
053041,000016:                                                                                                  ## Mod history: 2020-12-03 MAS  Created from Comanche 51.
053042,000017: 

Page 1236

053044,000019:                                                                                                  #  SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
053045,000020: 
053046,000021:                                                                                                  #  CALLING SEQUENCE
053047,000022:                                                                                                  #        L-1     CALL
053048,000023:                                                                                                  #        L               LAT-LONG
053049,000024: 
053050,000025:                                                                                                  #  SUBROUTINES USED
053051,000026:                                                                                                  #        R-TO-RP, ARCTAN, SETGAMMA, SETRE
053052,000027: 
053053,000028:                                                                                                  #  ERASABLE INIT. REQ.
053054,000029:                                                                                                  #        AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
053055,000030:                                                                                                  #        ALPHAV = POSITION VECTOR METERS B-29
053056,000031:                                                                                                  #        MPAC -- TIME (CSECS B-28)
053057,000032:                                                                                                  #        ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
053058,000033:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
053059,000034: 
053060,000035:                                                                                                  #  OUTPUT
053061,000036:                                                                                                  #        LATITUDE IN LAT         (REVS. B-0)
053062,000037:                                                                                                  #        LONGITUDE IN LONG       (REVS. B-0)
053063,000038:                                                                                                  #        ALTITUDE IN ALT METERS  B-29
053064,000039: 
053065,000040: 30,3750                                           BANK     30                                    
053066,000041: 13,2000                                           SETLOC   LATLONG                               
053067,000042: 13,2000                                           BANK                                           
053068,000043: 
053069,000044: 13,2370                                           COUNT    13/LT-LG                              
053070,000045: 
053071,000046: 13,2370  E4,1551                                  EBANK=   ALPHAV                                
053072,000047: 13,2370           40220        LAT-LONG           STQ      SETPD                                 
053073,000048: 13,2371           02242                                    INCORPEX                              
053074,000049: 13,2372           00001                                    0D                                    
053075,000050: 13,2373           24007                           STOVL    6D                                    #  SAVE TIME IN 6-7D FOR R-TO-RP
053076,000051: 13,2374           02152                                    ALPHAV                                
053077,000052: 13,2375           51406                           PUSH     ABVAL                                 #  0-5D= R FOR R-TO-RP
053078,000053: 13,2376           16310                           STODL    ALPHAM                                #  ABS. VALUE OF R FOR ALT FORMULA BELOW
053079,000054: 13,2377           11563                                    ZEROVEC                               #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
053080,000055: 13,2400           71414                           BOFF     COS                                   #  USE COS(0) TO GET NON-ZERO IN MPAC
053081,000056: 13,2401           01743                                    LUNAFLAG                              #  0=EARTH, 1=MOON
053082,000057: 13,2402           26403                                    CALLRTRP                              
053083,000058: 13,2403           77624        CALLRTRP           CALL                                           
053084,000059: 13,2404           55371                                    R-TO-RP                               #  RP VECTOR CONVERTED FROM R B-29
053085,000060: 13,2405           77656                           UNIT                                           #  UNIT RP B-1
053086,000061: 13,2406           36152                           STCALL   ALPHAV                                #  U2= 1/2 SINL FOR SETRE SUBR BELOW
053087,000062: 13,2407           26571                                    SETGAMMA                              #        SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
053088,000063: 13,2410           77624                           CALL                                           #        SCALED B-1
053089,000064: 13,2411           26601                                    SETRE                                 #  CALC RE METERS B-29
053090,000065: 13,2412           63545                           DLOAD    DSQ                                   
053091,000066: 13,2413           02152                                    ALPHAV                                
053092,000067: 13,2414           63525                           PDDL     DSQ                                   
053093,000068: 13,2415           02154                                    ALPHAV     +2                         

Page 1237

053095,000070: 13,2416           75415                           DAD      SQRT                                  
053096,000071: 13,2417           76405                           DMP      SL1R                                  
053097,000072: 13,2420           00011                                    GAMRP                                 
053098,000073: 13,2421           14021                           STODL    COSTH                                 #  COS(LAT) B-1
053099,000074: 13,2422           02156                                    ALPHAV     +4                         
053100,000075: 13,2423           34023                           STCALL   SINTH                                 #  SIN(LAT) B-1
053101,000076: 13,2424           26531                                    ARCTAN                                
053102,000077: 13,2425           15104                           STODL    LAT                                   #  LAT B0
053103,000078: 13,2426           02152                                    ALPHAV                                
053104,000079: 13,2427           14021                           STODL    COSTH                                 #  COS(LONG) B-1
053105,000080: 13,2430           02154                                    ALPHAV     +2                         
053106,000081: 13,2431           34023                           STCALL   SINTH                                 #  SIN(LONG) B-1
053107,000082: 13,2432           26531                                    ARCTAN                                
053108,000083: 13,2433           15106                           STODL    LONG                                  #  LONG. REVS B-0 IN RANGE -1/2 TO 1/2
053109,000084: 13,2434           02310                                    ALPHAM                                
053110,000085: 13,2435           77625                           DSU                                            #  ALT= R-RE METERS B-29
053111,000086: 13,2436           02241                                    ERADM                                 
053112,000087: 13,2437           35110                           STCALL   ALT                                   #  EXIT WITH ALT METERS B-29
053113,000088: 13,2440           02242                                    INCORPEX                              

Page 1238

053115,000090:                                                                                                  #  SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
053116,000091: 
053117,000092:                                                                                                  #  CALLING SEQUENCE
053118,000093:                                                                                                  #        L-1     CALL
053119,000094:                                                                                                  #        L               LALOTORV
053120,000095: 
053121,000096:                                                                                                  #  SUBROUTINES USED
053122,000097:                                                                                                  #        SETGAMMA, SETRE, RP-TO-R
053123,000098: 
053124,000099:                                                                                                  #  ERASABLE INIT. REQ.
053125,000100:                                                                                                  #        AXO, AYO, AZO, TEPHEM SET AT LAUNCH TIME
053126,000101:                                                                                                  #        LAT -- LATITUDE         (REVS B0)
053127,000102:                                                                                                  #        LONG -- LONGITUDE       (REVS B0)
053128,000103:                                                                                                  #        ALT -- ALTITUDE         (METERS) B-29
053129,000104:                                                                                                  #        MPAC -- TIME            (CSECS B-28)
053130,000105:                                                                                                  #        ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
053131,000106:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
053132,000107: 
053133,000108:                                                                                                  #  OUTPUT
053134,000109:                                                                                                  #        R-VECTOR IN ALPHAV      (METERS B-29)
053135,000110: 
053136,000111: 13,2441           40220        LALOTORV           STQ      SETPD                                 #  LAT,LONG,ALT TO R VECTOR
053137,000112: 13,2442           02242                                    INCORPEX                              
053138,000113: 13,2443           00001                                    0D                                    
053139,000114: 13,2444           34007                           STCALL   6D                                    #      6-7D = TIME FOR RP-TO-R
053140,000115: 13,2445           26571                                    SETGAMMA                              #     GAMMA = B2/A2 FOR EARTH, 1 FOR MOON B-1
053141,000116: 13,2446           73545                           DLOAD    SIN                                   #            COS(LONG)COS(LAT) IN MPAC
053142,000117: 13,2447           01104                                    LAT                                   #  UNIT  RP = SIN(LONG)COS(LAT)    2-3D
053143,000118: 13,2450           65275                           DMPR     PDDL                                  #  PD 2      GAMMA*SIN(LAT)       0-1D
053144,000119: 13,2451           00011                                    GAMRP                                 
053145,000120: 13,2452           01104                                    LAT                                   #      0-1D = GAMMA*SIN(LAT) B-2
053146,000121: 13,2453           65346                           COS      PDDL                                  #  PD4 2-3D= COS(LAT) B-1 TEMPORARILY
053147,000122: 13,2454           01106                                    LONG                                  
053148,000123: 13,2455           57356                           SIN      DMPR                                  #  PD 2
053149,000124: 13,2456           71525                           PDDL     COS                                   #  PD 4 2-3D= SIN(LONG)COS(LAT) B-2
053150,000125: 13,2457           01104                                    LAT                                   
053151,000126: 13,2460           71525                           PDDL     COS                                   #  PD 6 4-5D= COS(LAT) B-1 TEMPORARILY
053152,000127: 13,2461           01106                                    LONG                                  
053153,000128: 13,2462           55475                           DMPR     VDEF                                  #  PD4 MPAC = COS(LONG)COS(LAT) B-2
053154,000129: 13,2463           41456                           UNIT     PUSH                                  #      0-5D = UNIT RP FOR RP-TO-R SUBR.
053155,000130: 13,2464           36152                           STCALL   ALPHAV                                #  ALPHAV +4= SINL FOR SETRE SUBR.
053156,000131: 13,2465           26601                                    SETRE                                 #  RE METERS B-29
053157,000132: 13,2466           43145                           DLOAD    BOFF                                  #  SET MPAC = 0 FOR EARTH, NON-ZERO FOR MOON
053158,000133: 13,2467           11563                                    ZEROVEC                               
053159,000134: 13,2470           01743                                    LUNAFLAG                              
053160,000135: 13,2471           26473                                    CALLRPRT                              
053161,000136: 13,2472           77746                           COS                                            #  USE COS(0) TO GET NON-ZERO IN MPAC
053162,000137: 13,2473           77624        CALLRPRT           CALL                                           
053163,000138: 13,2474           55344                                    RP-TO-R                               #  EXIT WITH UNIT R VECTOR IN MPAC
053164,000139: 13,2475           16152                           STODL    ALPHAV                                
053165,000140: 13,2476           02241                                    ERADM                                 

Page 1239

053167,000142: 13,2477           74215                           DAD      VXSC                                  #  (RE + ALT)(UNIT R) METERS B-30
053168,000143: 13,2500           01110                                    ALT                                   
053169,000144: 13,2501           02152                                    ALPHAV                                
053170,000145: 13,2502           77772                           VSL1                                           #  R METERS B-29
053171,000146: 13,2503           36152                           STCALL   ALPHAV                                #  EXIT WITH R IN METERS B-29
053172,000147: 13,2504           02242                                    INCORPEX                              
053173,000148: 
053174,000149:                                                                                                  #  SUBROUTINE TO COMPUTE EARTH RADIUS
053175,000150: 
053176,000151:                                                                                                  #  INPUT
053177,000152:                                                                                                  #        1/2 SIN LAT IN ALPHAV +4
053178,000153: 
053179,000154:                                                                                                  #  OUTPUT
053180,000155:                                                                                                  #        EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
053181,000156: 
053182,000157: 13,2505           63545        GETERAD            DLOAD    DSQ                                   
053183,000158: 13,2506           02156                                    ALPHAV     +4                         #  SIN**2(L)
053184,000159: 13,2507           44352                           SL1      BDSU                                  
053185,000160: 13,2510           11561                                    DP1/2                                 #  COS**2(L)
053186,000161: 13,2511           44275                           DMPR     BDSU                                  
053187,000162: 13,2512           26526                                    EE                                    
053188,000163: 13,2513           11561                                    DP1/2                                 
053189,000164: 13,2514           75465                           BDDV     SQRT                                  
053190,000165: 13,2515           26522                                    B2XSC                                 
053191,000166: 13,2516           77622                           SR4R                                           
053192,000167: 13,2517           02241                           STORE    ERADM                                 
053193,000168: 13,2520           77616                           RVQ                                            
053194,000169: 
053195,000170:                                                                                                  #  THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
053196,000171:                                                                                                  #  B2XSC = B**2 SCALED B-51
053197,000172:                                                                                                  #  B2/A2 = B**2/A**2 SCALED B-1
053198,000173:                                                                                                  #  EE = (1-B**2/A**2) SCALED B-0
053199,000174: 
053200,000175: 13,2521           00446 00305  B2XSC              2DEC     .0179450689                            #  B**2 SCALED B-51
053201,000176: 
053202,000177: 13,2523  04,3560               DP1/2              =        XUNIT                                 
053203,000178: 13,2523           17711 05254  B2/A2              2DEC     .9933064884 B-1                        #  GAMMA= B**2/A**2 B-1
053204,000179: 
053205,000180: 13,2525           00155 25250  EE                 2DEC     6.6935116  E-3                        #  (1-B**2/A**2) B-0
053206,000181: 
053207,000182: 13,2527           00302 17755  ERAD               2DEC     6373338    B-29                       #  PAD RADIUS
053208,000183: 

Page 1240

053210,000185:                                                                                                  #  ARCTAN SUBROUTINE
053211,000186: 
053212,000187:                                                                                                  #  CALLING SEQUENCE
053213,000188:                                                                                                  #        SIN THETA IN SINTH B-1
053214,000189:                                                                                                  #        COS THETA IN COSTH B-1
053215,000190:                                                                                                  #        CALL ARCTAN
053216,000191: 
053217,000192:                                                                                                  #  OUTPUT
053218,000193:                                                                                                  #        ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
053219,000194: 
053220,000195: 13,2531           77600        ARCTAN             BOV                                            
053221,000196: 13,2532           26533                                    CLROVFLW                              
053222,000197: 13,2533           63545        CLROVFLW           DLOAD    DSQ                                   
053223,000198: 13,2534           00023                                    SINTH                                 
053224,000199: 13,2535           63525                           PDDL     DSQ                                   
053225,000200: 13,2536           00021                                    COSTH                                 
053226,000201: 13,2537           77615                           DAD                                            
053227,000202: 13,2540           75454                           BZE      SQRT                                  
053228,000203: 13,2541           26557                                    ARCTANXX                              #  ATAN=0/0  SET THETA=0
053229,000204: 13,2542           40065                           BDDV     BOV                                   
053230,000205: 13,2543           00023                                    SINTH                                 
053231,000206: 13,2544           26564                                    ATAN=90                               
053232,000207: 13,2545           67542                           SR1      ASIN                                  
053233,000208: 13,2546           00025                           STORE    THETA                                 
053234,000209: 13,2547           50125                           PDDL     BMN                                   
053235,000210: 13,2550           00021                                    COSTH                                 
053236,000211: 13,2551           26553                                    NEGCOS                                
053237,000212: 13,2552           43545                           DLOAD    RVQ                                   
053238,000213: 13,2553           57545        NEGCOS             DLOAD    DCOMP                                 
053239,000214: 13,2554           43244                           BPL      DAD                                   
053240,000215: 13,2555           26561                                    NEGOUT                                
053241,000216: 13,2556           11561                                    DP1/2                                 
053242,000217: 13,2557           00025        ARCTANXX           STORE    THETA                                 
053243,000218: 13,2560           77616                           RVQ                                            
053244,000219: 
053245,000220: 13,2561           52025        NEGOUT             DSU      GOTO                                  
053246,000221: 13,2562           11561                                    DP1/2                                 
053247,000222: 13,2563           26557                                    ARCTANXX                              
053248,000223: 13,2564           75345        ATAN=90            DLOAD    SIGN                                  
053249,000224: 13,2565           11607                                    LODP1/4                               
053250,000225: 13,2566           00023                                    SINTH                                 
053251,000226: 13,2567           00025                           STORE    THETA                                 
053252,000227: 13,2570           77616                           RVQ                                            
053253,000228: 
053254,000229: 13,2571  04,3562               2DZERO             =        DPZERO                                
053255,000230: 

Page 1241

053257,000232:                                                                                                  #  ..... SETGAMMA SUBROUTINE .....
053258,000233:                                                                                                  #  SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
053259,000234: 
053260,000235:                                                                                                  #  GAMMA = B**2/A**2 FOR EARTH (B-1)
053261,000236:                                                                                                  #  GAMMA = 1 FOR MOON (B-1)
053262,000237: 
053263,000238:                                                                                                  #  CALLING SEQUENCE
053264,000239:                                                                                                  #        L       CALL
053265,000240:                                                                                                  #        L+1             SETGAMMA
053266,000241: 
053267,000242:                                                                                                  #  INPUT
053268,000243:                                                                                                  #        LUNAFLAG=0 FOR EARTH, =1 FOR MOON
053269,000244: 
053270,000245:                                                                                                  #  OUTPUT
053271,000246:                                                                                                  #        GAMMA IN GAMRP (B-1)
053272,000247: 
053273,000248: 13,2571           43145        SETGAMMA           DLOAD    BOFF                                  #  BRANCH FOR EARTH
053274,000249: 13,2572           26524                                    B2/A2                                 #  EARTH GAMMA
053275,000250: 13,2573           01743                                    LUNAFLAG                              
053276,000251: 13,2574           26577                                    SETGMEX                               
053277,000252: 13,2575           77735                           SLOAD                                          
053278,000253: 13,2576           11561                                    1B1                                   #  MOON GAMMA
053279,000254: 13,2577           00011        SETGMEX            STORE    GAMRP                                 
053280,000255: 13,2600           77616                           RVQ                                            
053281,000256: 13,2601                        GAMRP              =        8D                                    
053282,000257: 

Page 1242

053284,000259:                                                                                                  #  ..... SETRE SUBROUTINE .....
053285,000260:                                                                                                  #  SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
053286,000261: 
053287,000262:                                                                                                  #        RE = RM FOR MOON
053288,000263:                                                                                                  #        RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
053289,000264: 
053290,000265:                                                                                                  #  CALLING SEQUENCE
053291,000266:                                                                                                  #        L       CALL
053292,000267:                                                                                                  #        L+1             SETRE
053293,000268: 
053294,000269:                                                                                                  #  SUBROUTINES USED
053295,000270:                                                                                                  #        GETERAD
053296,000271: 
053297,000272:                                                                                                  #  INPUT
053298,000273:                                                                                                  #        ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
053299,000274:                                                                                                  #        ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
053300,000275:                                                                                                  #        LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
053301,000276: 
053302,000277:                                                                                                  #  OUTPUT
053303,000278:                                                                                                  #        ERADM = 504RM FOR MOON (METERS B-29)
053304,000279:                                                                                                  #        ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
053305,000280: 
053306,000281: 13,2601           71220        SETRE              STQ      DLOAD                                 
053307,000282: 13,2602           00051                                    SETREX                                
053308,000283: 13,2603           26626                                    504RM                                 
053309,000284: 13,2604           71214                           BON      DLOAD                                 #  BRANCH FOR MOON
053310,000285: 13,2605           01703                                    LUNAFLAG                              
053311,000286: 13,2606           26616                                    TSTRLSRM                              
053312,000287: 13,2607           26530                                    ERAD                                  
053313,000288: 13,2610           45014                           BOFF     CALL                                  #  ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
053314,000289: 13,2611           00742                                    ERADFLAG                              
053315,000290: 13,2612           26614                                    SETRXX                                
053316,000291: 13,2613           26505                                    GETERAD                               
053317,000292: 13,2614           36241        SETRXX             STCALL   ERADM                                 #  EXIT WITH RE OR RM METERS B-29
053318,000293: 13,2615           00051                                    SETREX                                
053319,000294: 13,2616           77214        TSTRLSRM           BON      VLOAD                                 #  ERADFLAG=0, SET R0=RLS
053320,000295: 13,2617           00702                                    ERADFLAG                              #          =1      R0=RM
053321,000296: 13,2620           26614                                    SETRXX                                
053322,000297: 13,2621           02026                                    RLS                                   
053323,000298: 13,2622           64446                           ABVAL    SR2R                                  #  SCALE FROM B-27 TO B-29
053324,000299: 13,2623           77650                           GOTO                                           
053325,000300: 13,2624           26614                                    SETRXX                                
053326,000301: 13,2625  0000051               SETREX             =        S2                                    
053327,000302: 13,2625           00065 01265  504RM              2DEC     1738090    B-29                       #  METERS B-29 (MOON RADIUS)
053328,000303: 
053329,000304: 
053330,000305: 
053331,000306: 

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