Source Code

These source-code files are part of a reconstructed copy of Luminary 97, the second release of the Apollo 11 Lunar Module (LM) Apollo Guidance Computer (AGC) software. It was created to fix two incorrect ephemeris constants in Luminary 96, as described by anomaly report LNY-59.

The reconstruction began with source code of Luminary 99 revision 1 previously transcribed from a digitized copy of that program. The code was then updated by undoing changes described in original Luminary memos 83 and 85, using asterisks indicating changed lines in the listing as a guide. The reconstruction was verified by matching memory-bank checksums to those listed in drawing 2021152D. Note that page numbers in the reconstructed code match those on the Luminary 099 revision 001 printout, although the added code would likely have changed page numbers for a real Luminary 97 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.

042179,000002:                                                                                                  ## Copyright:   Public domain.
042180,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
042181,000004:                                                                                                  ## Purpose:     A section of Luminary revision 97.
042182,000005:                                                                                                  ##              It is part of the reconstructed source code for the
042183,000006:                                                                                                  ##              second release of the flight software for the Lunar 
042184,000007:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 11.
042185,000008:                                                                                                  ##              It was created to fix two incorrect ephemeris constants in
042186,000009:                                                                                                  ##              Luminary 96, as described by anomaly report LNY-59.
042187,000010:                                                                                                  ##              The code has been recreated from a copy of Luminary 99
042188,000011:                                                                                                  ##              revision 001, using asterisks indicating changed lines in
042189,000012:                                                                                                  ##              the listing and Luminary Memos #83 and #85, which list 
042190,000013:                                                                                                  ##              changes between Luminary 97 and 98, and 98 and 99. The
042191,000014:                                                                                                  ##              code has been adapted such that the resulting bugger words
042192,000015:                                                                                                  ##              exactly match those specified for Luminary 97 in NASA drawing
042193,000016:                                                                                                  ##              2021152D, which gives relatively high confidence that the
042194,000017:                                                                                                  ##              reconstruction is correct.
042195,000018:                                                                                                  ## Reference:   pp. 984-987
042196,000019:                                                                                                  ## Assembler:   yaYUL
042197,000020:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
042198,000021:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
042199,000022:                                                                                                  ## Mod history: 2019-07-28 MAS  Created from Luminary 99.
042200,000023: 

Page 984

