Source Code

These source-code files were derived from scans of the Colossus 237 (Apollo 8 Command Module) program listing from the private collection of original AGC developer Fred Martin. Scanning was by Ron Burkey. Pre-existing Colossus 249 (Apollo 9 CM) source files were used as a template, and changes between Colossus 249 and Colossus 237 were manually transcribed by a team of volunteers. Note that the page images presented online are of reduced quality, and that additional images are available. Report any conversion errors or legibility problems in page images to info@sandroid.org. Notations on the program listing read, in part:

	GAP: ASSEMBLE REVISION 237 OF AGC PROGRAM COLOSSUS 
	BY NASA 2021111-031  1:17 AUG. 24, 1968
Note that the date is the date of the printout, not the date of the program revision.

051050,000002:                                                                                                  ## Copyright:   Public domain.
051051,000003:                                                                                                  ## Filename:    LATITUDE_LONGITUDE_SUBROUTINES.agc
051052,000004:                                                                                                  ## Purpose:     Part of the source code for Colossus build 237.
051053,000005:                                                                                                  ##              This is for the Command Module's (CM) Apollo Guidance
051054,000006:                                                                                                  ##              Computer (AGC), for Apollo 8.
051055,000007:                                                                                                  ## Assembler:   yaYUL
051056,000008:                                                                                                  ## Contact:     Jim Lawton <jim DOT lawton AT gmail DOT com>
051057,000009:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
051058,000010:                                                                                                  ## Page Scans:  www.ibiblio.org/apollo/ScansForConversion/Colossus237/
051059,000011:                                                                                                  ## Mod history: 2011-04-13 JL   Adapted from corresponding Colossus 249 file.
051060,000012:                                                                                                  ##              2017-01-01 RSB  Proofed comment text using octopus/ProoferComments,
051061,000013:                                                                                                  ##                              and fixed errors found.
051062,000014:                                                                                                  ##              2017-02-05 RSB  Back-ported comment corrections 
051063,000015:                                                                                                  ##                              identified while proofing Artemis 072.
051064,000016:                                                                                                  ##              2017-03-15 RSB  Comment-text fixes identified in 5-way
051065,000017:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
051066,000018: 

Page 1203

051068,000020:                                                                                                  #  SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
051069,000021: 
051070,000022:                                                                                                  #  CALLING SEQUENCE
051071,000023: 
051072,000024:                                                                                                  #    L-1    CALL
051073,000025:                                                                                                  #    L             LAT-LONG
051074,000026:                                                                                                  #  SUBROUTINES USED
051075,000027: 
051076,000028:                                                                                                  #   R-TO-RP,ARCTAN,SETGAMMA,SETRE
051077,000029:                                                                                                  #  ERASABLE INIT. REQ.
051078,000030: 
051079,000031:                                                                                                  #    AXO,-AYO,AZO,TEPHEM (SET AT LAUNCH TIME)
051080,000032:                                                                                                  #  ALPHAV = POSITION VECTOR METERS B-29
051081,000033:                                                                                                  #    MPAC-- TIME (CSECS B-28)
051082,000034:                                                                                                  #   ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
051083,000035:                                                                                                  #   LUNAFLAG=0 FOR EARTH,1 FOR MOON
051084,000036:                                                                                                  #  OUTPUT
051085,000037: 
051086,000038:                                                                                                  #    LATITUDE IN LAT   (REVS. B-0)
051087,000039:                                                                                                  #    LONGITUDE IN LONG   (REVS. B-0)
051088,000040:                                                                                                  #  ALTITUDE IN ALT METERS B-29
051089,000041: 30,3776                                           BANK     30                                    
051090,000042: 13,2000                                           SETLOC   LATLONG                               
051091,000043: 13,2000                                           BANK                                           
051092,000044: 
051093,000045: 13,2322                                           COUNT    13/LT-LG                              
051094,000046: 
051095,000047: 13,2322  E4,1551                                  EBANK=   ALPHAV                                
051096,000048: 13,2322           40220        LAT-LONG           STQ      SETPD                                 
051097,000049: 13,2323           02242                                    INCORPEX                              
051098,000050: 13,2324           00001                                    0D                                    
051099,000051: 13,2325           24007                           STOVL    6D                                    #  SAVE TIME IN 6-7D FOR R-TO-RP
051100,000052: 13,2326           02152                                    ALPHAV                                
051101,000053: 13,2327           51406                           PUSH     ABVAL                                 #  0-5D= R FOR R-TO-RP
051102,000054: 13,2330           16310                           STODL    ALPHAM                                #  ABS. VALUE OF R FOR ALT FORMULA BELOW
051103,000055: 13,2331           11453                                    ZEROVEC                               #  SET MPAC=0 FOR EARTH,NON-ZERO FOR MOON
051104,000056: 13,2332           71414                           BOFF     COS                                   #  USE COS(0) TO GET NON-ZERO IN MPAC
051105,000057: 13,2333           01743                                    LUNAFLAG                              #  0=EARTH,1=MOON
051106,000058: 13,2334           26335                                    CALLRTRP                              
051107,000059: 13,2335           77624        CALLRTRP           CALL                                           
051108,000060: 13,2336           55366                                    R-TO-RP                               #  RP VECTOR CONVERTED FROM R B-29
051109,000061: 13,2337           77656                           UNIT                                           #  UNIT RP B-1
051110,000062: 13,2340           36152                           STCALL   ALPHAV                                #  U2= 1/2 SINL FOR SETRE SUBR BELOW
051111,000063: 13,2341           26523                                    SETGAMMA                              #   SET GAMMA=B2/A2 FOR EARTH,=1 FOR MOON
051112,000064: 13,2342           77624                           CALL                                           #   SCALED B-1
051113,000065: 13,2343           26533                                    SETRE                                 #  CALC RE METERS B-29
051114,000066: 13,2344           63545                           DLOAD    DSQ                                   
051115,000067: 13,2345           02152                                    ALPHAV                                
051116,000068: 13,2346           63525                           PDDL     DSQ                                   
051117,000069: 13,2347           02154                                    ALPHAV     +2                         

