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.

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

Page 1203

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

Page 1204

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

Page 1205

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

Page 1206

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

Page 1207

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

Page 1208

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

Page 1209

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