Source Code

These source-code files are part of a reconstructed copy of Artemis 071, the first release of the Apollo 15 through 17 Command Module (CM) Apollo Guidance Computer (AGC) software.

The reconstruction began with source code of Artemis 072 previously transcribed from a digitized copy of that program. The code was then updated by undoing changes between the two versions. The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021154-. Note that page numbers in the reconstructed code match those on the Artemis 072 printout, although the changed code would likely have changed page numbers for a real Artemis 071 listing.

Comments from the original source code are prefixed with a single '#' symbol, whereas comments added later are prefixed by "##" or "###". Report any errors noted by creating an issue report at the Virtual AGC project's GitHub repository.

052760,000002:                                                                                                  ## Copyright:   Public domain.
052761,000003:                                                                                                  ## Filename:    LATITUDE_LONGITUDE_SUBROUTINES.agc
052762,000004:                                                                                                  ## Purpose:     A section of Artemis revision 071.
052763,000005:                                                                                                  ##              It is part of the reconstructed source code for the first
052764,000006:                                                                                                  ##              release of the flight software for the Command Module's
052765,000007:                                                                                                  ##              (CM) Apollo Guidance Computer (AGC) for Apollo 15 through
052766,000008:                                                                                                  ##              17. The code has been recreated from a copy of Artemis 072.
052767,000009:                                                                                                  ##              It has been adapted such that the resulting bugger words
052768,000010:                                                                                                  ##              exactly match those specified for Artemis 071 in NASA
052769,000011:                                                                                                  ##              drawing 2021154-, which gives relatively high confidence
052770,000012:                                                                                                  ##              that the reconstruction is correct.
052771,000013:                                                                                                  ## Reference:   1236
052772,000014:                                                                                                  ## Assembler:   yaYUL
052773,000015:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
052774,000016:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
052775,000017:                                                                                                  ## Mod history: 2019-08-14 MAS  Created from Artemis 072.
052776,000018: 

Page 1236

