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.

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

Page 1236

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

Page 1237

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

Page 1238

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

Page 1239

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

Page 1240

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

Page 1241

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

Page 1242

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