Page 1204

051119,000071: 13,2350           75415                           DAD      SQRT                                  
051120,000072: 13,2351           76405                           DMP      SL1R                                  
051121,000073: 13,2352           00011                                    GAMRP                                 
051122,000074: 13,2353           14021                           STODL    COSTH                                 #  COS(LAT) B-1
051123,000075: 13,2354           02156                                    ALPHAV     +4                         
051124,000076: 13,2355           34023                           STCALL   SINTH                                 #  SIN(LAT) B-1
051125,000077: 13,2356           26463                                    ARCTAN                                
051126,000078: 13,2357           15104                           STODL    LAT                                   #  LAT B0
051127,000079: 13,2360           02152                                    ALPHAV                                
051128,000080: 13,2361           14021                           STODL    COSTH                                 #  COS(LONG) B-1
051129,000081: 13,2362           02154                                    ALPHAV     +2                         
051130,000082: 13,2363           34023                           STCALL   SINTH                                 #  SIN(LONG) B-1
051131,000083: 13,2364           26463                                    ARCTAN                                
051132,000084: 13,2365           15106                           STODL    LONG                                  #  LONG. REVS B-0 IN RANGE -1/2 TO 1/2
051133,000085: 13,2366           02310                                    ALPHAM                                
051134,000086: 13,2367           77625                           DSU                                            #  ALT= R-RE METERS B-29
051135,000087: 13,2370           02241                                    ERADM                                 
051136,000088: 13,2371           35110                           STCALL   ALT                                   #  EXIT WITH ALT METERS B-29
051137,000089: 13,2372           02242                                    INCORPEX                              
051138,000090: 

Page 1205

