Source Code

These source-code files derive from a printout of Luminary 210 (Apollo 15-17 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Jim Lawton, and transcribed to source code by a team of volunteers. This colorized, syntax-highlighted form was created by assembling that transcribed source code. Note that the full page images are available on the Virtual AGC project page at archive.org, while reduced-size images are presented at the VirtualAGC project website. Report or fix any transcription errors at the Virtual AGC project code repository.

Notations on the program listing read, in part:

	GAP: ASSEMBLE REVISION 210 OF AGC PROGRAM LUMINARY 
	BY NASA 2021112-161 17:11 MAR. 19,1971
Note that the date is the date of the printout, not the date of the program revision.

043160,000002:                                                                                                  ## Copyright:   Public domain.
043161,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
043162,000004:                                                                                                  ## Purpose:     A section of Luminary revision 210.
043163,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
043164,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 15-17.
043165,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
043166,000008:                                                                                                  ##              that the code format has been changed to conform to the
043167,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
043168,000010:                                                                                                  ##              original YUL assembler.
043169,000011:                                                                                                  ## Reference:   pp. 982-985
043170,000012:                                                                                                  ## Assembler:   yaYUL
043171,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
043172,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
043173,000015:                                                                                                  ## Mod history: 2016-11-17 JL   Created from Luminary131 version.
043174,000016:                                                                                                  ##              2016-11-29 HG   Transcribed
043175,000017:                                                                                                  ##              2016-12-12 HG   Fix for interpretive operands 8D -> 9D
043176,000018:                                                                                                  ##                                                            5D -> 6D 
043177,000019:                                                                                                  ##              2016-12-26 RSB  Comment-text proofed using ProoferComments
043178,000020:                                                                                                  ##                              and corrected errors found.
043179,000021:                                                                                                  ##              2017-03-13 RSB  Comment-text fixes noted in proofing Luminary 116.
043180,000022:                                                                                                  ##              2017-08-26 MAS  Fixed comment-text errors found while transcribing Zerlina 56.
043181,000023: 

Page 982

043183,000025:                                                                                                  #  NAME - LSPOS  - LOCATE SUN AND MOON                   DATE - 25 OCT 67
043184,000026:                                                                                                  #  MOD NO.2  (DATE OCT 70)
043185,000027:                                                                                                  #  MOD BY NEVILLE                                        ASSEMBLY SUNDANCE
043186,000028: 
043187,000029:                                                                                                  #  FUNCTIONAL DESCRIPTION
043188,000030: 
043189,000031:                                                                                                  #         COMPUTES UNIT POSITION VECTOR OF THE SUN AND MOON IN THE BASIC REFERENCE SYSTEM. THE SUN VECTOR S IS
043190,000032:                                                                                                  #  LOCATED VIA TWO ANGLES. THE FIRST ANGLE(OBLIQUITY) IS THE ANGLE BETWEEN THE EARTH EQUATOR AND THE ECLIPTIC.  THE
043191,000033:                                                                                                  #  SECOND ANGLE IS THE LONGITUDE OF THE SUN MEASURED IN THE ECLIPTIC.
043192,000034:                                                                                                  #  THE POSITION VECTOR OF THE SUN IS
043193,000035:                                                                                                  #         -
043194,000036:                                                                                                  #         S=(COS(LOS), COS(OBL)*SIN(LOS), SIN(OBL)*SIN(LOS)), WHERE
043195,000037: 
043196,000038:                                                                                                  #       LOS=LOS +LOS *T-(C *SIN(2PI*T)/365.24 +C *COS(2PI*T)/365.24)
043197,000039:                                                                                                  #              0    R     0                     1
043198,000040:                                                                                                  #       LOS  (RAD) IS THE LONGITUDE OF THE SUN FOR MIDNIGHT JUNE 30TH OF THE PARTICULAR YEAR.
043199,000041:                                                                                                  #          0
043200,000042:                                                                                                  #       LOS  (RAD/DAY) IS THE MEAN RATE FOR THE PARTICULAR YEAR.
043201,000043:                                                                                                  #          R
043202,000044:                                                                                                  #  LOS  AND LOS  ARE STORED AS LOSC AND LOSR IN RATESP.
043203,000045:                                                                                                  #     0        R
043204,000046:                                                                                                  #  COS(OBL) AND SIN(OBL) ARE STORED IN THE MATRIX KONMAT.
043205,000047:                                                                                                  #  T, TIME MEASURED IN DAYS (24 HOURS), IS STORED IN TIMEP.
043206,000048:                                                                                                  #  C  AND C  ARE FUDGE FACTORS TO MINIMIZE THE DEVIATION.  THEY ARE STORED AS ONE CONSTANT(CMOD), SINCE
043207,000049:                                                                                                  #   0      1                               2  2 1/2
043208,000050:                                                                                                  #  C *SIN(X)+C *COS(X) CAN BE WRITTEN AS (C +C )   *SIN(X+PHI), WHERE PHI=ARCTAN(C /C ).
043209,000051:                                                                                                  #   0         1                            0  1                                   1  0
043210,000052: 
043211,000053:                                                                                                  #  THE MOON IS LOCATED VIA FOUR ANGLES. THE FIRST IS THE OBLIQUITY. THE SECOND IS THE MEAN LONGITUDE OF THE MOON,
043212,000054:                                                                                                  #  MEASURED IN THE ECLIPTIC FROM THE MEAN EQUINOX TO THE MEAN ASCENDING NODE OF THE LUNAR ORBIT, AND THEN ALONG THE
043213,000055:                                                                                                  #  ORBIT. THE THIRD ANGLE IS THE ANGLE BETWEEN THE ECLIPTIC AND THE LUNAR ORBIT. THE FOURTH ANGLE IS THE LONGITUDE
043214,000056:                                                                                                  #  OF THE NODE OF THE MOON, MEASURED IN THE LUNAR ORBIT. LET THESE ANGLES BE OBL,LOM,IM, AND LON RESPECTIVELY.
043215,000057: 
043216,000058:                                                                                                  #  THE SIMPLIFIED POSITION VECTOR OF THE MOON IS
043217,000059:                                                                                                  #    -
043218,000060:                                                                                                  #    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))
043219,000061: 
043220,000062:                                                                                                  #    WHERE
043221,000063:                                                                                                  #       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
043222,000064:                                                                                                  #              0    R     0                    1                     0               1
043223,000065:                                                                                                  #        LON=LON +LON
043224,000066:                                                                                                  #               0    R
043225,000067:                                                                                                  #  A , A , B  AND B  ARE STORED AS AMOD AND BMOD (SEE DESCRIPTION OF CMOD, ABOVE).  COS(OBL), SIN(OBL)*SIN(IM),
043226,000068:                                                                                                  #   0   1   0      1
043227,000069:                                                                                                  #  SIN(OBL), AND COS(OBL)*SIN(IM) ARE STORED IN KONMAT AS K1, K2, K3 AND K4, RESPECTIVELY. LOM , LOM , LON , LON
043228,000070:                                                                                                  #  ARE STORED AS LOMO, LOMR, LONO, AND LONR IN RATESP.                                        0     R     0     R
043229,000071:                                                                                                  #  THE THREE PHIS ARE STORED AS AARG, BARG, AND CARG(SUN).  ALL CONSTANTS ARE UPDATED BY YEAR.
043230,000072: 
043231,000073:                                                                                                  #  CALLING SEQUENCE
043232,000074: 

Page 983

043234,000076:                                                                                                  #    CALL LSPOS.  RETURN IS VIA CPRET.
043235,000077: 
043236,000078:                                                                                                  #  ALARMS OR ABORTS
043237,000079: 
043238,000080:                                                                                                  #    NONE
043239,000081: 
043240,000082:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED
043241,000083: 
043242,000084:                                                                                                  #    TEPHEM - TIME FROM MIDNIGHT 1 JULY PRECEDING THE LAUNCH TO THE TIME OF THE LAUNCH (WHEN THE AGC CLOCK WENT
043243,000085:                                                                                                  #  TO ZERO). TEPHEM IS TP WITH UNITS OF CENTI-SECONDS.
043244,000086:                                                                                                  #    TIME2 AND TIME1 ARE IN MPAC AND MPAC +1 WHEN PROGRAM IS CALLED.
043245,000087: 
043246,000088:                                                                                                  #  OUTPUT
043247,000089: 
043248,000090:                                                                                                  #    UNIT POSITIONAL VECTOR OF SUN IN VSUN.   (SCALED B-1)
043249,000091:                                                                                                  #    UNIT POSITIONAL VECTOR OF MOON IN VMOON. (SCALED B-1)
043250,000092: 
043251,000093:                                                                                                  #  SUBROUTINES USED
043252,000094: 
043253,000095:                                                                                                  #    NONE
043254,000096: 
043255,000097:                                                                                                  #  DEBRIS
043256,000098: 
043257,000099:                                                                                                  #    CURRENT CORE SET, WORK AREA AND FREEFLAG
043258,000100: 04,3030                                           BANK     04                                    
043259,000101: 15,2000                                           SETLOC   EPHEM                                 
043260,000102: 15,2000                                           BANK                                           
043261,000103: 
043262,000104: 15,3646  E5,1714                                  EBANK=   VSUN                                  
043263,000105: 15,3646                                           COUNT*   $$/EPHEM                              
043264,000106: 15,3646  15,3646               LUNPOS             EQUALS   LSPOS                                 
043265,000107: 
043266,000108: 15,3646           54201        LSPOS              SETPD    SR                                    
043267,000109: 15,3647           00001                                    0                                     
043268,000110: 15,3650           20617                                    14D                                   #  TP
043269,000111: 15,3651           56371                           TAD      DDV                                   
043270,000112: 15,3652           01707                                    TEPHEM                                #  TIME OF LAUNCH
043271,000113: 15,3653           32001                                    CSTODAY                               #  24 HOURS-8640000 CENTI-SECS/DAY B-32
043272,000114: 15,3654           00031                           STORE    TIMEP                                 #  T IN DAYS
043273,000115: 15,3655           77170                           AXT,1    AXT,2                                 
043274,000116: 15,3656           00000                                    0                                     
043275,000117: 15,3657           00000                                    0                                     
043276,000118: 15,3660           77614                           CLEAR                                          
043277,000119: 15,3661           00274                                    FREEFLAG                              #  SWITCH BIT
043278,000120: 15,3662           77745        POSITA             DLOAD                                          
043279,000121: 15,3663           12004                                    KONMAT     +2                         #  ZEROS
043280,000122: 15,3664           00027                           STORE    GTMP                                  
043281,000123: 15,3665           40745        POSITB             DLOAD    DMP*                                  
043282,000124: 15,3666           00031                                    TIMEP                                 #  T
043283,000125: 15,3667           12030                                    VAL67      +4,1                       #  1/27 OR 1/32 OR 1/365

Page 984

043285,000127: 15,3670           42661                           SL       DAD*                                  
043286,000128: 15,3671           20212                                    9D                                    
043287,000129: 15,3672           12026                                    VAL67      +2,1                       #  AARG
043288,000130: 15,3673           40756                           SIN      DMP*                                  #  SIN(T/27+PHI) OR T/32 OR T/365
043289,000131: 15,3674           12024                                    VAL67,1                               #  (A0**2+A1**2)**1/2 SIN(X+PHIA)
043290,000132: 15,3675           62015                           DAD      INCR,1                                #  PLUS
043291,000133: 15,3676           00027                                    GTMP                                  #  (B0**2+B1**2)**1/2 SIN(X+PHIB)
043292,000134: 15,3677           77771                           DEC      -6         B-14                       
043293,000135: 15,3700           00027                           STORE    GTMP                                  #  OR (C0**2+C1**2)**1/2 SIN(X+PHIC)
043294,000136: 15,3701           77614                           BOFSET                                         
043295,000137: 15,3702           00054                                    FREEFLAG                              
043296,000138: 15,3703           33665                                    POSITB                                
043297,000139: 15,3704           40745        POSITD             DLOAD    DMP*                                  
043298,000140: 15,3705           00031                                    TIMEP                                 #  T
043299,000141: 15,3706           67752                                    RATESP,2                              #  LOMR,LOSR,LONR
043300,000142: 15,3707           42661                           SL       DAD*                                  
043301,000143: 15,3710           20207                                    6D                                    
043302,000144: 15,3711           67744                                    RATESP     +6,2                       #  LOMO,LOSO,LONO
043303,000145: 15,3712           77625                           DSU                                            
043304,000146: 15,3713           00027                                    GTMP                                  
043305,000147: 15,3714           10021                           STORE    STMP,2                                #  LOM,LOS,LON
043306,000148: 15,3715           63135                           SLOAD    INCR,2                                
043307,000149: 15,3716           00050                                    X2                                    
043308,000150: 15,3717           77775                           DEC      -2         B-14                       
043309,000151: 15,3720           53015                           DAD      BZE                                   
043310,000152: 15,3721           32003                                    RCB-13                                #  PLUS 2
043311,000153: 15,3722           33752                                    POSITE                                #  2ND
043312,000154: 15,3723           77644                           BPL                                            
043313,000155: 15,3724           33662                                    POSITA                                #  1ST
043314,000156: 15,3725           45345        POSITF             DLOAD    DSU                                   #  3RD
043315,000157: 15,3726           00021                                    STMP                                  #  LOM
043316,000158: 15,3727           00025                                    STMP       +4                         #  LON
043317,000159: 15,3730           65356                           SIN      PDDL                                  #  SIN(LOM-LON)
043318,000160: 15,3731           00021                                    STMP                                  
043319,000161: 15,3732           65356                           SIN      PDDL                                  #  SIN LOM
043320,000162: 15,3733           00021                                    STMP                                  
043321,000163: 15,3734           55546                           COS      VDEF                                  #  COS LOM
043322,000164: 15,3735           53521                           MXV      UNIT                                  
043323,000165: 15,3736           12002                                    KONMAT                                #  K1,K2,K3,K4,
043324,000166: 15,3737           02723                           STORE    VMOON                                 
043325,000167: 15,3740           65345                           DLOAD    PDDL                                  
043326,000168: 15,3741           12004                                    KONMAT     +2                         #  ZERO
043327,000169: 15,3742           00023                                    STMP       +2                         
043328,000170: 15,3743           65356                           SIN      PDDL                                  #  SIN LOS
043329,000171: 15,3744           00023                                    STMP       +2                         
043330,000172: 15,3745           55546                           COS      VDEF                                  #  COS LOS
043331,000173: 15,3746           53521                           MXV      UNIT                                  
043332,000174: 15,3747           12002                                    KONMAT                                
043333,000175: 15,3750           02715                           STORE    VSUN                                  
043334,000176: 15,3751           77616                           RVQ                                            
043335,000177: 

Page 985

043337,000179: 15,3752           77745        POSITE             DLOAD                                          
043338,000180: 15,3753           12004                                    KONMAT     +2                         #  ZEROS
043339,000181: 15,3754           00027                           STORE    GTMP                                  
043340,000182: 15,3755           77650                           GOTO                                           
043341,000183: 15,3756           33704                                    POSITD                                
043342,000184: 05,2000                                           SETLOC   EPHEM1                                
043343,000185: 05,2000                                           BANK                                           
043344,000186: 
043345,000187: 05,3507                                           COUNT*   $$/EPHEM                              
043346,000188: 
043347,000189: 05,3507                        STMP               EQUALS   16D                                   
043348,000190: 
043349,000191: 05,3507                        GTMP               EQUALS   22D                                   
043350,000192: 
043351,000193: 05,3507                        TIMEP              EQUALS   24D                                   

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