Source Code

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

The reconstruction began with source code of Zerlina 56, Luminary 210, and Luminary 131, previously transcribed from digitized copies of those programs. The code was created by combining the three, using Zerlina 56 as a base, since it was based off of Luminary 183. The differences between the three were carefully merged using the Luminary memos as a guide, with all changes made after Luminary 178 being backed out. 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 178 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.

042360,000002:                                                                                                  ## Copyright:   Public domain.
042361,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
042362,000004:                                                                                                  ## Purpose:     A section of Luminary revision 178.
042363,000005:                                                                                                  ##              It is part of the reconstructed source code for the final
042364,000006:                                                                                                  ##              release of the flight software for the Lunar Module's
042365,000007:                                                                                                  ##              (LM) Apollo Guidance Computer (AGC) for Apollo 14. The
042366,000008:                                                                                                  ##              code has been recreated from copies of Zerlina 56, Luminary
042367,000009:                                                                                                  ##              210, and Luminary 131, as well as many Luminary memos.
042368,000010:                                                                                                  ##              It has been adapted such that the resulting bugger words
042369,000011:                                                                                                  ##              exactly match those specified for Luminary 178 in NASA
042370,000012:                                                                                                  ##              drawing 2021152N, which gives relatively high confidence
042371,000013:                                                                                                  ##              that the reconstruction is correct.
042372,000014:                                                                                                  ## Reference:   pp. 975-978
042373,000015:                                                                                                  ## Assembler:   yaYUL
042374,000016:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
042375,000017:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
042376,000018:                                                                                                  ## Mod history: 2019-08-14 MAS  Created from Zerlina 56.
042377,000019: 

Page 975

042379,000021:                                                                                                  #  NAME - LSPOS  - LOCATE SUN AND MOON                                                      DATE - 25 OCT 67
042380,000022:                                                                                                  #  MOD NO.1
042381,000023:                                                                                                  #  MOD BY NEVILLE                                                                           ASSEMBLY SUNDANCE
042382,000024: 
042383,000025:                                                                                                  #  FUNCTIONAL DESCRIPTION
042384,000026: 
042385,000027:                                                                                                  #         COMPUTES UNIT POSITION VECTOR OF THE SUN AND MOON IN THE BASIC REFERENCE SYSTEM. THE SUN VECTOR S IS
042386,000028:                                                                                                  #  LOCATED VIA TWO ANGLES. THE FIRST ANGLE(OBLIQUITY) IS THE ANGLE BETWEEN THE EARTH EQUATOR AND THE ECLIPTIC. THE
042387,000029:                                                                                                  #  SECOND ANGLE IS THE LONGITUDE OF THE SUN MEASURED IN THE ECLIPTIC.
042388,000030:                                                                                                  #  THE POSITION VECTOR OF THE SUN IS
042389,000031:                                                                                                  #         -
042390,000032:                                                                                                  #         S=(COS(LOS), COS(OBL)*SIN(LOS), SIN(OBL)*SIN(LOS)), WHERE
042391,000033: 
042392,000034:                                                                                                  #       LOS=LOS +LOS *T-(C *SIN(2PI*T)/365.24 +C *COS(2PI*T)/365.24)
042393,000035:                                                                                                  #              0    R     0                     1
042394,000036:                                                                                                  #       LOS  (RAD) IS THE LONGITUDE OF THE SUN FOR MIDNIGHT JUNE 30TH OF THE PARTICULAR YEAR.
042395,000037:                                                                                                  #          0
042396,000038:                                                                                                  #       LOS  (RAD/DAY) IS THE MEAN RATE FOR THE PARTICULAR YEAR.
042397,000039:                                                                                                  #          R
042398,000040:                                                                                                  #  LOS  AND LOS  ARE STORED AS LOSC AND LOSR IN RATESP.
042399,000041:                                                                                                  #     0        R
042400,000042:                                                                                                  #  COS(OBL) AND SIN(OBL) ARE STORED IN THE MATRIX KONMAT.
042401,000043:                                                                                                  #  T, TIME MEASURED IN DAYS(24 HOURS), IS STORED IN TIMEP.
042402,000044:                                                                                                  #  C  AND C  ARE FUDGE FACTORS TO MINIMIZE THE DEVIATION. THEY ARE STORED AS ONE CONSTANT(CMOD), SINCE
042403,000045:                                                                                                  #   0      1                               2  2 1/2
042404,000046:                                                                                                  #  C *SIN(X)+C *COS(X) CAN BE WRITTEN AS (C +C )   *SIN(X+PHI), WHERE PHI=ARCTAN(C /C ).
042405,000047:                                                                                                  #   0         1                            0  1                                   1  0
042406,000048: 
042407,000049:                                                                                                  #  THE MOON IS LOCATED VIA FOUR ANGLES. THE FIRST IS THE OBLIQUITY. THE SECOND IS THE MEAN LONGITUDE OF THE MOON,
042408,000050:                                                                                                  #  MEASURED IN THE ECLIPTIC FROM THE MEAN EQUINOX TO THE MEAN ASCENDING NODE OF THE LUNAR ORBIT, AND THEN ALONG THE
042409,000051:                                                                                                  #  ORBIT. THE THIRD ANGLE IS THE ANGLE BETWEEN THE ECLIPTIC AND THE LUNAR ORBIT. THE FOURTH ANGLE IS THE LONGITUDE
042410,000052:                                                                                                  #  OF THE NODE OF THE MOON, MEASURED IN THE LUNAR ORBIT. LET THESE ANGLES BE OBL,LOM,IM, AND LON RESPECTIVELY.
042411,000053: 
042412,000054:                                                                                                  #  THE SIMPLIFIED POSITION VECTOR OF THE MOON IS
042413,000055:                                                                                                  #    -
042414,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))
042415,000057: 
042416,000058:                                                                                                  #    WHERE
042417,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
042418,000060:                                                                                                  #              0    R     0                    1                     0               1
042419,000061:                                                                                                  #        LON=LON +LON
042420,000062:                                                                                                  #               0    R
042421,000063:                                                                                                  #  A , A , B  AND B  ARE STORED AS AMOD AND BMOD (SEE DESCRIPTION OF CMOD, ABOVE).  COS(OBL), SIN(OBL)*SIN(IM),
042422,000064:                                                                                                  #   0   1   0      1
042423,000065:                                                                                                  #  SIN(OBL), AND COS(OBL)*SIN(IM) ARE STORED IN KONMAT AS K1, K2, K3 AND K4, RESPECTIVELY. LOM , LOM , LON , LON
042424,000066:                                                                                                  #  ARE STORED AS LOMO, LOMR, LONO, AND LONR IN RATESP.                                        0     R     0     R
042425,000067:                                                                                                  #  THE THREE PHIS ARE STORED AS AARG, BARG, AND CARG(SUN).  ALL CONSTANTS ARE UPDATED BY YEAR.
042426,000068: 
042427,000069:                                                                                                  #  CALLING SEQUENCE