051140,000092:                                                                                                  #  SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
051141,000093:                                                                                                  #  CALLING SEQUENCE
051142,000094: 
051143,000095:                                                                                                  #    L-1    CALL
051144,000096:                                                                                                  #    L             LALOTORV
051145,000097:                                                                                                  #  SUBROUTINES USED
051146,000098: 
051147,000099:                                                                                                  #   SETGAMMA,SETRE,RP-TO-R
051148,000100:                                                                                                  #  ERASABLE INIT. REQ.
051149,000101: 
051150,000102:                                                                                                  #    AXO,AYO,AZO,TEPHEM  SET AT LAUNCH TIME
051151,000103:                                                                                                  #    LAT-- LATITUDE  (REVS B0)
051152,000104:                                                                                                  #    LONG-- LONGITUDE  (REVS B0)
051153,000105:                                                                                                  #  ALT--ALTITUDE (METERS) B-29
051154,000106:                                                                                                  #    MPAC-- TIME  (CSECS B-28)
051155,000107:                                                                                                  #    ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
051156,000108:                                                                                                  #    LUNAFLAG=0 FOR EARTH,1 FOR MOON
051157,000109:                                                                                                  #  OUTPUT
051158,000110: 
051159,000111:                                                                                                  #  R-VECTOR IN ALPHAV (METERS B-29)
051160,000112: 13,2373           40220        LALOTORV           STQ      SETPD                                 #  LAT,LONG,ALT TO R VECTOR
051161,000113: 13,2374           02242                                    INCORPEX                              
051162,000114: 13,2375           00001                                    0D                                    
051163,000115: 13,2376           34007                           STCALL   6D                                    #  6-7D= TIME FOR RP-TO-R
051164,000116: 13,2377           26523                                    SETGAMMA                              #  GAMMA=B2/A2 FOR EARTH,1 FOR MOON B-1
051165,000117: 13,2400           73545                           DLOAD    SIN                                   #                COS(LONG)COS(LAT) IN MPAC
051166,000118: 13,2401           01104                                    LAT                                   #       UNIT RP= SIN(LONG)COS(LAT)    2-3D
051167,000119: 13,2402           65275                           DMPR     PDDL                                  #  PD 2          GAMMA*SIN(LAT)       0-1D
051168,000120: 13,2403           00011                                    GAMRP                                 
051169,000121: 13,2404           01104                                    LAT                                   #          0-1D= GAMMA*SIN(LAT) B-2
051170,000122: 13,2405           65346                           COS      PDDL                                  #  PD 4     2-3D=COS(LAT) B-1 TEMPORARILY
051171,000123: 13,2406           01106                                    LONG                                  
051172,000124: 13,2407           57356                           SIN      DMPR                                  #  PD 2
051173,000125: 13,2410           71525                           PDDL     COS                                   #  PD 4    2-3D=SIN(LONG)COS(LAT) B-2
051174,000126: 13,2411           01104                                    LAT                                   
051175,000127: 13,2412           71525                           PDDL     COS                                   #  PD 6     4-5D=COS(LAT) B-1 TEMPORARILY
051176,000128: 13,2413           01106                                    LONG                                  
051177,000129: 13,2414           55475                           DMPR     VDEF                                  #  PD4     MPAC= COS(LONG)COS(LAT) B-2
051178,000130: 13,2415           41456                           UNIT     PUSH                                  #  0-5D= UNIT RP FOR RP-TO-R SUBR.
051179,000131: 13,2416           36152                           STCALL   ALPHAV                                #  ALPHAV +4= SINL FOR SETRE SUBR.
051180,000132: 13,2417           26533                                    SETRE                                 #  RE METERS B-29
051181,000133: 13,2420           43145                           DLOAD    BOFF                                  #  SET MPAC=0 FOR EARTH,NON-ZERO FOR MOON
051182,000134: 13,2421           11453                                    ZEROVEC                               
051183,000135: 13,2422           01743                                    LUNAFLAG                              
051184,000136: 13,2423           26425                                    CALLRPRT                              
051185,000137: 13,2424           77746                           COS                                            #  USE COS(0) TO GET NON-ZERO IN MPAC
051186,000138: 13,2425           77624        CALLRPRT           CALL                                           
051187,000139: 13,2426           55341                                    RP-TO-R                               #  EXIT WITH UNIT R VECTOR IN MPAC
051188,000140: 13,2427           16152                           STODL    ALPHAV                                
051189,000141: 13,2430           02241                                    ERADM                                 

Page 1206

051191,000143: 13,2431           74215                           DAD      VXSC                                  #  (RE + ALT)(UNIT R) METERS B-30
051192,000144: 13,2432           01110                                    ALT                                   
051193,000145: 13,2433           02152                                    ALPHAV                                
051194,000146: 13,2434           77772                           VSL1                                           #  R METERS B-29
051195,000147: 13,2435           36152                           STCALL   ALPHAV                                #  EXIT WITH R IN METERS B-29
051196,000148: 13,2436           02242                                    INCORPEX                              
051197,000149:                                                                                                  #  SUBROUTINE TO COMPUTE EARTH RADIUS
051198,000150: 
051199,000151:                                                                                                  #  INPUT
051200,000152: 
051201,000153:                                                                                                  #    1/2 SIN LAT IN ALPHAV +4
051202,000154: 
051203,000155:                                                                                                  #  OUTPUT
051204,000156: 
051205,000157:                                                                                                  #    EARTH RADIUS IN ERADM AND MPAC  (METERS B-29)
051206,000158: 
051207,000159: 13,2437           63545        GETERAD            DLOAD    DSQ                                   
051208,000160: 13,2440           02156                                    ALPHAV     +4                         #  SIN**2(L)
051209,000161: 13,2441           44352                           SL1      BDSU                                  
051210,000162: 13,2442           11451                                    DP1/2                                 #  COS**2(L)
051211,000163: 13,2443           44275                           DMPR     BDSU                                  
051212,000164: 13,2444           26460                                    EE                                    
051213,000165: 13,2445           11451                                    DP1/2                                 
051214,000166: 13,2446           75465                           BDDV     SQRT                                  
051215,000167: 13,2447           26454                                    B2XSC                                 
051216,000168: 13,2450           77622                           SR4R                                           
051217,000169: 13,2451           02241                           STORE    ERADM                                 
051218,000170: 13,2452           77616                           RVQ                                            
051219,000171: 
051220,000172:                                                                                                  #  THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166,B=6356784 METERS
051221,000173:                                                                                                  #  B2XSC= B**2 SCALED B-51
051222,000174:                                                                                                  #  B2/A2= B**2/A**2 SCALED B-1
051223,000175:                                                                                                  #  EE=(1-B**2/A**2) SCALED B-0
051224,000176: 
051225,000177: 13,2453           00446 00305  B2XSC              2DEC     .0179450689                            #  B**2 SCALED B-51
051226,000178: 13,2455  04,3450               DP1/2              =        XUNIT                                 
051227,000179: 13,2455           17711 05254  B2/A2              2DEC     .9933064884 B-1                        #  GAMMA= B**2/A**2 B-1
051228,000180: 13,2457           00155 25250  EE                 2DEC     6.6935116  E-3                        #  (1-B**2/A**2) B-0
051229,000181: 13,2461           00302 17755  ERAD               2DEC     6373338    B-29                       #  PAD RADIUS
051230,000182: 

