Source Code

These source-code files were transcribed from scans made from Don Eyles's personal copy of Luminary 069. They were scanned at archive.org's Boston facility, and the scanning was sponsored by Onno Hommes. The code was transcribed from these scans by a team of volunteers who are referenced in the program comments. Comments from the original source code are prefixed with a single '#' symbol, whereas comments added later are prefixed by "##" or "###". In some cases, where similar code blocks exist in previously-transcribed AGC programs (primarily Luminary 99, from Apollo 11) those code blocks were used as a starting point and then corrected to agree with the Luminary 69 scans. The full scans are available at the Virtual AGC project's collection at archive.org, while more-convenient reduced-size (but reduced-quality) images are available at the main Virtual AGC website. Report any errors noted by creating an issue report at the Virtual AGC project's GitHub repository. Notations on the program listing read, in part:

	GAP:  ASSEMBLE REVISION 069 OF AGC PROGRAM LUMINARY BY NASA 2021112-011
	19:02 NOV. 25,1968
Note that the date is the date of the printout, not the date of the program revision.

048691,000002:                                                                                                  ## Copyright:   Public domain.
048692,000003:                                                                                                  ## Filename:    LATITUDE_LONGITUDE_SUBROUTINES.agc
048693,000004:                                                                                                  ## Purpose:     The main source file for Luminary revision 069.
048694,000005:                                                                                                  ##              It is part of the source code for the original release
048695,000006:                                                                                                  ##              of the flight software for the Lunar Module's (LM) Apollo
048696,000007:                                                                                                  ##              Guidance Computer (AGC) for Apollo 10. The actual flown
048697,000008:                                                                                                  ##              version was Luminary 69 revision 2, which included a
048698,000009:                                                                                                  ##              newer lunar gravity model and only affected module 2.
048699,000010:                                                                                                  ##              This file is intended to be a faithful transcription, except
048700,000011:                                                                                                  ##              that the code format has been changed to conform to the
048701,000012:                                                                                                  ##              requirements of the yaYUL assembler rather than the
048702,000013:                                                                                                  ##              original YUL assembler.
048703,000014:                                                                                                  ## Reference:   pp. 1128-1134
048704,000015:                                                                                                  ## Assembler:   yaYUL
048705,000016:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
048706,000017:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
048707,000018:                                                                                                  ## Mod history: 2016-12-13 MAS  Created from Luminary 99.
048708,000019:                                                                                                  ##              2016-12-18 MAS  Updated from comment-proofed Luminary 99 version.
048709,000020:                                                                                                  ##              2017-01-28 RSB  Proofed comment text using octopus/prooferComments
048710,000021:                                                                                                  ##                              and fixed errors found.
048711,000022:                                                                                                  ##              2017-03-15 RSB  Comment-text fixes identified in 5-way
048712,000023:                                                                                                  ##                              side-by-side diff of Luminary 69/99/116/131/210.
048713,000024: 

Page 1128