042202,000025:                                                                                                  #  NAME - LSPOS - LOCATE SUN AND MOON                    DATE - 25 OCT 67
042203,000026:                                                                                                  #  MOD NO. 1
042204,000027:                                                                                                  #  MOD BY NEVILLE                                        ASSEMBLY SUNDANCE
042205,000028: 
042206,000029:                                                                                                  #  FUNCTIONAL DESCRIPTION
042207,000030: 
042208,000031:                                                                                                  #         COMPUTES UNIT POSITION VECTOR OF THE SUN AND MOON IN THE BASIC REFERENCE SYSTEM. THE SUN VECTOR S IS
042209,000032:                                                                                                  #  LOCATED VIA TWO ANGLES. THE FIRST ANGLE(OBLIQUITY) IS THE ANGLE BETWEEN THE EARTH EQUATOR AND THE ECLIPTIC. THE
042210,000033:                                                                                                  #  SECOND ANGLE IS THE LONGITUDE OF THE SUN MEASURED IN THE ECLIPTIC.
042211,000034:                                                                                                  #  THE POSITION VECTOR OF THE SUN IS
042212,000035:                                                                                                  #        -
042213,000036:                                                                                                  #        S = (COS(LOS), COS(OBL)*SIN(LOS), SIN(OBL)*SIN(LOS)), WHERE
042214,000037: 
042215,000038:                                                                                                  #        LOS = LOS +LOS *T-(C *SIN(2PI*T)/365.24 +C *COS(2PI*T)/365.24)
042216,000039:                                                                                                  #                 0    R     0                     1
042217,000040:                                                                                                  #        LOS  (RAD) IS THE LONGITUDE OF THE SUN FOR MIDNIGHT JUNE 30TH OF THE PARTICULAR YEAR.
042218,000041:                                                                                                  #           0
042219,000042:                                                                                                  #        LOS  (RAD/DAY) IS THE MEAN RATE FOR THE PARTICULAR YEAR.
042220,000043:                                                                                                  #           R
042221,000044: 
042222,000045:                                                                                                  #  LOS  AND LOS  ARE STORED AS LOSC AND LOSR IN RATESP.
042223,000046:                                                                                                  #     0        R
042224,000047:                                                                                                  #  COS(OBL) AND SIN(OBL) ARE STORED IN THE MATRIX KONMAT.
042225,000048: 
042226,000049:                                                                                                  #  T, TIME MEASURED IN DAYS (24 HOURS), IS STORED IN TIMEP.
042227,000050: 
042228,000051:                                                                                                  #  C  AND C  ARE FUDGE FACTORS TO MINIMIZE THE DEVIATION.  THEY ARE STORED AS ONE CONSTANT (CMOD), SINCE
042229,000052:                                                                                                  #   0      1                               2  2 1/2
042230,000053:                                                                                                  #  C *SIN(X)+C *COS(X) CAN BE WRITTEN AS (C +C )   *SIN(X+PHI), WHERE PHI=ARCTAN(C /C ).
042231,000054:                                                                                                  #   0         1                            0  1                                   1  0
042232,000055: 
042233,000056:                                                                                                  #  THE MOON IS LOCATED VIA FOUR ANGLES. THE FIRST IS THE OBLIQUITY. THE SECOND IS THE MEAN LONGITUDE OF THE MOON,
042234,000057:                                                                                                  #  MEASURED IN THE ECLIPTIC FROM THE MEAN EQUINOX TO THE MEAN ASCENDING NODE OF THE LUNAR ORBIT, AND THEN ALONG THE
042235,000058:                                                                                                  #  ORBIT.  THE THIRD ANGLE IS THE ANGLE BETWEEN THE ECLIPTIC AND THE LUNAR ORBIT.  THE FOURTH ANGLE IS THE LONGITUDE
042236,000059:                                                                                                  #  OF THE NODE OF THE MOON, MEASURED IN THE LUNAR ORBIT.  LET THESE ANGLES BE OBL,LOM,IM, AND LON RESPECTIVELY.
042237,000060: 
042238,000061:                                                                                                  #  THE SIMPLIFIED POSITION VECTOR OF THE MOON IS
042239,000062:                                                                                                  #        -
042240,000063:                                                                                                  #        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))
042241,000064: 
042242,000065:                                                                                                  #  WHERE
042243,000066:                                                                                                  #        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
042244,000067:                                                                                                  #               0    R     0                    1                     0               1
042245,000068:                                                                                                  #        LON=LON +LON
042246,000069:                                                                                                  #               0    R
042247,000070:                                                                                                  #  A , A , B  AND B  ARE STORED AS AMOD AND BMOD (SEE DESCRIPTION OF CMOD, ABOVE).  COS(OBL), SIN(OBL)*SIN(IM),
042248,000071:                                                                                                  #   0   1   0      1
042249,000072:                                                                                                  #  SIN(OBL), AND COS(OBL)*SIN(IM) ARE STORED IN KONMAT AS K1, K2, K3 AND K4, RESPECTIVELY.  LOM , LOM , LON , LON                                   
042250,000073:                                                                                                  #  ARE STORED AS LOMO, LOMR, LONO, AND LONR IN RATESP.                                         0     R     0     R
042251,000074:                                                                                                  #  THE THREE PHIS ARE STORED AS AARG, BARG, AND CARG(SUN).  ALL CONSTANTS ARE UPDATED BY YEAR.
042252,000075: 
042253,000076:                                                                                                  #  CALLING SEQUENCE

Page 985

