Source Code

These source-code files are part of a reconstructed copy of Luminary 173, the second (unflown) release of the Apollo 14 Lunar Module (LM) Apollo Guidance Computer (AGC) software.

The reconstruction began with reconstructed source code for Luminary 178. Changes between revision 173 and 178 were backed out, as described by Luminary memo 167 (revision 1). The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021152N. Note that page numbers in the reconstructed code match those for the baseline log section mentioned in each file's changelog; the page numbers for a real Luminary 173 listing would be different.

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.

042269,000002:                                                                                                  ## Copyright:   Public domain.
042270,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
042271,000004:                                                                                                  ## Purpose:     A section of Luminary revision 173.
042272,000005:                                                                                                  ##              It is part of the reconstructed source code for the second
042273,000006:                                                                                                  ##              (unflown) release of the flight software for the Lunar
042274,000007:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 14.
042275,000008:                                                                                                  ##              The code has been recreated from a reconstructed copy of
042276,000009:                                                                                                  ##              Luminary 178, as well as Luminary memo 167 (revision 1).
042277,000010:                                                                                                  ##              It has been adapted such that the resulting bugger words
042278,000011:                                                                                                  ##              exactly match those specified for Luminary 173 in NASA
042279,000012:                                                                                                  ##              drawing 2021152N, which gives relatively high confidence
042280,000013:                                                                                                  ##              that the reconstruction is correct.
042281,000014:                                                                                                  ## Reference:   pp. 975-978
042282,000015:                                                                                                  ## Assembler:   yaYUL
042283,000016:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
042284,000017:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
042285,000018:                                                                                                  ## Mod history: 2019-09-18 MAS  Created from Luminary 178.
042286,000019: 

Page 975