048715,000026:                                                                                                  #  SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
048716,000027: 
048717,000028:                                                                                                  #  CALLING SEQUENCE
048718,000029:                                                                                                  #        L-1     CALL
048719,000030:                                                                                                  #        L               LAT-LONG
048720,000031: 
048721,000032:                                                                                                  #  SUBROUTINES USED
048722,000033:                                                                                                  #        R-TO-RP,ARCTAN,SETGAMMA,SETRE
048723,000034: 
048724,000035:                                                                                                  #  ERASABLE INIT. REQ.
048725,000036:                                                                                                  #        AXO,-AYO,AZO,TEPHEM (SET AT LAUNCH TIME)
048726,000037:                                                                                                  #        ALPHAV = POSITION VECTOR METERS B-29
048727,000038:                                                                                                  #        MPAC-- TIME (CSECS B-28)
048728,000039:                                                                                                  #        ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
048729,000040:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
048730,000041: 
048731,000042:                                                                                                  #  OUTPUT
048732,000043:                                                                                                  #        LATITUDE IN LAT         (REVS. B-0)
048733,000044:                                                                                                  #        LONGITUDE IN LONG       (REVS. B-0)
048734,000045:                                                                                                  #        ALTITUDE IN ALT         METERS B-29
048735,000046: 
048736,000047: 30,3746                                           BANK     30                                    
048737,000048: 13,2000                                           SETLOC   LATLONG                               
048738,000049: 13,2000                                           BANK                                           
048739,000050: 
048740,000051: 13,2351                                           COUNT*   $$/LT-LG                              
048741,000052: 13,2351  E4,1431                                  EBANK=   ALPHAV                                
048742,000053: 13,2351           40220        LAT-LONG           STQ      SETPD                                 
048743,000054: 13,2352           03672                                    INCORPEX                              
048744,000055: 13,2353           00001                                    0D                                    
048745,000056: 13,2354           24007                           STOVL    6D                                    #  SAVE TIME IN 6-7D FOR R-TO-RP
048746,000057: 13,2355           02032                                    ALPHAV                                
048747,000058: 13,2356           51406                           PUSH     ABVAL                                 #  0-5D= R FOR R-TO-RP
048748,000059: 13,2357           16070                           STODL    ALPHAM                                #  ABS. VALUE OF R FOR ALT FORMULA BELOW
048749,000060: 13,2360           22275                                    ZEROVEC                               #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
048750,000061: 13,2361           71414                           BOFF     COS                                   #  USE COS(0) TO GET NON-ZERO IN MPAC
048751,000062: 13,2362           01743                                    LUNAFLAG                              #  0=EARTH, 1=MOON
048752,000063: 13,2363           26364                                    CALLRTRP                              
048753,000064: 13,2364           77624        CALLRTRP           CALL                                           
048754,000065: 13,2365           51531                                    R-TO-RP                               #  RP VECTOR CONVERTED FROM R B-29
048755,000066: 13,2366           77656                           UNIT                                           #  UNIT RP B-1
048756,000067: 13,2367           36032                           STCALL   ALPHAV                                #  U2= 1/2 SINL FOR SETRE SUBR BELOW
048757,000068: 13,2370           26550                                    SETGAMMA                              #        SET GAMMA=B2/A2 FOR EARTH,=1 FOR MOON
048758,000069: 13,2371           77624                           CALL                                           #        SCALED B-1
048759,000070: 13,2372           26560                                    SETRE                                 #  CALC RE METERS B-29
048760,000071: 13,2373           63545                           DLOAD    DSQ                                   
048761,000072: 13,2374           02032                                    ALPHAV                                
048762,000073: 13,2375           63525                           PDDL     DSQ                                   
048763,000074: 13,2376           02034                                    ALPHAV     +2                         
048764,000075: 13,2377           75415                           DAD      SQRT                                  

Page 1129

048766,000077: 13,2400           76405                           DMP      SL1R                                  
048767,000078: 13,2401           00011                                    GAMRP                                 
048768,000079: 13,2402           14021                           STODL    COSTH                                 #  COS(LAT) B-1
048769,000080: 13,2403           02036                                    ALPHAV     +4                         
048770,000081: 13,2404           34023                           STCALL   SINTH                                 #  SIN(LAT) B-1
048771,000082: 13,2405           26510                                    ARCTAN                                
048772,000083: 13,2406           15121                           STODL    LAT                                   #  LAT B0
048773,000084: 13,2407           02032                                    ALPHAV                                
048774,000085: 13,2410           14021                           STODL    COSTH                                 #  COS(LONG) B-1
048775,000086: 13,2411           02034                                    ALPHAV     +2                         
048776,000087: 13,2412           34023                           STCALL   SINTH                                 #  SIN(LONG) B-1
048777,000088: 13,2413           26510                                    ARCTAN                                
048778,000089: 13,2414           15123                           STODL    LONG                                  #  LONG. REVS B-0 IN RANGE -1/2 TO 1/2
048779,000090: 13,2415           02070                                    ALPHAM                                
048780,000091: 13,2416           77625                           DSU                                            #  ALT= R-RE METERS B-29
048781,000092: 13,2417           03671                                    ERADM                                 
048782,000093: 13,2420           35125                           STCALL   ALT                                   #  EXIT WITH ALT METERS B-29
048783,000094: 13,2421           03672                                    INCORPEX                              

Page 1130

