Source Code

These source-code files were obtained by digitally photographing an Artemis 72 (Apollo 15-17 Command Module) program listing from a private collection and then modifying pre-existing Comanche 55 (Apollo 11) source files to incorporate changes. Photography was by Ron Burkey, and transcription was performed by a team of volunteers. Note that the page images presented online are of reduced quality, and that additional images may be 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 072 OF AGC PROGRAM ARTEMIS 
	BY NASA 2021114-011 11:40 FEB. 26, 1971
Note that the date is the date of the printout, not the date of the program revision.

052904,000002:                                                                                                  ## Copyright:   Public domain.
052905,000003:                                                                                                  ## Filename:    LATITUDE_LONGITUDE_SUBROUTINES.agc
052906,000004:                                                                                                  ## Purpose:     Part of the source code for Artemis (i.e., Colossus 3),
052907,000005:                                                                                                  ##              build 072.  This is for the Command Module's (CM)
052908,000006:                                                                                                  ##              Apollo Guidance Computer (AGC), for
052909,000007:                                                                                                  ##              Apollo 15-17.
052910,000008:                                                                                                  ## Assembler:   yaYUL
052911,000009:                                                                                                  ## Contact:     Sergio Navarro <sergionavarrog@gmail.com>
052912,000010:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
052913,000011:                                                                                                  ## Page Scans:  www.ibiblio.org/apollo/ScansForConversion/Artemis072/
052914,000012:                                                                                                  ## Mod history: 2009-09-03 SN   Adapted from corresponding Comanche 055 file.
052915,000013:                                                                                                  ##              2009-09-04 JL   Fixed typos.
052916,000014:                                                                                                  ##              2010-02-20 RSB  Un-##'d this header.
052917,000015:                                                                                                  ##              2010-04-13 JL   Fixed a typo (' instead of #).
052918,000016:                                                                                                  ##              2010-08-15 JL   Fixed indentation.
052919,000017:                                                                                                  ##              2017-02-05 RSB  Proofed comment text by diff'ing vs Comanche 55
052920,000018:                                                                                                  ##                              and corrected errors found.
052921,000019:                                                                                                  ##              2017-03-15 RSB  Comment-text fixes identified in 5-way
052922,000020:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
052923,000021: 

Page 1236

052925,000023:                                                                                                  #  SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
052926,000024: 
052927,000025:                                                                                                  #  CALLING SEQUENCE
052928,000026: 
052929,000027:                                                                                                  #        L-1     CALL
052930,000028:                                                                                                  #        L               LAT-LONG
052931,000029: 
052932,000030:                                                                                                  #  SUBROUTINES USED
052933,000031: 
052934,000032:                                                                                                  #        R-TO-RP, ARCTAN, SETGAMMA, SETRE
052935,000033: 
052936,000034:                                                                                                  #  ERASABLE INIT. REQ.
052937,000035: 
052938,000036:                                                                                                  #        AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
052939,000037:                                                                                                  #        ALPHAV = POSITION VECTOR METERS B-29
052940,000038:                                                                                                  #        MPAC -- TIME (CSECS B-28)
052941,000039:                                                                                                  #        ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
052942,000040:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
052943,000041: 
052944,000042:                                                                                                  #  OUTPUT
052945,000043: 
052946,000044:                                                                                                  #        LATITUDE IN LAT         (REVS. B-0)
052947,000045:                                                                                                  #        LONGITUDE IN LONG       (REVS. B-0)
052948,000046:                                                                                                  #        ALTITUDE IN ALT METERS B-29
052949,000047: 
052950,000048: 13,2000                                           SETLOC   LATLONG                               
052951,000049: 13,2000                                           BANK                                           
052952,000050: 
052953,000051: 13,2453                                           COUNT*   $$/LT-LG                              
052954,000052: 13,2453  E4,1551                                  EBANK=   ALPHAV                                
052955,000053: 13,2453           40220        LAT-LONG           STQ      SETPD                                 
052956,000054: 13,2454           02241                                    INCORPEX                              
052957,000055: 13,2455           00001                                    0D                                    
052958,000056: 13,2456           24007                           STOVL    6D                                    #  SAVE TIME IN 6-7D FOR R-TO-RP
052959,000057: 13,2457           02152                                    ALPHAV                                
052960,000058: 13,2460           51406                           PUSH     ABVAL                                 #  0-5D= R FOR R-TO-RP
052961,000059: 13,2461           16301                           STODL    ALPHAM                                #  ABS. VALUE OF R FOR ALT FORMULA BELOW
052962,000060: 13,2462           11762                                    ZEROVEC                               #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
052963,000061: 13,2463           71414                           BOFF     COS                                   #  USE COS(0) TO GET NON-ZERO IN MPAC
052964,000062: 13,2464           01743                                    LUNAFLAG                              #  0=EARTH,1=MOON
052965,000063: 13,2465           26466                                    CALLRTRP                              
052966,000064: 13,2466           77624        CALLRTRP           CALL                                           
052967,000065: 13,2467           55370                                    R-TO-RP                               #  RP VECTOR CONVERTED FROM R B-29
052968,000066: 13,2470           77656                           UNIT                                           #  UNIT RP B-1
052969,000067: 13,2471           36152                           STCALL   ALPHAV                                #  U2= 1/2 SINL FOR SETRE SUBR BELOW
052970,000068: 13,2472           35766                                    SETGAMMA                              #   SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
052971,000069: 13,2473           77624                           CALL                                           #   SCALED B-1
052972,000070: 13,2474           26654                                    SETRE                                 #  CALC RE METERS B-29
052973,000071: 13,2475           63545                           DLOAD    DSQ                                   
052974,000072: 13,2476           02152                                    ALPHAV                                
052975,000073: 13,2477           63525                           PDDL     DSQ                                   
052976,000074: 13,2500           02154                                    ALPHAV     +2                         
052977,000075: 13,2501           75415                           DAD      SQRT                                  
052978,000076: 13,2502           76405                           DMP      SL1R                                  