Page 976

042429,000071:                                                                                                  #    CALL LSPOS.  RETURN IS VIA CPRET.
042430,000072: 
042431,000073:                                                                                                  #  ALARMS OR ABORTS
042432,000074: 
042433,000075:                                                                                                  #    NONE
042434,000076: 
042435,000077:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED
042436,000078: 
042437,000079:                                                                                                  #    TEPHEM - TIME FROM MIDNIGHT 1 JULY PRECEDING THE LAUNCH TO THE TIME OF THE LAUNCH (WHEN THE AGC CLOCK WENT
042438,000080:                                                                                                  #  TO ZERO). TEPHEM IS TP WITH UNITS OF CENTI-SECONDS.
042439,000081:                                                                                                  #    TIME2 AND TIME1 ARE IN MPAC AND MPAC +1 WHEN PROGRAM IS CALLED.
042440,000082: 
042441,000083:                                                                                                  #  OUTPUT
042442,000084: 
042443,000085:                                                                                                  #    UNIT POSITIONAL VECTOR OF SUN IN VSUN.   (SCALED B-1)
042444,000086:                                                                                                  #    UNIT POSITIONAL VECTOR OF MOON IN VMOON. (SCALED B-1)
042445,000087: 
042446,000088:                                                                                                  #  SUBROUTINES USED
042447,000089: 
042448,000090:                                                                                                  #    NONE
042449,000091: 
042450,000092:                                                                                                  #  DEBRIS
042451,000093: 
042452,000094:                                                                                                  #    CURRENT CORE SET,WORK AREA AND FREEFLAG
042453,000095: 04,3001                                           BANK     04                                    
042454,000096: 15,2000                                           SETLOC   EPHEM                                 
042455,000097: 15,2000                                           BANK                                           
042456,000098: 
042457,000099: 15,3660  E5,1714                                  EBANK=   VSUN                                  
042458,000100: 15,3660                                           COUNT*   $$/EPHEM                              
042459,000101: 15,3660  15,3660               LUNPOS             EQUALS   LSPOS                                 
042460,000102: 
042461,000103: 15,3660           54201        LSPOS              SETPD    SR                                    
042462,000104: 15,3661           00001                                    0                                     
042463,000105: 15,3662           20617                                    14D                                   #  TP
042464,000106: 15,3663           56371                           TAD      DDV                                   
042465,000107: 15,3664           01707                                    TEPHEM                                #  TIME OF LAUNCH
042466,000108: 15,3665           12024                                    CSTODAY                               #  24 HOURS-8640000 CENTI-SECS/DAY B-33
042467,000109: 15,3666           00031                           STORE    TIMEP                                 #  T IN DAYS
042468,000110: 15,3667           77170                           AXT,1    AXT,2                                 
042469,000111: 15,3670           00000                                    0                                     
042470,000112: 15,3671           00000                                    0                                     
042471,000113: 15,3672           77614                           CLEAR                                          
042472,000114: 15,3673           00274                                    FREEFLAG                              #  SWITCH BIT
042473,000115: 15,3674           77745        POSITA             DLOAD                                          
042474,000116: 15,3675           12004                                    KONMAT     +2                         #  ZEROS
042475,000117: 15,3676           00027                           STORE    GTMP                                  
042476,000118: 15,3677           40745        POSITB             DLOAD    DMP*                                  
042477,000119: 15,3700           00031                                    TIMEP                                 #  T
042478,000120: 15,3701           12050                                    VAL67      +4,1                       #  1/27 OR 1/32 OR 1/365