048785,000096:                                                                                                  #  SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
048786,000097: 
048787,000098:                                                                                                  #  CALLING SEQUENCE
048788,000099:                                                                                                  #        L-1     CALL
048789,000100:                                                                                                  #        L               LALOTORV
048790,000101: 
048791,000102:                                                                                                  #  SUBROUTINES USED
048792,000103:                                                                                                  #        SETGAMMA,SETRE,RP-TO-R
048793,000104: 
048794,000105:                                                                                                  #  ERASABLE INIT. REQ.
048795,000106:                                                                                                  #        AXO,AYO,AZO,TEPHEM SET AT LAUNCH TIME
048796,000107:                                                                                                  #        LAT-- LATITUDE  (REVS B0)
048797,000108:                                                                                                  #        LONG-- LONGITUDE        (REVS B0)
048798,000109:                                                                                                  #        ALT--ALTITUDE           (METERS) B-29
048799,000110:                                                                                                  #        MPAC-- TIME             (CSECS B-28)
048800,000111:                                                                                                  #        ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
048801,000112:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
048802,000113: 
048803,000114:                                                                                                  #  OUTPUT
048804,000115:                                                                                                  #        R-VECTOR IN ALPHAV      (METERS B-29)
048805,000116: 
048806,000117: 13,2422           40220        LALOTORV           STQ      SETPD                                 #  LAT,LONG,ALT TO R VECTOR
048807,000118: 13,2423           03672                                    INCORPEX                              
048808,000119: 13,2424           00001                                    0D                                    
048809,000120: 13,2425           34007                           STCALL   6D                                    #  6-7D= TIME FOR RP-TO-R
048810,000121: 13,2426           26550                                    SETGAMMA                              #  GAMMA=B2/A2 FOR EARTH,1 FOR MOON B-1
048811,000122: 13,2427           73545                           DLOAD    SIN                                   #                COS(LONG)COS(LAT) IN MPAC
048812,000123: 13,2430           01121                                    LAT                                   #      UNIT RP=  SIN(LONG)COS(LAT)    2-3D
048813,000124: 13,2431           65275                           DMPR     PDDL                                  #  PD 2          GAMMA*SIN(LAT)       0-1D
048814,000125: 13,2432           00011                                    GAMRP                                 
048815,000126: 13,2433           01121                                    LAT                                   #         0-1D=  GAMMA*SIN(LAT) B-2
048816,000127: 13,2434           65346                           COS      PDDL                                  #  PD 4     2-3D=COS(LAT) B-1 TEMPORARILY
048817,000128: 13,2435           01123                                    LONG                                  
048818,000129: 13,2436           57356                           SIN      DMPR                                  #  PD 2
048819,000130: 13,2437           71525                           PDDL     COS                                   #  PD 4   2-3D=SIN(LONG)COS(LAT) B-2
048820,000131: 13,2440           01121                                    LAT                                   
048821,000132: 13,2441           71525                           PDDL     COS                                   #  PD 6   4-5D=COS(LAT) B-1 TEMPORARILY
048822,000133: 13,2442           01123                                    LONG                                  
048823,000134: 13,2443           55475                           DMPR     VDEF                                  #  PD 4   MPAC=  COS(LONG)COS(LAT) B-2
048824,000135: 13,2444           41456                           UNIT     PUSH                                  #  0-5D= UNIT RP FOR RP-TO-R SUBR.
048825,000136: 13,2445           36032                           STCALL   ALPHAV                                #  ALPHAV +4= SINL FOR SETRE SUBR.
048826,000137: 13,2446           26560                                    SETRE                                 #  RE METERS B-29
048827,000138: 13,2447           43145                           DLOAD    BOFF                                  #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
048828,000139: 13,2450           22275                                    ZEROVEC                               
048829,000140: 13,2451           01743                                    LUNAFLAG                              
048830,000141: 13,2452           26454                                    CALLRPRT                              
048831,000142: 13,2453           77746                           COS                                            #  USE COS(0) TO GET NON-ZERO IN MPAC
048832,000143: 13,2454           77624        CALLRPRT           CALL                                           
048833,000144: 13,2455           51504                                    RP-TO-R                               #  EXIT WITH UNIT R VECTOR IN MPAC
048834,000145: 13,2456           16032                           STODL    ALPHAV                                
048835,000146: 13,2457           03671                                    ERADM                                 

Page 1131