042288,000021:                                                                                                  #  NAME - LSPOS  - LOCATE SUN AND MOON                                                      DATE - 25 OCT 67
042289,000022:                                                                                                  #  MOD NO.1
042290,000023:                                                                                                  #  MOD BY NEVILLE                                                                           ASSEMBLY SUNDANCE
042291,000024: 
042292,000025:                                                                                                  #  FUNCTIONAL DESCRIPTION
042293,000026: 
042294,000027:                                                                                                  #         COMPUTES UNIT POSITION VECTOR OF THE SUN AND MOON IN THE BASIC REFERENCE SYSTEM. THE SUN VECTOR S IS
042295,000028:                                                                                                  #  LOCATED VIA TWO ANGLES. THE FIRST ANGLE(OBLIQUITY) IS THE ANGLE BETWEEN THE EARTH EQUATOR AND THE ECLIPTIC. THE
042296,000029:                                                                                                  #  SECOND ANGLE IS THE LONGITUDE OF THE SUN MEASURED IN THE ECLIPTIC.
042297,000030:                                                                                                  #  THE POSITION VECTOR OF THE SUN IS
042298,000031:                                                                                                  #         -
042299,000032:                                                                                                  #         S=(COS(LOS), COS(OBL)*SIN(LOS), SIN(OBL)*SIN(LOS)), WHERE
042300,000033: 
042301,000034:                                                                                                  #       LOS=LOS +LOS *T-(C *SIN(2PI*T)/365.24 +C *COS(2PI*T)/365.24)
042302,000035:                                                                                                  #              0    R     0                     1
042303,000036:                                                                                                  #       LOS  (RAD) IS THE LONGITUDE OF THE SUN FOR MIDNIGHT JUNE 30TH OF THE PARTICULAR YEAR.
042304,000037:                                                                                                  #          0
042305,000038:                                                                                                  #       LOS  (RAD/DAY) IS THE MEAN RATE FOR THE PARTICULAR YEAR.
042306,000039:                                                                                                  #          R
042307,000040:                                                                                                  #  LOS  AND LOS  ARE STORED AS LOSC AND LOSR IN RATESP.
042308,000041:                                                                                                  #     0        R
042309,000042:                                                                                                  #  COS(OBL) AND SIN(OBL) ARE STORED IN THE MATRIX KONMAT.
042310,000043:                                                                                                  #  T, TIME MEASURED IN DAYS(24 HOURS), IS STORED IN TIMEP.
042311,000044:                                                                                                  #  C  AND C  ARE FUDGE FACTORS TO MINIMIZE THE DEVIATION. THEY ARE STORED AS ONE CONSTANT(CMOD), SINCE
042312,000045:                                                                                                  #   0      1                               2  2 1/2
042313,000046:                                                                                                  #  C *SIN(X)+C *COS(X) CAN BE WRITTEN AS (C +C )   *SIN(X+PHI), WHERE PHI=ARCTAN(C /C ).
042314,000047:                                                                                                  #   0         1                            0  1                                   1  0
042315,000048: 
042316,000049:                                                                                                  #  THE MOON IS LOCATED VIA FOUR ANGLES. THE FIRST IS THE OBLIQUITY. THE SECOND IS THE MEAN LONGITUDE OF THE MOON,
042317,000050:                                                                                                  #  MEASURED IN THE ECLIPTIC FROM THE MEAN EQUINOX TO THE MEAN ASCENDING NODE OF THE LUNAR ORBIT, AND THEN ALONG THE
042318,000051:                                                                                                  #  ORBIT. THE THIRD ANGLE IS THE ANGLE BETWEEN THE ECLIPTIC AND THE LUNAR ORBIT. THE FOURTH ANGLE IS THE LONGITUDE
042319,000052:                                                                                                  #  OF THE NODE OF THE MOON, MEASURED IN THE LUNAR ORBIT. LET THESE ANGLES BE OBL,LOM,IM, AND LON RESPECTIVELY.
042320,000053: 
042321,000054:                                                                                                  #  THE SIMPLIFIED POSITION VECTOR OF THE MOON IS
042322,000055:                                                                                                  #    -
042323,000056:                                                                                                  #    M=(COS(LOM), COS(OBL)*SIN(LOM)-SIN(OBL)*SIN(IM)*SIN(LOM-LON), SIN(OBL)*SIN(LOM)+COS(OBL)*SIN(IM)*SIN(LOM-LON))
042324,000057: 
042325,000058:                                                                                                  #    WHERE
042326,000059:                                                                                                  #       LOM=LOM +LOM *T-(A *SIN 2PI*T/27.5545+A *COS(2PI*T/27.5545)+B *SIN 2PI*T/32+B *COS(2PI*T/32)), AND
042327,000060:                                                                                                  #              0    R     0                    1                     0               1
042328,000061:                                                                                                  #        LON=LON +LON
042329,000062:                                                                                                  #               0    R
042330,000063:                                                                                                  #  A , A , B  AND B  ARE STORED AS AMOD AND BMOD (SEE DESCRIPTION OF CMOD, ABOVE).  COS(OBL), SIN(OBL)*SIN(IM),
042331,000064:                                                                                                  #   0   1   0      1
042332,000065:                                                                                                  #  SIN(OBL), AND COS(OBL)*SIN(IM) ARE STORED IN KONMAT AS K1, K2, K3 AND K4, RESPECTIVELY. LOM , LOM , LON , LON
042333,000066:                                                                                                  #  ARE STORED AS LOMO, LOMR, LONO, AND LONR IN RATESP.                                        0     R     0     R
042334,000067:                                                                                                  #  THE THREE PHIS ARE STORED AS AARG, BARG, AND CARG(SUN).  ALL CONSTANTS ARE UPDATED BY YEAR.
042335,000068: 
042336,000069:                                                                                                  #  CALLING SEQUENCE

Page 976