Page 1237

052980,000078: 13,2503           00011                                    GAMRP                                 
052981,000079: 13,2504           14021                           STODL    COSTH                                 #  COS(LAT) B-1
052982,000080: 13,2505           02156                                    ALPHAV     +4                         
052983,000081: 13,2506           34023                           STCALL   SINTH                                 #  SIN(LAT) B-1
052984,000082: 13,2507           26614                                    ARCTAN                                
052985,000083: 13,2510           14747                           STODL    LAT                                   #  LAT B0
052986,000084: 13,2511           02152                                    ALPHAV                                
052987,000085: 13,2512           14021                           STODL    COSTH                                 #  COS(LONG) B-1
052988,000086: 13,2513           02154                                    ALPHAV     +2                         
052989,000087: 13,2514           34023                           STCALL   SINTH                                 #  SIN(LONG) B-1
052990,000088: 13,2515           26614                                    ARCTAN                                
052991,000089: 13,2516           14751                           STODL    LONG                                  #  LONG. REVS B-0 IN RANGE -1/2 TO 1/2
052992,000090: 13,2517           02301                                    ALPHAM                                
052993,000091: 13,2520           77625                           DSU                                            #  ALT= R-RE METERS B-29
052994,000092: 13,2521           02240                                    ERADM                                 
052995,000093: 13,2522           34753                           STCALL   ALT                                   #  EXIT WITH ALT METERS B-29
052996,000094: 13,2523           02241                                    INCORPEX                              
052997,000095: 

Page 1238