048837,000148: 13,2460           74215                           DAD      VXSC                                  #  (RE + ALT)(UNIT R) METERS B-30
048838,000149: 13,2461           01125                                    ALT                                   
048839,000150: 13,2462           02032                                    ALPHAV                                
048840,000151: 13,2463           77772                           VSL1                                           #  R METERS B-29
048841,000152: 13,2464           36032                           STCALL   ALPHAV                                #  EXIT WITH R IN METERS B-29
048842,000153: 13,2465           03672                                    INCORPEX                              
048843,000154: 
048844,000155:                                                                                                  #  SUBROUTINE TO COMPUTE EARTH RADIUS
048845,000156: 
048846,000157:                                                                                                  #  INPUT
048847,000158:                                                                                                  #        1/2 SIN LAT IN ALPHAV +4
048848,000159: 
048849,000160:                                                                                                  #  OUTPUT
048850,000161:                                                                                                  #        EARTH RADIUS IN ERADM AND MPAC (METERS B-29)
048851,000162: 
048852,000163: 13,2466           63545        GETERAD            DLOAD    DSQ                                   
048853,000164: 13,2467           02036                                    ALPHAV     +4                         #  SIN**2(L)
048854,000165: 13,2470           44352                           SL1      BDSU                                  
048855,000166: 13,2471           22273                                    DP1/2                                 #  COS**2(L)
048856,000167: 13,2472           44275                           DMPR     BDSU                                  
048857,000168: 13,2473           26507                                    EE                                    
048858,000169: 13,2474           22273                                    DP1/2                                 
048859,000170: 13,2475           75465                           BDDV     SQRT                                  
048860,000171: 13,2476           26503                                    B2XSC                                 
048861,000172: 13,2477           77622                           SR4R                                           
048862,000173: 13,2500           03671                           STORE    ERADM                                 
048863,000174: 13,2501           77616                           RVQ                                            
048864,000175: 
048865,000176:                                                                                                  #  THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
048866,000177:                                                                                                  #  B2XSC= B**2 SCALED B-51
048867,000178:                                                                                                  #  B2/A2= B**2/A**2 SCALED B-1
048868,000179:                                                                                                  #  EE=(1-B**2/A**2) SCALED B-0
048869,000180: 
048870,000181: 13,2502           00446 00305  B2XSC              2DEC     .0179450689                            #  B**2 SCALED B-51
048871,000182: 13,2504  11,2272               DP1/2              =        XUNIT                                 
048872,000183: 13,2504           17711 05254  B2/A2              2DEC     .9933064884 B-1                        #  GAMMA= B**2/A**2 B-1
048873,000184: 13,2506           00155 25250  EE                 2DEC     6.6935116  E-3                        #  (1-B**2/A**2) B-0
048874,000185: 

Page 1132

048876,000187:                                                                                                  #  ARCTAN SUBROUTINE
048877,000188: 
048878,000189:                                                                                                  #  CALLING SEQUENCE
048879,000190:                                                                                                  #        SIN THETA IN SINTH B-1
048880,000191:                                                                                                  #        COS THETA IN COSTH B-1
048881,000192:                                                                                                  #        CALL ARCTAN
048882,000193: 
048883,000194:                                                                                                  #  OUTPUT
048884,000195:                                                                                                  #        ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
048885,000196: 
048886,000197: 13,2510           77600        ARCTAN             BOV                                            
048887,000198: 13,2511           26512                                    CLROVFLW                              
048888,000199: 13,2512           63545        CLROVFLW           DLOAD    DSQ                                   
048889,000200: 13,2513           00023                                    SINTH                                 
048890,000201: 13,2514           63525                           PDDL     DSQ                                   
048891,000202: 13,2515           00021                                    COSTH                                 
048892,000203: 13,2516           77615                           DAD                                            
048893,000204: 13,2517           75454                           BZE      SQRT                                  
048894,000205: 13,2520           26536                                    ARCTANXX                              #  ATAN=0/0  SET THETA=0
048895,000206: 13,2521           40065                           BDDV     BOV                                   
048896,000207: 13,2522           00023                                    SINTH                                 
048897,000208: 13,2523           26543                                    ATAN=90                               
048898,000209: 13,2524           67542                           SR1      ASIN                                  
048899,000210: 13,2525           00025                           STORE    THETA                                 
048900,000211: 13,2526           50125                           PDDL     BMN                                   
048901,000212: 13,2527           00021                                    COSTH                                 
048902,000213: 13,2530           26532                                    NEGCOS                                
048903,000214: 13,2531           43545                           DLOAD    RVQ                                   
048904,000215: 13,2532           57545        NEGCOS             DLOAD    DCOMP                                 
048905,000216: 13,2533           43244                           BPL      DAD                                   
048906,000217: 13,2534           26540                                    NEGOUT                                
048907,000218: 13,2535           22273                                    DP1/2                                 
048908,000219: 13,2536           00025        ARCTANXX           STORE    THETA                                 
048909,000220: 13,2537           77616                           RVQ                                            
048910,000221: 
048911,000222: 13,2540           52025        NEGOUT             DSU      GOTO                                  
048912,000223: 13,2541           22273                                    DP1/2                                 
048913,000224: 13,2542           26536                                    ARCTANXX                              
048914,000225: 13,2543           75345        ATAN=90            DLOAD    SIGN                                  
048915,000226: 13,2544           10760                                    LODP1/4                               
048916,000227: 13,2545           00023                                    SINTH                                 
048917,000228: 13,2546           00025                           STORE    THETA                                 
048918,000229: 13,2547           77616                           RVQ                                            
048919,000230: 
048920,000231: 13,2550  11,2274               2DZERO             =        DPZERO                                
048921,000232: 