042255,000078:                                                                                                  #        CALL LSPOS.  RETURN IS VIA CPRET.
042256,000079: 
042257,000080:                                                                                                  #  ALARMS OR ABORTS
042258,000081:                                                                                                  #        NONE
042259,000082: 
042260,000083:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED
042261,000084:                                                                                                  #        TEPHEM - TIME FROM MIDNIGHT 1 JULY PRECEDING THE LAUNCH TO THE TIME OF THE LAUNCH (WHEN THE AGC CLOCK WENT
042262,000085:                                                                                                  #        TO ZERO).  TEPHEM IS TP WITH UNITS OF CENTI-SECONDS.
042263,000086: 
042264,000087:                                                                                                  #        TIME2 AND TIME1 ARE IN MPAC AND MPAC +1 WHEN PROGRAM IS CALLED.
042265,000088: 
042266,000089:                                                                                                  #  OUTPUT
042267,000090:                                                                                                  #        UNIT POSITIONAL VECTOR OF SUN IN VSUN.  (SCALED B-1)
042268,000091:                                                                                                  #        UNIT POSITIONAL VECTOR OF MOON IN VMOON.  (SCALED B-1)
042269,000092: 
042270,000093:                                                                                                  #  SUBROUTINES USED
042271,000094:                                                                                                  #        NONE
042272,000095: 
042273,000096:                                                                                                  #  DEBRIS
042274,000097:                                                                                                  #        CURRENT CORE SET, WORK AREA AND FREEFLAG
042275,000098: 
042276,000099: 04,3027                                           BANK     04                                    
042277,000100: 15,2000                                           SETLOC   EPHEM                                 
042278,000101: 15,2000                                           BANK                                           
042279,000102: 
042280,000103: 15,3664  E5,1714                                  EBANK=   VSUN                                  
042281,000104: 15,3664                                           COUNT*   $$/EPHEM                              
042282,000105: 15,3664  15,3664               LUNPOS             EQUALS   LSPOS                                 
042283,000106: 
042284,000107: 15,3664           54201        LSPOS              SETPD    SR                                    
042285,000108: 15,3665           00001                                    0                                     
042286,000109: 15,3666           20617                                    14D                                   #  TP
042287,000110: 15,3667           56371                           TAD      DDV                                   

The hand-written notation "in centisec B 42" appears to the right.

042289,000112: 15,3670           01707                                    TEPHEM                                #  TIME OF LAUNCH
042290,000113: 15,3671           12024                                    CSTODAY                               #  24 HOURS-8640000 CENTI-SECS/DAY B-33

The hand-written notation "@ B 9 = 512 days" appears to the right.

042292,000115: 15,3672           00031                           STORE    TIMEP                                 #  T IN DAYS

The hand-written notation "∴ granularity ≈ 0.164 sec" appears to the right.

042294,000117: 15,3673           77170                           AXT,1    AXT,2                                 
042295,000118: 15,3674           00000                                    0                                     
042296,000119: 15,3675           00000                                    0                                     
042297,000120: 15,3676           77614                           CLEAR                                          
042298,000121: 15,3677           00274                                    FREEFLAG                              #  SWITCH BIT
042299,000122: 15,3700           77745        POSITA             DLOAD                                          
042300,000123: 15,3701           12004                                    KONMAT     +2                         #  ZEROS
042301,000124: 15,3702           00027                           STORE    GTMP                                  
042302,000125: 15,3703           40745        POSITB             DLOAD    DMP*                                  
042303,000126: 15,3704           00031                                    TIMEP                                 #  T
042304,000127: 15,3705           12050                                    VAL67      +4,1                       #  1/27 OR 1/32 OR 1/365

Page 986