052778,000020:                                                                                                  #  SUBROUTINE TO CONVERT RAD VECTOR AT GIVEN TIME TO LAT,LONG AND ALT
052779,000021: 
052780,000022:                                                                                                  #  CALLING SEQUENCE
052781,000023: 
052782,000024:                                                                                                  #        L-1     CALL
052783,000025:                                                                                                  #        L               LAT-LONG
052784,000026: 
052785,000027:                                                                                                  #  SUBROUTINES USED
052786,000028: 
052787,000029:                                                                                                  #        R-TO-RP, ARCTAN, SETGAMMA, SETRE
052788,000030: 
052789,000031:                                                                                                  #  ERASABLE INIT. REQ.
052790,000032: 
052791,000033:                                                                                                  #        AXO, -AYO, AZO, TEPHEM (SET AT LAUNCH TIME)
052792,000034:                                                                                                  #        ALPHAV = POSITION VECTOR METERS B-29
052793,000035:                                                                                                  #        MPAC -- TIME (CSECS B-28)
052794,000036:                                                                                                  #        ERADFLAG =1, TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
052795,000037:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
052796,000038: 
052797,000039:                                                                                                  #  OUTPUT
052798,000040: 
052799,000041:                                                                                                  #        LATITUDE IN LAT         (REVS. B-0)
052800,000042:                                                                                                  #        LONGITUDE IN LONG       (REVS. B-0)
052801,000043:                                                                                                  #        ALTITUDE IN ALT METERS B-29
052802,000044: 
052803,000045: 13,2000                                           SETLOC   LATLONG                               
052804,000046: 13,2000                                           BANK                                           
052805,000047: 
052806,000048: 13,2453                                           COUNT*   $$/LT-LG                              
052807,000049: 13,2453  E4,1551                                  EBANK=   ALPHAV                                
052808,000050: 13,2453           40220        LAT-LONG           STQ      SETPD                                 
052809,000051: 13,2454           02241                                    INCORPEX                              
052810,000052: 13,2455           00001                                    0D                                    
052811,000053: 13,2456           24007                           STOVL    6D                                    #  SAVE TIME IN 6-7D FOR R-TO-RP
052812,000054: 13,2457           02152                                    ALPHAV                                
052813,000055: 13,2460           51406                           PUSH     ABVAL                                 #  0-5D= R FOR R-TO-RP
052814,000056: 13,2461           16301                           STODL    ALPHAM                                #  ABS. VALUE OF R FOR ALT FORMULA BELOW
052815,000057: 13,2462           11762                                    ZEROVEC                               #  SET MPAC=0 FOR EARTH, NON-ZERO FOR MOON
052816,000058: 13,2463           71414                           BOFF     COS                                   #  USE COS(0) TO GET NON-ZERO IN MPAC
052817,000059: 13,2464           01743                                    LUNAFLAG                              #  0=EARTH,1=MOON
052818,000060: 13,2465           26466                                    CALLRTRP                              
052819,000061: 13,2466           77624        CALLRTRP           CALL                                           
052820,000062: 13,2467           55370                                    R-TO-RP                               #  RP VECTOR CONVERTED FROM R B-29
052821,000063: 13,2470           77656                           UNIT                                           #  UNIT RP B-1
052822,000064: 13,2471           36152                           STCALL   ALPHAV                                #  U2= 1/2 SINL FOR SETRE SUBR BELOW
052823,000065: 13,2472           35766                                    SETGAMMA                              #   SET GAMMA=B2/A2 FOR EARTH, =1 FOR MOON
052824,000066: 13,2473           77624                           CALL                                           #   SCALED B-1
052825,000067: 13,2474           26654                                    SETRE                                 #  CALC RE METERS B-29
052826,000068: 13,2475           63545                           DLOAD    DSQ                                   
052827,000069: 13,2476           02152                                    ALPHAV                                
052828,000070: 13,2477           63525                           PDDL     DSQ                                   
052829,000071: 13,2500           02154                                    ALPHAV     +2                         
052830,000072: 13,2501           75415                           DAD      SQRT                                  
052831,000073: 13,2502           76405                           DMP      SL1R                                  

Page 1237

052833,000075: 13,2503           00011                                    GAMRP                                 
052834,000076: 13,2504           14021                           STODL    COSTH                                 #  COS(LAT) B-1
052835,000077: 13,2505           02156                                    ALPHAV     +4                         
052836,000078: 13,2506           34023                           STCALL   SINTH                                 #  SIN(LAT) B-1
052837,000079: 13,2507           26614                                    ARCTAN                                
052838,000080: 13,2510           14747                           STODL    LAT                                   #  LAT B0
052839,000081: 13,2511           02152                                    ALPHAV                                
052840,000082: 13,2512           14021                           STODL    COSTH                                 #  COS(LONG) B-1
052841,000083: 13,2513           02154                                    ALPHAV     +2                         
052842,000084: 13,2514           34023                           STCALL   SINTH                                 #  SIN(LONG) B-1
052843,000085: 13,2515           26614                                    ARCTAN                                
052844,000086: 13,2516           14751                           STODL    LONG                                  #  LONG. REVS B-0 IN RANGE -1/2 TO 1/2
052845,000087: 13,2517           02301                                    ALPHAM                                
052846,000088: 13,2520           77625                           DSU                                            #  ALT= R-RE METERS B-29
052847,000089: 13,2521           02240                                    ERADM                                 
052848,000090: 13,2522           34753                           STCALL   ALT                                   #  EXIT WITH ALT METERS B-29
052849,000091: 13,2523           02241                                    INCORPEX                              
052850,000092: 

Page 1238