Page 1133

048923,000234:                                                                                                  #  ..... SETGAMMA SUBROUTINE .....
048924,000235:                                                                                                  #  SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
048925,000236: 
048926,000237:                                                                                                  #  GAMMA = B**2/A**2 FOR EARTH (B-1)
048927,000238:                                                                                                  #  GAMMA = 1 FOR MOON (B-1)
048928,000239: 
048929,000240:                                                                                                  #  CALLING SEQUENCE
048930,000241:                                                                                                  #        L       CALL
048931,000242:                                                                                                  #        L+1             SETGAMMA
048932,000243: 
048933,000244:                                                                                                  #  INPUT
048934,000245:                                                                                                  #        LUNAFLAG=0 FOR EARTH,=1 FOR MOON
048935,000246: 
048936,000247:                                                                                                  #  OUTPUT
048937,000248:                                                                                                  #        GAMMA IN GAMRP (B-1)
048938,000249: 
048939,000250: 13,2550           43145        SETGAMMA           DLOAD    BOFF                                  #  BRANCH FOR EARTH
048940,000251: 13,2551           26505                                    B2/A2                                 #  EARTH GAMMA
048941,000252: 13,2552           01743                                    LUNAFLAG                              
048942,000253: 13,2553           26556                                    SETGMEX                               
048943,000254: 13,2554           77735                           SLOAD                                          
048944,000255: 13,2555           22273                                    1B1                                   #  MOON GAMMA
048945,000256: 13,2556           00011        SETGMEX            STORE    GAMRP                                 
048946,000257: 13,2557           77616                           RVQ                                            
048947,000258: 13,2560                        GAMRP              =        8D                                    
048948,000259: 

Page 1134

048950,000261:                                                                                                  #  ..... SETRE SUBROUTINE .....
048951,000262:                                                                                                  #  SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
048952,000263: 
048953,000264:                                                                                                  #        RE= RM FOR MOON
048954,000265:                                                                                                  #                RE= RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
048955,000266: 
048956,000267:                                                                                                  #  CALLING SEQUENCE
048957,000268:                                                                                                  #        L       CALL
048958,000269:                                                                                                  #        L+1             SETRE
048959,000270: 
048960,000271:                                                                                                  #  SUBROUTINES USED
048961,000272:                                                                                                  #        GETERAD
048962,000273: 
048963,000274:                                                                                                  #  INPUT
048964,000275:                                                                                                  #        ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED RE
048965,000276:                                                                                                  #        ALPHAV +4= 1/2 SINL IF GETERAD IS CALLED
048966,000277:                                                                                                  #        LUNAFLAG=0 FOR EARTH,=1 FOR MOON
048967,000278: 
048968,000279:                                                                                                  #  OUTPUT
048969,000280:                                                                                                  #        ERADM= 504RM FOR MOON (METERS B-29)
048970,000281:                                                                                                  #        ERADM= ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
048971,000282: 
048972,000283: 13,2560           71220        SETRE              STQ      DLOAD                                 
048973,000284: 13,2561           00051                                    SETREX                                
048974,000285: 13,2562           10003                                    504RM                                 
048975,000286: 13,2563           71214                           BON      DLOAD                                 #  BRANCH FOR MOON
048976,000287: 13,2564           01703                                    LUNAFLAG                              
048977,000288: 13,2565           26575                                    TSTRLSRM                              
048978,000289: 13,2566           10001                                    ERAD                                  
048979,000290: 13,2567           45014                           BOFF     CALL                                  #  ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
048980,000291: 13,2570           00742                                    ERADFLAG                              
048981,000292: 13,2571           26573                                    SETRXX                                
048982,000293: 13,2572           26466                                    GETERAD                               
048983,000294: 13,2573           37671        SETRXX             STCALL   ERADM                                 #  EXIT WITH RE OR RM METERS B-29
048984,000295: 13,2574           00051                                    SETREX                                
048985,000296: 13,2575           77214        TSTRLSRM           BON      VLOAD                                 #  ERADFLAG=0, SET R0=RLS
048986,000297: 13,2576           00702                                    ERADFLAG                              #          =1      R0=RM
048987,000298: 13,2577           26573                                    SETRXX                                
048988,000299: 13,2600           02023                                    RLS                                   
048989,000300: 13,2601           64446                           ABVAL    SR2R                                  #  SCALE FROM B-27 TO B-29
048990,000301: 13,2602           77650                           GOTO                                           
048991,000302: 13,2603           26573                                    SETRXX                                
048992,000303: 13,2604  0000051               SETREX             =        S2                                    
048993,000304: 
048994,000305: 

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