052999,000097:                                                                                                  #  SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
053000,000098: 
053001,000099:                                                                                                  #  CALLING SEQUENCE
053002,000100: 
053003,000101:                                                                                                  #        L-1     CALL
053004,000102:                                                                                                  #        L               LALOTORV
053005,000103: 
053006,000104:                                                                                                  #  SUBROUTINES USED
053007,000105: 
053008,000106:                                                                                                  #        SETGAMMA, SETRE, RP-TO-R
053009,000107: 
053010,000108:                                                                                                  #  ERASABLE INIT. REQ.
053011,000109: 
053012,000110:                                                                                                  #        AXO, AYO, AZO, TEPHEM  SET AT LAUNCH TIME
053013,000111:                                                                                                  #        LAT -- LATITUDE         (REVS B0)
053014,000112:                                                                                                  #        LONG -- LONGITUDE       (REVS B0)
053015,000113:                                                                                                  #        ALT -- ALTITUDE         (METERS) B-29
053016,000114:                                                                                                  #        MPAC -- TIME            (CSECS B-28)
053017,000115:                                                                                                  #        ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
053018,000116:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
053019,000117: 
053020,000118:                                                                                                  #  OUTPUT
053021,000119: 
053022,000120:                                                                                                  #        R-VECTOR IN ALPHAV (METERS B-29)
053023,000121: 
053024,000122: 13,2524           40220        LALOTORV           STQ      SETPD                                 #  LAT,LONG,ALT TO R VECTOR
053025,000123: 13,2525           02241                                    INCORPEX                              
053026,000124: 13,2526           00001                                    0D                                    
053027,000125: 13,2527           34007                           STCALL   6D                                    #  6-7D = TIME FOR RP-TO-R
053028,000126: 13,2530           35766                                    SETGAMMA                              #  GAMMA = B2/A2 FOR EARTH, 1 FOR MOON B-1
053029,000127: 13,2531           73545                           DLOAD    SIN                                   #                   COS(LONG)COS(LAT) IN MPAC
053030,000128: 13,2532           00747                                    LAT                                   #        UNIT  RP = SIN(LONG)COS(LAT)    2-3D
053031,000129: 13,2533           65275                           DMPR     PDDL                                  #  PD 2             GAMMA*SIN(LAT)       0-1D
053032,000130: 13,2534           00011                                    GAMRP                                 
053033,000131: 13,2535           00747                                    LAT                                   #            0-1D = GAMMA*SIN(LAT) B-2
053034,000132: 13,2536           65346                           COS      PDDL                                  #  PD4       2-3D = COS(LAT) B-1 TEMPORARILY
053035,000133: 13,2537           00751                                    LONG                                  
053036,000134: 13,2540           57356                           SIN      DMPR                                  #  PD 2
053037,000135: 13,2541           71525                           PDDL     COS                                   #  PD 4      2-3D = SIN(LONG)COS(LAT) B-2
053038,000136: 13,2542           00747                                    LAT                                   
053039,000137: 13,2543           71525                           PDDL     COS                                   #  PD 6      4-5D = COS(LAT) B-1 TEMPORARILY
053040,000138: 13,2544           00751                                    LONG                                  
053041,000139: 13,2545           55475                           DMPR     VDEF                                  #  PD4       MPAC = COS(LONG)COS(LAT) B-2
053042,000140: 13,2546           41456                           UNIT     PUSH                                  #  0-5D = UNIT RP FOR RP-TO-R SUBR.
053043,000141: 13,2547           36152                           STCALL   ALPHAV                                #  ALPHAV +4= SINL FOR SETRE SUBR.
053044,000142: 13,2550           26654                                    SETRE                                 #  RE METERS B-29
053045,000143: 13,2551           43145                           DLOAD    BOFF                                  #  SET MPAC = 0 FOR EARTH, NON-ZERO FOR MOON
053046,000144: 13,2552           11762                                    ZEROVEC                               
053047,000145: 13,2553           01743                                    LUNAFLAG                              
053048,000146: 13,2554           26556                                    CALLRPRT                              
053049,000147: 13,2555           77746                           COS                                            #  USE COS(0) TO GET NON-ZERO IN MPAC
053050,000148: 13,2556           77624        CALLRPRT           CALL                                           
053051,000149: 13,2557           55345                                    RP-TO-R                               #  EXIT WITH UNIT R VECTOR IN MPAC
053052,000150: 13,2560           16152                           STODL    ALPHAV                                
053053,000151: 13,2561           02240                                    ERADM                                 

Page 1239

053055,000153: 13,2562           74215                           DAD      VXSC                                  #  (RE + ALT)(UNIT R) METERS B-30
053056,000154: 13,2563           00753                                    ALT                                   
053057,000155: 13,2564           02152                                    ALPHAV                                
053058,000156: 13,2565           77772                           VSL1                                           #  R METERS B-29
053059,000157: 13,2566           36152                           STCALL   ALPHAV                                #  EXIT WITH R IN METERS B-29
053060,000158: 13,2567           02241                                    INCORPEX                              
053061,000159: 
053062,000160:                                                                                                  #  SUBROUTINE TO COMPUTE EARTH RADIUS
053063,000161: 
053064,000162:                                                                                                  #  INPUT
053065,000163: 
053066,000164:                                                                                                  #        1/2 SIN LAT IN ALPHAV +4
053067,000165: 
053068,000166:                                                                                                  #  OUTPUT
053069,000167: 
053070,000168:                                                                                                  #        EARTH RADIUS IN ERADM AND MPAC  (METERS B-29)
053071,000169: 
053072,000170: 13,2570           63545        GETERAD            DLOAD    DSQ                                   
053073,000171: 13,2571           02156                                    ALPHAV     +4                         #  SIN**2(L)
053074,000172: 13,2572           44352                           SL1      BDSU                                  
053075,000173: 13,2573           11760                                    DP1/2                                 #  COS**2(L)
053076,000174: 13,2574           44275                           DMPR     BDSU                                  
053077,000175: 13,2575           26611                                    EE                                    
053078,000176: 13,2576           11760                                    DP1/2                                 
053079,000177: 13,2577           75465                           BDDV     SQRT                                  
053080,000178: 13,2600           26605                                    B2XSC                                 
053081,000179: 13,2601           77622                           SR4R                                           
053082,000180: 13,2602           02240                           STORE    ERADM                                 
053083,000181: 13,2603           77616                           RVQ                                            
053084,000182: 
053085,000183:                                                                                                  #  THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
053086,000184:                                                                                                  #  B2XSC = B**2 SCALED B-51
053087,000185:                                                                                                  #  B2/A2 = B**2/A**2  SCALED B-1
053088,000186:                                                                                                  #  EE = (1-B**2/A**2) SCALED B-0
053089,000187: 
053090,000188: 13,2604           00446 00305  B2XSC              2DEC     .0179450689                            #  B**2 SCALED B-51
053091,000189: 13,2606  04,3757               DP1/2              =        XUNIT                                 
053092,000190: 13,2606           17711 05254  B2/A2              2DEC     .9933064884 B-1                        #  GAMMA= B**2/A**2 B-1
053093,000191: 13,2610           00155 25250  EE                 2DEC     6.6935116  E-3                        #  (1-B**2/A**2) B-0
053094,000192: 13,2612           00302 17755  ERAD               2DEC     6373338    B-29                       #  PAD RADIUS
053095,000193: 