052852,000094:                                                                                                  #  SUBROUTINE TO CONVERT LAT,LONG,ALT AT GIVEN TIME TO RADIUS VECTOR
052853,000095: 
052854,000096:                                                                                                  #  CALLING SEQUENCE
052855,000097: 
052856,000098:                                                                                                  #        L-1     CALL
052857,000099:                                                                                                  #        L               LALOTORV
052858,000100: 
052859,000101:                                                                                                  #  SUBROUTINES USED
052860,000102: 
052861,000103:                                                                                                  #        SETGAMMA, SETRE, RP-TO-R
052862,000104: 
052863,000105:                                                                                                  #  ERASABLE INIT. REQ.
052864,000106: 
052865,000107:                                                                                                  #        AXO, AYO, AZO, TEPHEM  SET AT LAUNCH TIME
052866,000108:                                                                                                  #        LAT -- LATITUDE         (REVS B0)
052867,000109:                                                                                                  #        LONG -- LONGITUDE       (REVS B0)
052868,000110:                                                                                                  #        ALT -- ALTITUDE         (METERS) B-29
052869,000111:                                                                                                  #        MPAC -- TIME            (CSECS B-28)
052870,000112:                                                                                                  #        ERADFLAG =1 TO COMPUTE EARTH RADIUS, =0 FOR FIXED EARTH RADIUS
052871,000113:                                                                                                  #        LUNAFLAG=0 FOR EARTH, 1 FOR MOON
052872,000114: 
052873,000115:                                                                                                  #  OUTPUT
052874,000116: 
052875,000117:                                                                                                  #        R-VECTOR IN ALPHAV (METERS B-29)
052876,000118: 
052877,000119: 13,2524           40220        LALOTORV           STQ      SETPD                                 #  LAT,LONG,ALT TO R VECTOR
052878,000120: 13,2525           02241                                    INCORPEX                              
052879,000121: 13,2526           00001                                    0D                                    
052880,000122: 13,2527           34007                           STCALL   6D                                    #  6-7D = TIME FOR RP-TO-R
052881,000123: 13,2530           35766                                    SETGAMMA                              #  GAMMA = B2/A2 FOR EARTH, 1 FOR MOON B-1
052882,000124: 13,2531           73545                           DLOAD    SIN                                   #                   COS(LONG)COS(LAT) IN MPAC
052883,000125: 13,2532           00747                                    LAT                                   #        UNIT  RP = SIN(LONG)COS(LAT)    2-3D
052884,000126: 13,2533           65275                           DMPR     PDDL                                  #  PD 2             GAMMA*SIN(LAT)       0-1D
052885,000127: 13,2534           00011                                    GAMRP                                 
052886,000128: 13,2535           00747                                    LAT                                   #            0-1D = GAMMA*SIN(LAT) B-2
052887,000129: 13,2536           65346                           COS      PDDL                                  #  PD4       2-3D = COS(LAT) B-1 TEMPORARILY
052888,000130: 13,2537           00751                                    LONG                                  
052889,000131: 13,2540           57356                           SIN      DMPR                                  #  PD 2
052890,000132: 13,2541           71525                           PDDL     COS                                   #  PD 4      2-3D = SIN(LONG)COS(LAT) B-2
052891,000133: 13,2542           00747                                    LAT                                   
052892,000134: 13,2543           71525                           PDDL     COS                                   #  PD 6      4-5D = COS(LAT) B-1 TEMPORARILY
052893,000135: 13,2544           00751                                    LONG                                  
052894,000136: 13,2545           55475                           DMPR     VDEF                                  #  PD4       MPAC = COS(LONG)COS(LAT) B-2
052895,000137: 13,2546           41456                           UNIT     PUSH                                  #  0-5D = UNIT RP FOR RP-TO-R SUBR.
052896,000138: 13,2547           36152                           STCALL   ALPHAV                                #  ALPHAV +4= SINL FOR SETRE SUBR.
052897,000139: 13,2550           26654                                    SETRE                                 #  RE METERS B-29
052898,000140: 13,2551           43145                           DLOAD    BOFF                                  #  SET MPAC = 0 FOR EARTH, NON-ZERO FOR MOON
052899,000141: 13,2552           11762                                    ZEROVEC                               
052900,000142: 13,2553           01743                                    LUNAFLAG                              
052901,000143: 13,2554           26556                                    CALLRPRT                              
052902,000144: 13,2555           77746                           COS                                            #  USE COS(0) TO GET NON-ZERO IN MPAC
052903,000145: 13,2556           77624        CALLRPRT           CALL                                           
052904,000146: 13,2557           55345                                    RP-TO-R                               #  EXIT WITH UNIT R VECTOR IN MPAC
052905,000147: 13,2560           16152                           STODL    ALPHAV                                
052906,000148: 13,2561           02240                                    ERADM                                 