Page 1207

051232,000184:                                                                                                  #  ARCTAN SUBROUTINE
051233,000185: 
051234,000186: 
051235,000187:                                                                                                  #  CALLING SEQUENCE
051236,000188: 
051237,000189:                                                                                                  #    SIN THETA IN SINTH B-1
051238,000190:                                                                                                  #    COS THETA IN COSTH B-1
051239,000191:                                                                                                  #    CALL ARCTAN
051240,000192: 
051241,000193:                                                                                                  #  OUTPUT
051242,000194:                                                                                                  #    ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
051243,000195: 
051244,000196: 
051245,000197: 13,2463           77600        ARCTAN             BOV                                            
051246,000198: 13,2464           26465                                    CLROVFLW                              
051247,000199: 13,2465           63545        CLROVFLW           DLOAD    DSQ                                   
051248,000200: 13,2466           00023                                    SINTH                                 
051249,000201: 13,2467           63525                           PDDL     DSQ                                   
051250,000202: 13,2470           00021                                    COSTH                                 
051251,000203: 13,2471           77615                           DAD                                            
051252,000204: 13,2472           75454                           BZE      SQRT                                  
051253,000205: 13,2473           26511                                    ARCTANXX                              #  ATAN=0/0  SET THETA=0
051254,000206: 13,2474           40065                           BDDV     BOV                                   
051255,000207: 13,2475           00023                                    SINTH                                 
051256,000208: 13,2476           26516                                    ATAN=90                               
051257,000209: 13,2477           67542                           SR1      ASIN                                  
051258,000210: 13,2500           00025                           STORE    THETA                                 
051259,000211: 13,2501           50125                           PDDL     BMN                                   
051260,000212: 13,2502           00021                                    COSTH                                 
051261,000213: 13,2503           26505                                    NEGCOS                                
051262,000214: 13,2504           43545                           DLOAD    RVQ                                   
051263,000215: 13,2505           57545        NEGCOS             DLOAD    DCOMP                                 
051264,000216: 13,2506           43244                           BPL      DAD                                   
051265,000217: 13,2507           26513                                    NEGOUT                                
051266,000218: 13,2510           11451                                    DP1/2                                 
051267,000219: 13,2511           00025        ARCTANXX           STORE    THETA                                 
051268,000220: 13,2512           77616                           RVQ                                            
051269,000221: 
051270,000222: 13,2513           52025        NEGOUT             DSU      GOTO                                  
051271,000223: 13,2514           11451                                    DP1/2                                 
051272,000224: 13,2515           26511                                    ARCTANXX                              
051273,000225: 13,2516           75345        ATAN=90            DLOAD    SIGN                                  
051274,000226: 13,2517           11477                                    LODP1/4                               
051275,000227: 13,2520           00023                                    SINTH                                 
051276,000228: 13,2521           00025                           STORE    THETA                                 
051277,000229: 13,2522           77616                           RVQ                                            
051278,000230: 
051279,000231: 13,2523  04,3452               2DZERO             =        DPZERO                                
051280,000232: 

Page 1208