042338,000071:                                                                                                  #    CALL LSPOS.  RETURN IS VIA CPRET.
042339,000072: 
042340,000073:                                                                                                  #  ALARMS OR ABORTS
042341,000074: 
042342,000075:                                                                                                  #    NONE
042343,000076: 
042344,000077:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED
042345,000078: 
042346,000079:                                                                                                  #    TEPHEM - TIME FROM MIDNIGHT 1 JULY PRECEDING THE LAUNCH TO THE TIME OF THE LAUNCH (WHEN THE AGC CLOCK WENT
042347,000080:                                                                                                  #  TO ZERO). TEPHEM IS TP WITH UNITS OF CENTI-SECONDS.
042348,000081:                                                                                                  #    TIME2 AND TIME1 ARE IN MPAC AND MPAC +1 WHEN PROGRAM IS CALLED.
042349,000082: 
042350,000083:                                                                                                  #  OUTPUT
042351,000084: 
042352,000085:                                                                                                  #    UNIT POSITIONAL VECTOR OF SUN IN VSUN.   (SCALED B-1)
042353,000086:                                                                                                  #    UNIT POSITIONAL VECTOR OF MOON IN VMOON. (SCALED B-1)
042354,000087: 
042355,000088:                                                                                                  #  SUBROUTINES USED
042356,000089: 
042357,000090:                                                                                                  #    NONE
042358,000091: 
042359,000092:                                                                                                  #  DEBRIS
042360,000093: 
042361,000094:                                                                                                  #    CURRENT CORE SET,WORK AREA AND FREEFLAG
042362,000095: 04,3001                                           BANK     04                                    
042363,000096: 15,2000                                           SETLOC   EPHEM                                 
042364,000097: 15,2000                                           BANK                                           
042365,000098: 
042366,000099: 15,3660  E5,1714                                  EBANK=   VSUN                                  
042367,000100: 15,3660                                           COUNT*   $$/EPHEM                              
042368,000101: 15,3660  15,3660               LUNPOS             EQUALS   LSPOS                                 
042369,000102: 
042370,000103: 15,3660           54201        LSPOS              SETPD    SR                                    
042371,000104: 15,3661           00001                                    0                                     
042372,000105: 15,3662           20617                                    14D                                   #  TP
042373,000106: 15,3663           56371                           TAD      DDV                                   
042374,000107: 15,3664           01707                                    TEPHEM                                #  TIME OF LAUNCH
042375,000108: 15,3665           12024                                    CSTODAY                               #  24 HOURS-8640000 CENTI-SECS/DAY B-33
042376,000109: 15,3666           00031                           STORE    TIMEP                                 #  T IN DAYS
042377,000110: 15,3667           77170                           AXT,1    AXT,2                                 
042378,000111: 15,3670           00000                                    0                                     
042379,000112: 15,3671           00000                                    0                                     
042380,000113: 15,3672           77614                           CLEAR                                          
042381,000114: 15,3673           00274                                    FREEFLAG                              #  SWITCH BIT
042382,000115: 15,3674           77745        POSITA             DLOAD                                          
042383,000116: 15,3675           12004                                    KONMAT     +2                         #  ZEROS
042384,000117: 15,3676           00027                           STORE    GTMP                                  
042385,000118: 15,3677           40745        POSITB             DLOAD    DMP*                                  
042386,000119: 15,3700           00031                                    TIMEP                                 #  T
042387,000120: 15,3701           12050                                    VAL67      +4,1                       #  1/27 OR 1/32 OR 1/365

Page 977