Page 977

042480,000122: 15,3702           42661                           SL       DAD*                                  
042481,000123: 15,3703           20211                                    8D                                    
042482,000124: 15,3704           12046                                    VAL67      +2,1                       #  AARG
042483,000125: 15,3705           40756                           SIN      DMP*                                  #  SIN(T/27+PHI) OR T/32 OR T/365
042484,000126: 15,3706           12044                                    VAL67,1                               #  (A0**2+A1**2)**1/2SIN(X+PHIA)
042485,000127: 15,3707           62015                           DAD      INCR,1                                #  PLUS
042486,000128: 15,3710           00027                                    GTMP                                  #  (B0**2+B1**2)**1/2SIN(X+PHIB)
042487,000129: 15,3711           77771                           DEC      -6         B-14                       
042488,000130: 15,3712           00027                           STORE    GTMP                                  #  OR (C0**2+C1**2)**1/2SIN(X+PHIC)
042489,000131: 15,3713           77614                           BOFSET                                         
042490,000132: 15,3714           00054                                    FREEFLAG                              
042491,000133: 15,3715           33677                                    POSITB                                
042492,000134: 15,3716           40745        POSITD             DLOAD    DMP*                                  
042493,000135: 15,3717           00031                                    TIMEP                                 #  T
042494,000136: 15,3720           65747                                    RATESP,2                              #  LOMR,LOSR,LONR
042495,000137: 15,3721           42661                           SL       DAD*                                  
042496,000138: 15,3722           20206                                    5D                                    
042497,000139: 15,3723           65741                                    RATESP     +6,2                       #  LOMO,LOSO,LONO
042498,000140: 15,3724           77625                           DSU                                            
042499,000141: 15,3725           00027                                    GTMP                                  
042500,000142: 15,3726           10021                           STORE    STMP,2                                #  LOM,LOS,LON
042501,000143: 15,3727           63135                           SLOAD    INCR,2                                
042502,000144: 15,3730           00050                                    X2                                    
042503,000145: 15,3731           77775                           DEC      -2         B-14                       
042504,000146: 15,3732           53015                           DAD      BZE                                   
042505,000147: 15,3733           12026                                    RCB-13                                #  PLUS 2
042506,000148: 15,3734           33764                                    POSITE                                #  2ND
042507,000149: 15,3735           77644                           BPL                                            
042508,000150: 15,3736           33674                                    POSITA                                #  1ST
042509,000151: 15,3737           45345        POSITF             DLOAD    DSU                                   #  3RD
042510,000152: 15,3740           00021                                    STMP                                  #  LOM
042511,000153: 15,3741           00025                                    STMP       +4                         #  LON
042512,000154: 15,3742           65356                           SIN      PDDL                                  #  SIN(LOM-LON)
042513,000155: 15,3743           00021                                    STMP                                  
042514,000156: 15,3744           65356                           SIN      PDDL                                  #  SIN LOM
042515,000157: 15,3745           00021                                    STMP                                  
042516,000158: 15,3746           55546                           COS      VDEF                                  #  COS LOM
042517,000159: 15,3747           53521                           MXV      UNIT                                  
042518,000160: 15,3750           12002                                    KONMAT                                #  K1,K2,K3,K4,
042519,000161: 15,3751           02723                           STORE    VMOON                                 
042520,000162: 15,3752           65345                           DLOAD    PDDL                                  
042521,000163: 15,3753           12004                                    KONMAT     +2                         #  ZERO
042522,000164: 15,3754           00023                                    STMP       +2                         
042523,000165: 15,3755           65356                           SIN      PDDL                                  #  SIN LOS
042524,000166: 15,3756           00023                                    STMP       +2                         
042525,000167: 15,3757           55546                           COS      VDEF                                  #  COS LOS
042526,000168: 15,3760           53521                           MXV      UNIT                                  
042527,000169: 15,3761           12002                                    KONMAT                                
042528,000170: 15,3762           02715                           STORE    VSUN                                  
042529,000171: 15,3763           77616                           RVQ                                            
042530,000172: 

Page 978

042532,000174: 15,3764           77745        POSITE             DLOAD                                          
042533,000175: 15,3765           12004                                    KONMAT     +2                         #  ZEROS
042534,000176: 15,3766           00027                           STORE    GTMP                                  
042535,000177: 15,3767           77650                           GOTO                                           
042536,000178: 15,3770           33716                                    POSITD                                
042537,000179: 05,2000                                           SETLOC   EPHEM1                                
042538,000180: 05,2000                                           BANK                                           
042539,000181: 
042540,000182: 05,3510                                           COUNT*   $$/EPHEM                              
042541,000183: 
042542,000184: 05,3510                        STMP               EQUALS   16D                                   
042543,000185: 
042544,000186: 05,3510                        GTMP               EQUALS   22D                                   
042545,000187: 
042546,000188: 05,3510                        TIMEP              EQUALS   24D                                   

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