Page 1240

053097,000195:                                                                                                  #  ARCTAN SUBROUTINE
053098,000196: 
053099,000197:                                                                                                  #  CALLING SEQUENCE
053100,000198: 
053101,000199:                                                                                                  #        SIN THETA IN SINTH B-1
053102,000200:                                                                                                  #        COS THETA IN COSTH B-1
053103,000201:                                                                                                  #        CALL ARCTAN
053104,000202: 
053105,000203:                                                                                                  #  OUTPUT
053106,000204:                                                                                                  #        ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
053107,000205: 
053108,000206: 13,2614           77600        ARCTAN             BOV                                            
053109,000207: 13,2615           26616                                    CLROVFLW                              
053110,000208: 13,2616           63545        CLROVFLW           DLOAD    DSQ                                   
053111,000209: 13,2617           00023                                    SINTH                                 
053112,000210: 13,2620           63525                           PDDL     DSQ                                   
053113,000211: 13,2621           00021                                    COSTH                                 
053114,000212: 13,2622           77615                           DAD                                            
053115,000213: 13,2623           75454                           BZE      SQRT                                  
053116,000214: 13,2624           26642                                    ARCTANXX                              #  ATAN=0/0  SET THETA=0
053117,000215: 13,2625           40065                           BDDV     BOV                                   
053118,000216: 13,2626           00023                                    SINTH                                 
053119,000217: 13,2627           26647                                    ATAN=90                               
053120,000218: 13,2630           67542                           SR1      ASIN                                  
053121,000219: 13,2631           00025                           STORE    THETA                                 
053122,000220: 13,2632           50125                           PDDL     BMN                                   
053123,000221: 13,2633           00021                                    COSTH                                 
053124,000222: 13,2634           26636                                    NEGCOS                                
053125,000223: 13,2635           43545                           DLOAD    RVQ                                   
053126,000224: 13,2636           57545        NEGCOS             DLOAD    DCOMP                                 
053127,000225: 13,2637           43244                           BPL      DAD                                   
053128,000226: 13,2640           26644                                    NEGOUT                                
053129,000227: 13,2641           11760                                    DP1/2                                 
053130,000228: 13,2642           00025        ARCTANXX           STORE    THETA                                 
053131,000229: 13,2643           77616                           RVQ                                            
053132,000230: 
053133,000231: 13,2644           52025        NEGOUT             DSU      GOTO                                  
053134,000232: 13,2645           11760                                    DP1/2                                 
053135,000233: 13,2646           26642                                    ARCTANXX                              
053136,000234: 13,2647           75345        ATAN=90            DLOAD    SIGN                                  
053137,000235: 13,2650           33412                                    LODP1/4                               
053138,000236: 13,2651           00023                                    SINTH                                 
053139,000237: 13,2652           00025                           STORE    THETA                                 
053140,000238: 13,2653           77616                           RVQ                                            
053141,000239: 
053142,000240: 13,2654  04,3761               2DZERO             =        DPZERO                                
053143,000241: 

Page 1241

