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.

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

Page 1236

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

Page 1237

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

Page 1238

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

Page 1239

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

Page 1240

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

Page 1241

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

Page 1242

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