Page 1239

052908,000150: 13,2562           74215                           DAD      VXSC                                  #  (RE + ALT)(UNIT R) METERS B-30
052909,000151: 13,2563           00753                                    ALT                                   
052910,000152: 13,2564           02152                                    ALPHAV                                
052911,000153: 13,2565           77772                           VSL1                                           #  R METERS B-29
052912,000154: 13,2566           36152                           STCALL   ALPHAV                                #  EXIT WITH R IN METERS B-29
052913,000155: 13,2567           02241                                    INCORPEX                              
052914,000156: 
052915,000157:                                                                                                  #  SUBROUTINE TO COMPUTE EARTH RADIUS
052916,000158: 
052917,000159:                                                                                                  #  INPUT
052918,000160: 
052919,000161:                                                                                                  #        1/2 SIN LAT IN ALPHAV +4
052920,000162: 
052921,000163:                                                                                                  #  OUTPUT
052922,000164: 
052923,000165:                                                                                                  #        EARTH RADIUS IN ERADM AND MPAC  (METERS B-29)
052924,000166: 
052925,000167: 13,2570           63545        GETERAD            DLOAD    DSQ                                   
052926,000168: 13,2571           02156                                    ALPHAV     +4                         #  SIN**2(L)
052927,000169: 13,2572           44352                           SL1      BDSU                                  
052928,000170: 13,2573           11760                                    DP1/2                                 #  COS**2(L)
052929,000171: 13,2574           44275                           DMPR     BDSU                                  
052930,000172: 13,2575           26611                                    EE                                    
052931,000173: 13,2576           11760                                    DP1/2                                 
052932,000174: 13,2577           75465                           BDDV     SQRT                                  
052933,000175: 13,2600           26605                                    B2XSC                                 
052934,000176: 13,2601           77622                           SR4R                                           
052935,000177: 13,2602           02240                           STORE    ERADM                                 
052936,000178: 13,2603           77616                           RVQ                                            
052937,000179: 
052938,000180:                                                                                                  #  THE FOLLOWING CONSTANTS WERE COMPUTED WITH A=6378166, B=6356784 METERS
052939,000181:                                                                                                  #  B2XSC = B**2 SCALED B-51
052940,000182:                                                                                                  #  B2/A2 = B**2/A**2  SCALED B-1
052941,000183:                                                                                                  #  EE = (1-B**2/A**2) SCALED B-0
052942,000184: 
052943,000185: 13,2604           00446 00305  B2XSC              2DEC     .0179450689                            #  B**2 SCALED B-51
052944,000186: 13,2606  04,3757               DP1/2              =        XUNIT                                 
052945,000187: 13,2606           17711 05254  B2/A2              2DEC     .9933064884 B-1                        #  GAMMA= B**2/A**2 B-1
052946,000188: 13,2610           00155 25250  EE                 2DEC     6.6935116  E-3                        #  (1-B**2/A**2) B-0
052947,000189: 13,2612           00302 17755  ERAD               2DEC     6373338    B-29                       #  PAD RADIUS
052948,000190: 

Page 1240