053145,000243:                                                                                                  #  ..... SETGAMMA SUBROUTINE .....
053146,000244:                                                                                                  #  SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
053147,000245: 
053148,000246:                                                                                                  #  GAMMA = B**2/A**2 FOR EARTH (B-1)
053149,000247:                                                                                                  #  GAMMA = 1 FOR MOON (B-1)
053150,000248: 
053151,000249:                                                                                                  #  CALLING SEQUENCE
053152,000250:                                                                                                  #        L       CALL
053153,000251:                                                                                                  #        L+1             SETGAMMA
053154,000252: 
053155,000253:                                                                                                  #  INPUT
053156,000254:                                                                                                  #        LUNAFLAG=0 FOR EARTH, =1 FOR MOON
053157,000255: 
053158,000256:                                                                                                  #  OUTPUT
053159,000257:                                                                                                  #        GAMMA IN GAMRP  (B-1)
053160,000258: 
053161,000259: 16,2000                                           SETLOC   LATLONG1                              
053162,000260: 16,2000                                           BANK                                           
053163,000261: 16,3766                                           COUNT*   $$/LT-LG                              
053164,000262: 
053165,000263: 16,3766           43145        SETGAMMA           DLOAD    BOFF                                  #  BRANCH FOR EARTH
053166,000264: 16,3767           26607                                    B2/A2                                 #  EARTH GAMMA
053167,000265: 16,3770           01743                                    LUNAFLAG                              
053168,000266: 16,3771           35774                                    SETGMEX                               
053169,000267: 16,3772           77735                           SLOAD                                          
053170,000268: 16,3773           11760                                    1B1                                   #  MOON GAMMA
053171,000269: 16,3774           00011        SETGMEX            STORE    GAMRP                                 
053172,000270: 16,3775           77616                           RVQ                                            
053173,000271: 16,3776                        GAMRP              =        8D                                    
053174,000272: 13,2000                                           SETLOC   LATLONG                               
053175,000273: 13,2000                                           BANK                                           
053176,000274: 

Page 1242

053178,000276:                                                                                                  #  ..... SETRE SUBROUTINE .....
053179,000277:                                                                                                  #  SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
053180,000278: 
053181,000279:                                                                                                  #   RE = RM FOR MOON
053182,000280:                                                                                                  #   RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
053183,000281: 
053184,000282:                                                                                                  #  CALLING SEQUENCE
053185,000283:                                                                                                  #   L    CALL
053186,000284:                                                                                                  #   L+1          SETRE
053187,000285: 
053188,000286:                                                                                                  #  SUBROUTINES USED
053189,000287:                                                                                                  #   GETERAD
053190,000288: 
053191,000289:                                                                                                  #  INPUT
053192,000290:                                                                                                  #   ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
053193,000291:                                                                                                  #   ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
053194,000292:                                                                                                  #   LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
053195,000293: 
053196,000294:                                                                                                  #  OUTPUT
053197,000295:                                                                                                  #   ERADM = 504RM FOR MOON (METERS B-29)
053198,000296:                                                                                                  #   ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
053199,000297: 
053200,000298: 13,2654           71220        SETRE              STQ      DLOAD                                 
053201,000299: 13,2655           00051                                    SETREX                                
053202,000300: 13,2656           26701                                    504RM                                 
053203,000301: 13,2657           71214                           BON      DLOAD                                 #  BRANCH FOR MOON
053204,000302: 13,2660           01703                                    LUNAFLAG                              
053205,000303: 13,2661           26671                                    TSTRLSRM                              
053206,000304: 13,2662           26613                                    ERAD                                  
053207,000305: 13,2663           45014                           BOFF     CALL                                  #  ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
053208,000306: 13,2664           00742                                    ERADFLAG                              
053209,000307: 13,2665           26667                                    SETRXX                                
053210,000308: 13,2666           26570                                    GETERAD                               
053211,000309: 13,2667           36240        SETRXX             STCALL   ERADM                                 #  EXIT WITH RE OR RM METERS B-29
053212,000310: 13,2670           00051                                    SETREX                                
053213,000311: 13,2671           77214        TSTRLSRM           BON      VLOAD                                 #  ERADFLAG=0, SET R0=RLS
053214,000312: 13,2672           00702                                    ERADFLAG                              #          =1      R0=RM
053215,000313: 13,2673           26667                                    SETRXX                                
053216,000314: 13,2674           02026                                    RLS                                   
053217,000315: 13,2675           64446                           ABVAL    SR2R                                  #  SCALE FROM B-27 TO B-29
053218,000316: 13,2676           77650                           GOTO                                           
053219,000317: 13,2677           26667                                    SETRXX                                
053220,000318: 13,2700  0000051               SETREX             =        S2                                    
053221,000319: 13,2700           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