051282,000234:                                                                                                  #  ..... SETGAMMA SUBROUTINE .....
051283,000235:                                                                                                  #  SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
051284,000236: 
051285,000237:                                                                                                  #   GAMMA = B**2/A**2 FOR EARTH (B-1)
051286,000238:                                                                                                  #   GAMMA = 1 FOR MOON (B-1)
051287,000239: 
051288,000240:                                                                                                  #  CALLING SEQUENCE
051289,000241:                                                                                                  #   L       CALL
051290,000242:                                                                                                  #   L+1            SETGAMMA
051291,000243: 
051292,000244:                                                                                                  #  INPUT
051293,000245:                                                                                                  #   LUNAFLAG=0 FOR EARTH,=1 FOR MOON
051294,000246: 
051295,000247:                                                                                                  #  OUTPUT
051296,000248:                                                                                                  #   GAMMA IN GAMRP  (B-1)
051297,000249: 
051298,000250: 13,2523           43145        SETGAMMA           DLOAD    BOFF                                  #  BRANCH FOR EARTH
051299,000251: 13,2524           26456                                    B2/A2                                 #  EARTH GAMMA
051300,000252: 13,2525           01743                                    LUNAFLAG                              
051301,000253: 13,2526           26531                                    SETGMEX                               
051302,000254: 13,2527           77735                           SLOAD                                          
051303,000255: 13,2530           11451                                    1B1                                   #  MOON GAMMA
051304,000256: 13,2531           00011        SETGMEX            STORE    GAMRP                                 
051305,000257: 13,2532           77616                           RVQ                                            
051306,000258: 13,2533                        GAMRP              =        8D                                    
051307,000259: 

Page 1209

051309,000261:                                                                                                  #  .....SETRE SUBROUTINE .....
051310,000262:                                                                                                  #  SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
051311,000263: 
051312,000264:                                                                                                  #  RE= RM FOR MOON
051313,000265:                                                                                                  #   RE= RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
051314,000266: 
051315,000267:                                                                                                  #  CALLING SEQUENCE
051316,000268:                                                                                                  #   L       CALL
051317,000269:                                                                                                  #   L+1            SETRE
051318,000270: 
051319,000271:                                                                                                  #  SUBROUTINES USED
051320,000272:                                                                                                  #   GETERAD
051321,000273: 
051322,000274:                                                                                                  #  INPUT
051323,000275:                                                                                                  #   ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED RE
051324,000276:                                                                                                  #   ALPHAV +4= 1/2 SINL IF GETERAD IS CALLED
051325,000277:                                                                                                  #   LUNAFLAG=0 FOR EARTH,=1 FOR MOON
051326,000278: 
051327,000279:                                                                                                  #  OUTPUT
051328,000280:                                                                                                  #   ERADM= 504RM FOR MOON (METERS B-29)
051329,000281:                                                                                                  #   ERADM= ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
051330,000282: 
051331,000283: 13,2533           71220        SETRE              STQ      DLOAD                                 
051332,000284: 13,2534           00051                                    SETREX                                
051333,000285: 13,2535           26560                                    504RM                                 
051334,000286: 13,2536           71214                           BON      DLOAD                                 #  BRANCH FOR MOON
051335,000287: 13,2537           01703                                    LUNAFLAG                              
051336,000288: 13,2540           26550                                    TSTRLSRM                              
051337,000289: 13,2541           26462                                    ERAD                                  
051338,000290: 13,2542           45014                           BOFF     CALL                                  #  ERADFLAG=0 FOR FIXED RE,1 FOR COMPUTED
051339,000291: 13,2543           00742                                    ERADFLAG                              
051340,000292: 13,2544           26546                                    SETRXX                                
051341,000293: 13,2545           26437                                    GETERAD                               
051342,000294: 13,2546           36241        SETRXX             STCALL   ERADM                                 #  EXIT WITH RE OR RM METERS B-29
051343,000295: 13,2547           00051                                    SETREX                                
051344,000296: 13,2550           77214        TSTRLSRM           BON      VLOAD                                 #  ERADFLAG=0,SET R0=RLS
051345,000297: 13,2551           00702                                    ERADFLAG                              #          =1     R0=RM
051346,000298: 13,2552           26546                                    SETRXX                                
051347,000299: 13,2553           02026                                    RLS                                   
051348,000300: 13,2554           64446                           ABVAL    SR2R                                  #  SCALE FROM B-27 TO B-29
051349,000301: 13,2555           77650                           GOTO                                           
051350,000302: 13,2556           26546                                    SETRXX                                
051351,000303: 13,2557  0000051               SETREX             =        S2                                    
051352,000304: 13,2557           00065 01265  504RM              2DEC     1738090    B-29                       #  METERS B-29 (MOON RADIUS)

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