052950,000192:                                                                                                  #  ARCTAN SUBROUTINE
052951,000193: 
052952,000194:                                                                                                  #  CALLING SEQUENCE
052953,000195: 
052954,000196:                                                                                                  #        SIN THETA IN SINTH B-1
052955,000197:                                                                                                  #        COS THETA IN COSTH B-1
052956,000198:                                                                                                  #        CALL ARCTAN
052957,000199: 
052958,000200:                                                                                                  #  OUTPUT
052959,000201:                                                                                                  #        ARCTAN THETA IN MPAC AND THETA B-0 IN RANGE -1/2 TO +1/2
052960,000202: 
052961,000203: 13,2614           77600        ARCTAN             BOV                                            
052962,000204: 13,2615           26616                                    CLROVFLW                              
052963,000205: 13,2616           63545        CLROVFLW           DLOAD    DSQ                                   
052964,000206: 13,2617           00023                                    SINTH                                 
052965,000207: 13,2620           63525                           PDDL     DSQ                                   
052966,000208: 13,2621           00021                                    COSTH                                 
052967,000209: 13,2622           77615                           DAD                                            
052968,000210: 13,2623           75454                           BZE      SQRT                                  
052969,000211: 13,2624           26642                                    ARCTANXX                              #  ATAN=0/0  SET THETA=0
052970,000212: 13,2625           40065                           BDDV     BOV                                   
052971,000213: 13,2626           00023                                    SINTH                                 
052972,000214: 13,2627           26647                                    ATAN=90                               
052973,000215: 13,2630           67542                           SR1      ASIN                                  
052974,000216: 13,2631           00025                           STORE    THETA                                 
052975,000217: 13,2632           50125                           PDDL     BMN                                   
052976,000218: 13,2633           00021                                    COSTH                                 
052977,000219: 13,2634           26636                                    NEGCOS                                
052978,000220: 13,2635           43545                           DLOAD    RVQ                                   
052979,000221: 13,2636           57545        NEGCOS             DLOAD    DCOMP                                 
052980,000222: 13,2637           43244                           BPL      DAD                                   
052981,000223: 13,2640           26644                                    NEGOUT                                
052982,000224: 13,2641           11760                                    DP1/2                                 
052983,000225: 13,2642           00025        ARCTANXX           STORE    THETA                                 
052984,000226: 13,2643           77616                           RVQ                                            
052985,000227: 
052986,000228: 13,2644           52025        NEGOUT             DSU      GOTO                                  
052987,000229: 13,2645           11760                                    DP1/2                                 
052988,000230: 13,2646           26642                                    ARCTANXX                              
052989,000231: 13,2647           75345        ATAN=90            DLOAD    SIGN                                  
052990,000232: 13,2650           33412                                    LODP1/4                               
052991,000233: 13,2651           00023                                    SINTH                                 
052992,000234: 13,2652           00025                           STORE    THETA                                 
052993,000235: 13,2653           77616                           RVQ                                            
052994,000236: 
052995,000237: 13,2654  04,3761               2DZERO             =        DPZERO                                
052996,000238: 

Page 1241

052998,000240:                                                                                                  #  ..... SETGAMMA SUBROUTINE .....
052999,000241:                                                                                                  #  SUBROUTINE TO SET GAMMA FOR THE LAT-LONG AND LALOTORV SUBROUTINES
053000,000242: 
053001,000243:                                                                                                  #  GAMMA = B**2/A**2 FOR EARTH (B-1)
053002,000244:                                                                                                  #  GAMMA = 1 FOR MOON (B-1)
053003,000245: 
053004,000246:                                                                                                  #  CALLING SEQUENCE
053005,000247:                                                                                                  #        L       CALL
053006,000248:                                                                                                  #        L+1             SETGAMMA
053007,000249: 
053008,000250:                                                                                                  #  INPUT
053009,000251:                                                                                                  #        LUNAFLAG=0 FOR EARTH, =1 FOR MOON
053010,000252: 
053011,000253:                                                                                                  #  OUTPUT
053012,000254:                                                                                                  #        GAMMA IN GAMRP  (B-1)
053013,000255: 
053014,000256: 16,2000                                           SETLOC   LATLONG1                              
053015,000257: 16,2000                                           BANK                                           
053016,000258: 16,3766                                           COUNT*   $$/LT-LG                              
053017,000259: 
053018,000260: 16,3766           43145        SETGAMMA           DLOAD    BOFF                                  #  BRANCH FOR EARTH
053019,000261: 16,3767           26607                                    B2/A2                                 #  EARTH GAMMA
053020,000262: 16,3770           01743                                    LUNAFLAG                              
053021,000263: 16,3771           35774                                    SETGMEX                               
053022,000264: 16,3772           77735                           SLOAD                                          
053023,000265: 16,3773           11760                                    1B1                                   #  MOON GAMMA
053024,000266: 16,3774           00011        SETGMEX            STORE    GAMRP                                 
053025,000267: 16,3775           77616                           RVQ                                            
053026,000268: 16,3776                        GAMRP              =        8D                                    
053027,000269: 13,2000                                           SETLOC   LATLONG                               
053028,000270: 13,2000                                           BANK                                           
053029,000271: 