042306,000129: 15,3706           42661                           SL       DAD*                                  
042307,000130: 15,3707           20211                                    8D                                    
042308,000131: 15,3710           12046                                    VAL67      +2,1                       #  AARG
042309,000132: 15,3711           40756                           SIN      DMP*                                  #  SIN(T/27+PHI) OR T/32 OR T/365
042310,000133: 15,3712           12044                                    VAL67,1                               #  (A0**2+A1**2)**1/2 SIN(X+PHIA)
042311,000134: 15,3713           62015                           DAD      INCR,1                                #  PLUS
042312,000135: 15,3714           00027                                    GTMP                                  #  (B0**2+B1**2)**1/2 SIN(X+PHIB)
042313,000136: 15,3715           77771                           DEC      -6         B-14                       
042314,000137: 15,3716           00027                           STORE    GTMP                                  #  OR (C0**2+C1**2)**1/2 SIN(X+PHIC)
042315,000138: 15,3717           77614                           BOFSET                                         
042316,000139: 15,3720           00054                                    FREEFLAG                              
042317,000140: 15,3721           33703                                    POSITB                                
042318,000141: 15,3722           40745        POSITD             DLOAD    DMP*                                  
042319,000142: 15,3723           00031                                    TIMEP                                 #  T
042320,000143: 15,3724           65747                                    RATESP,2                              #  LOMR,LOSR,LONR
042321,000144: 15,3725           42661                           SL       DAD*                                  
042322,000145: 15,3726           20206                                    5D                                    
042323,000146: 15,3727           65741                                    RATESP     +6,2                       #  LOMO,LOSO,LONO
042324,000147: 15,3730           77625                           DSU                                            
042325,000148: 15,3731           00027                                    GTMP                                  
042326,000149: 15,3732           10021                           STORE    STMP,2                                #  LOM,LOS,LON
042327,000150: 15,3733           63135                           SLOAD    INCR,2                                
042328,000151: 15,3734           00050                                    X2                                    
042329,000152: 15,3735           77775                           DEC      -2         B-14                       
042330,000153: 15,3736           53015                           DAD      BZE                                   
042331,000154: 15,3737           12026                                    RCB-13                                #  PLUS 2
042332,000155: 15,3740           33770                                    POSITE                                #  2ND
042333,000156: 15,3741           77644                           BPL                                            
042334,000157: 15,3742           33700                                    POSITA                                #  1ST
042335,000158: 15,3743           45345        POSITF             DLOAD    DSU                                   #  3RD
042336,000159: 15,3744           00021                                    STMP                                  #  LOM
042337,000160: 15,3745           00025                                    STMP       +4                         #  LON
042338,000161: 15,3746           65356                           SIN      PDDL                                  #  SIN(LOM-LON)
042339,000162: 15,3747           00021                                    STMP                                  
042340,000163: 15,3750           65356                           SIN      PDDL                                  #  SIN LOM
042341,000164: 15,3751           00021                                    STMP                                  
042342,000165: 15,3752           55546                           COS      VDEF                                  #  COS LOM
042343,000166: 15,3753           53521                           MXV      UNIT                                  
042344,000167: 15,3754           12002                                    KONMAT                                #  K1,K2,K3,K4,
042345,000168: 15,3755           02723                           STORE    VMOON                                 
042346,000169: 15,3756           65345                           DLOAD    PDDL                                  
042347,000170: 15,3757           12004                                    KONMAT     +2                         #  ZERO
042348,000171: 15,3760           00023                                    STMP       +2                         
042349,000172: 15,3761           65356                           SIN      PDDL                                  #  SIN LOS
042350,000173: 15,3762           00023                                    STMP       +2                         
042351,000174: 15,3763           55546                           COS      VDEF                                  #  COS LOS
042352,000175: 15,3764           53521                           MXV      UNIT                                  
042353,000176: 15,3765           12002                                    KONMAT                                
042354,000177: 15,3766           02715                           STORE    VSUN                                  
042355,000178: 15,3767           77616                           RVQ                                            

Page 987

042357,000180: 15,3770           77745        POSITE             DLOAD                                          
042358,000181: 15,3771           12004                                    KONMAT     +2                         #  ZEROS
042359,000182: 15,3772           00027                           STORE    GTMP                                  
042360,000183: 15,3773           77650                           GOTO                                           
042361,000184: 15,3774           33722                                    POSITD                                
042362,000185: 15,3775           77616        LUNVEL             RVQ                                            #         TO FOOL INTEGRATION
042363,000186: 05,2000                                           SETLOC   EPHEM1                                
042364,000187: 05,2000                                           BANK                                           
042365,000188: 
042366,000189: 05,3506                                           COUNT*   $$/EPHEM                              
042367,000190: 05,3506                        STMP               EQUALS   16D                                   
042368,000191: 05,3506                        GTMP               EQUALS   22D                                   
042369,000192: 05,3506                        TIMEP              EQUALS   24D                                   
042370,000193: 

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