042389,000122: 15,3702           42661                           SL       DAD*                                  
042390,000123: 15,3703           20211                                    8D                                    
042391,000124: 15,3704           12046                                    VAL67      +2,1                       #  AARG
042392,000125: 15,3705           40756                           SIN      DMP*                                  #  SIN(T/27+PHI) OR T/32 OR T/365
042393,000126: 15,3706           12044                                    VAL67,1                               #  (A0**2+A1**2)**1/2SIN(X+PHIA)
042394,000127: 15,3707           62015                           DAD      INCR,1                                #  PLUS
042395,000128: 15,3710           00027                                    GTMP                                  #  (B0**2+B1**2)**1/2SIN(X+PHIB)
042396,000129: 15,3711           77771                           DEC      -6         B-14                       
042397,000130: 15,3712           00027                           STORE    GTMP                                  #  OR (C0**2+C1**2)**1/2SIN(X+PHIC)
042398,000131: 15,3713           77614                           BOFSET                                         
042399,000132: 15,3714           00054                                    FREEFLAG                              
042400,000133: 15,3715           33677                                    POSITB                                
042401,000134: 15,3716           40745        POSITD             DLOAD    DMP*                                  
042402,000135: 15,3717           00031                                    TIMEP                                 #  T
042403,000136: 15,3720           65747                                    RATESP,2                              #  LOMR,LOSR,LONR
042404,000137: 15,3721           42661                           SL       DAD*                                  
042405,000138: 15,3722           20206                                    5D                                    
042406,000139: 15,3723           65741                                    RATESP     +6,2                       #  LOMO,LOSO,LONO
042407,000140: 15,3724           77625                           DSU                                            
042408,000141: 15,3725           00027                                    GTMP                                  
042409,000142: 15,3726           10021                           STORE    STMP,2                                #  LOM,LOS,LON
042410,000143: 15,3727           63135                           SLOAD    INCR,2                                
042411,000144: 15,3730           00050                                    X2                                    
042412,000145: 15,3731           77775                           DEC      -2         B-14                       
042413,000146: 15,3732           53015                           DAD      BZE                                   
042414,000147: 15,3733           12026                                    RCB-13                                #  PLUS 2
042415,000148: 15,3734           33764                                    POSITE                                #  2ND
042416,000149: 15,3735           77644                           BPL                                            
042417,000150: 15,3736           33674                                    POSITA                                #  1ST
042418,000151: 15,3737           45345        POSITF             DLOAD    DSU                                   #  3RD
042419,000152: 15,3740           00021                                    STMP                                  #  LOM
042420,000153: 15,3741           00025                                    STMP       +4                         #  LON
042421,000154: 15,3742           65356                           SIN      PDDL                                  #  SIN(LOM-LON)
042422,000155: 15,3743           00021                                    STMP                                  
042423,000156: 15,3744           65356                           SIN      PDDL                                  #  SIN LOM
042424,000157: 15,3745           00021                                    STMP                                  
042425,000158: 15,3746           55546                           COS      VDEF                                  #  COS LOM
042426,000159: 15,3747           53521                           MXV      UNIT                                  
042427,000160: 15,3750           12002                                    KONMAT                                #  K1,K2,K3,K4,
042428,000161: 15,3751           02723                           STORE    VMOON                                 
042429,000162: 15,3752           65345                           DLOAD    PDDL                                  
042430,000163: 15,3753           12004                                    KONMAT     +2                         #  ZERO
042431,000164: 15,3754           00023                                    STMP       +2                         
042432,000165: 15,3755           65356                           SIN      PDDL                                  #  SIN LOS
042433,000166: 15,3756           00023                                    STMP       +2                         
042434,000167: 15,3757           55546                           COS      VDEF                                  #  COS LOS
042435,000168: 15,3760           53521                           MXV      UNIT                                  
042436,000169: 15,3761           12002                                    KONMAT                                
042437,000170: 15,3762           02715                           STORE    VSUN                                  
042438,000171: 15,3763           77616                           RVQ                                            
042439,000172: 

Page 978

042441,000174: 15,3764           77745        POSITE             DLOAD                                          
042442,000175: 15,3765           12004                                    KONMAT     +2                         #  ZEROS
042443,000176: 15,3766           00027                           STORE    GTMP                                  
042444,000177: 15,3767           77650                           GOTO                                           
042445,000178: 15,3770           33716                                    POSITD                                
042446,000179: 05,2000                                           SETLOC   EPHEM1                                
042447,000180: 05,2000                                           BANK                                           
042448,000181: 
042449,000182: 05,3510                                           COUNT*   $$/EPHEM                              
042450,000183: 
042451,000184: 05,3510                        STMP               EQUALS   16D                                   
042452,000185: 
042453,000186: 05,3510                        GTMP               EQUALS   22D                                   
042454,000187: 
042455,000188: 05,3510                        TIMEP              EQUALS   24D                                   

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