Page 1242

053031,000273:                                                                                                  #  ..... SETRE SUBROUTINE .....
053032,000274:                                                                                                  #  SUBROUTINE TO SET RE (EARTH OR MOON RADIUS)
053033,000275: 
053034,000276:                                                                                                  #   RE = RM FOR MOON
053035,000277:                                                                                                  #   RE = RREF FOR FIXED EARTH RADIUS OR COMPUTED RF FOR FISCHER ELLIPSOID
053036,000278: 
053037,000279:                                                                                                  #  CALLING SEQUENCE
053038,000280:                                                                                                  #   L    CALL
053039,000281:                                                                                                  #   L+1          SETRE
053040,000282: 
053041,000283:                                                                                                  #  SUBROUTINES USED
053042,000284:                                                                                                  #   GETERAD
053043,000285: 
053044,000286:                                                                                                  #  INPUT
053045,000287:                                                                                                  #   ERADFLAG = 0 FOR FIXED RE, 1 FOR COMPUTED RE
053046,000288:                                                                                                  #   ALPHAV +4 = 1/2 SINL IF GETERAD IS CALLED
053047,000289:                                                                                                  #   LUNAFLAG = 0 FOR EARTH, =1 FOR MOON
053048,000290: 
053049,000291:                                                                                                  #  OUTPUT
053050,000292:                                                                                                  #   ERADM = 504RM FOR MOON (METERS B-29)
053051,000293:                                                                                                  #   ERADM = ERAD OR COMPUTED RF FOR EARTH (METERS B-29)
053052,000294: 
053053,000295: 13,2654           71220        SETRE              STQ      DLOAD                                 
053054,000296: 13,2655           00051                                    SETREX                                
053055,000297: 13,2656           26701                                    504RM                                 
053056,000298: 13,2657           71214                           BON      DLOAD                                 #  BRANCH FOR MOON
053057,000299: 13,2660           01703                                    LUNAFLAG                              
053058,000300: 13,2661           26671                                    TSTRLSRM                              
053059,000301: 13,2662           26613                                    ERAD                                  
053060,000302: 13,2663           45014                           BOFF     CALL                                  #  ERADFLAG=0 FOR FIXED RE, 1 FOR COMPUTED
053061,000303: 13,2664           00742                                    ERADFLAG                              
053062,000304: 13,2665           26667                                    SETRXX                                
053063,000305: 13,2666           26570                                    GETERAD                               
053064,000306: 13,2667           36240        SETRXX             STCALL   ERADM                                 #  EXIT WITH RE OR RM METERS B-29
053065,000307: 13,2670           00051                                    SETREX                                
053066,000308: 13,2671           77214        TSTRLSRM           BON      VLOAD                                 #  ERADFLAG=0, SET R0=RLS
053067,000309: 13,2672           00702                                    ERADFLAG                              #          =1      R0=RM
053068,000310: 13,2673           26667                                    SETRXX                                
053069,000311: 13,2674           02026                                    RLS                                   
053070,000312: 13,2675           64446                           ABVAL    SR2R                                  #  SCALE FROM B-27 TO B-29
053071,000313: 13,2676           77650                           GOTO                                           
053072,000314: 13,2677           26667                                    SETRXX                                
053073,000315: 13,2700  0000051               SETREX             =        S2                                    
053074,000316: 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