Source Code

These source-code files were from the printout at the MIT Museum, with many thanks to Deborah Douglas, the Museum's Curator of Science and Technology, for releasing it to us. The printout was digitally photographed by Paul Fjeld. A team of volunteers transcribed the source code manually from these images or, where appropriate, modified already-transcribed but similar source Luminary 131 (Apollo 13) source code to agree with the images from the printout. Note that the page images presented online are of reduced quality, and that higher-quality images are available. Report any conversion errors or legibility problems in page images to info@sandroid.org. Notations on the program listing read, in part:

	GAP:  ASSEMBLE REVISION 001 OF AGC PROGRAM LMY99 BY NASA 2021112-061
	20'35 OCT. 28,1968
Note that the date is the date of the printout, not the date of the program revision.

042860,000002:                                                                                                  ## Copyright:   Public domain.
042861,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
042862,000004:                                                                                                  ## Purpose:     Part of the source code for Luminary 1A build 099.
042863,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
042864,000006:                                                                                                  ##              Apollo Guidance Computer (AGC), for Apollo 11.
042865,000007:                                                                                                  ## Assembler:   yaYUL
042866,000008:                                                                                                  ## Contact:     Hartmuth Gutsche <hgutsche@xplornet.com>.
042867,000009:                                                                                                  ## Website:     www.ibiblio.org/apollo.
042868,000010:                                                                                                  ## Pages:       984-987
042869,000011:                                                                                                  ## Mod history: 2009-05-24 HG   Transcribed from page images.
042870,000012:                                                                                                  ##              2016-12-17 RSB  Proofed text comments with octopus/ProoferComments
042871,000013:                                                                                                  ##                              and corrected the errors found.
042872,000014:                                                                                                  ##              2017-03-13 RSB  Comment-text fixes noted in proofing Luminary 116.
042873,000015:                                                                                                  ##              2017-08-26 MAS  Fixed comment-text errors found while transcribing Zerlina 56.
042874,000016:                                                                                                  ##
042875,000017:                                                                                                  ## This source code has been transcribed or otherwise adapted from
042876,000018:                                                                                                  ## digitized images of a hardcopy from the MIT Museum.  The digitization
042877,000019:                                                                                                  ## was performed by Paul Fjeld, and arranged for by Deborah Douglas of
042878,000020:                                                                                                  ## the Museum.  Many thanks to both.  The images (with suitable reduction
042879,000021:                                                                                                  ## in storage size and consequent reduction in image quality as well) are
042880,000022:                                                                                                  ## available online at www.ibiblio.org/apollo.  If for some reason you
042881,000023:                                                                                                  ## find that the images are illegible, contact me at info@sandroid.org
042882,000024:                                                                                                  ## about getting access to the (much) higher-quality images which Paul
042883,000025:                                                                                                  ## actually created.
042884,000026:                                                                                                  ##
042885,000027:                                                                                                  ## Notations on the hardcopy document read, in part:
042886,000028:                                                                                                  ##
042887,000029:                                                                                                  ##      Assemble revision 001 of AGC program LMY99 by NASA 2021112-61
042888,000030:                                                                                                  ##      16:27 JULY 14, 1969 
042889,000031: 

Page 984

042891,000033:                                                                                                  #  NAME - LSPOS - LOCATE SUN AND MOON                    DATE - 25 OCT 67
042892,000034:                                                                                                  #  MOD NO. 1
042893,000035:                                                                                                  #  MOD BY NEVILLE                                        ASSEMBLY SUNDANCE
042894,000036: 
042895,000037:                                                                                                  #  FUNCTIONAL DESCRIPTION
042896,000038: 
042897,000039:                                                                                                  #         COMPUTES UNIT POSITION VECTOR OF THE SUN AND MOON IN THE BASIC REFERENCE SYSTEM. THE SUN VECTOR S IS
042898,000040:                                                                                                  #  LOCATED VIA TWO ANGLES. THE FIRST ANGLE(OBLIQUITY) IS THE ANGLE BETWEEN THE EARTH EQUATOR AND THE ECLIPTIC. THE
042899,000041:                                                                                                  #  SECOND ANGLE IS THE LONGITUDE OF THE SUN MEASURED IN THE ECLIPTIC.
042900,000042:                                                                                                  #  THE POSITION VECTOR OF THE SUN IS
042901,000043:                                                                                                  #        -
042902,000044:                                                                                                  #        S = (COS(LOS), COS(OBL)*SIN(LOS), SIN(OBL)*SIN(LOS)), WHERE
042903,000045: 
042904,000046:                                                                                                  #        LOS = LOS +LOS *T-(C *SIN(2PI*T)/365.24 +C *COS(2PI*T)/365.24)
042905,000047:                                                                                                  #                 0    R     0                     1
042906,000048:                                                                                                  #        LOS  (RAD) IS THE LONGITUDE OF THE SUN FOR MIDNIGHT JUNE 30TH OF THE PARTICULAR YEAR.
042907,000049:                                                                                                  #           0
042908,000050:                                                                                                  #        LOS  (RAD/DAY) IS THE MEAN RATE FOR THE PARTICULAR YEAR.
042909,000051:                                                                                                  #           R
042910,000052: 
042911,000053:                                                                                                  #  LOS  AND LOS  ARE STORED AS LOSC AND LOSR IN RATESP.
042912,000054:                                                                                                  #     0        R
042913,000055:                                                                                                  #  COS(OBL) AND SIN(OBL) ARE STORED IN THE MATRIX KONMAT.
042914,000056: 
042915,000057:                                                                                                  #  T, TIME MEASURED IN DAYS (24 HOURS), IS STORED IN TIMEP.
042916,000058: 
042917,000059:                                                                                                  #  C  AND C  ARE FUDGE FACTORS TO MINIMIZE THE DEVIATION.  THEY ARE STORED AS ONE CONSTANT (CMOD), SINCE
042918,000060:                                                                                                  #   0      1                               2  2 1/2
042919,000061:                                                                                                  #  C *SIN(X)+C *COS(X) CAN BE WRITTEN AS (C +C )   *SIN(X+PHI), WHERE PHI=ARCTAN(C /C ).
042920,000062:                                                                                                  #   0         1                            0  1                                   1  0
042921,000063: 
042922,000064:                                                                                                  #  THE MOON IS LOCATED VIA FOUR ANGLES. THE FIRST IS THE OBLIQUITY. THE SECOND IS THE MEAN LONGITUDE OF THE MOON,
042923,000065:                                                                                                  #  MEASURED IN THE ECLIPTIC FROM THE MEAN EQUINOX TO THE MEAN ASCENDING NODE OF THE LUNAR ORBIT, AND THEN ALONG THE
042924,000066:                                                                                                  #  ORBIT.  THE THIRD ANGLE IS THE ANGLE BETWEEN THE ECLIPTIC AND THE LUNAR ORBIT.  THE FOURTH ANGLE IS THE LONGITUDE
042925,000067:                                                                                                  #  OF THE NODE OF THE MOON, MEASURED IN THE LUNAR ORBIT.  LET THESE ANGLES BE OBL,LOM,IM, AND LON RESPECTIVELY.
042926,000068: 
042927,000069:                                                                                                  #  THE SIMPLIFIED POSITION VECTOR OF THE MOON IS
042928,000070:                                                                                                  #        -
042929,000071:                                                                                                  #        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))
042930,000072: 
042931,000073:                                                                                                  #  WHERE
042932,000074:                                                                                                  #        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
042933,000075:                                                                                                  #               0    R     0                    1                     0               1
042934,000076:                                                                                                  #        LON=LON +LON
042935,000077:                                                                                                  #               0    R
042936,000078:                                                                                                  #  A , A , B  AND B  ARE STORED AS AMOD AND BMOD (SEE DESCRIPTION OF CMOD, ABOVE).  COS(OBL), SIN(OBL)*SIN(IM),
042937,000079:                                                                                                  #   0   1   0      1
042938,000080:                                                                                                  #  SIN(OBL), AND COS(OBL)*SIN(IM) ARE STORED IN KONMAT AS K1, K2, K3 AND K4, RESPECTIVELY.  LOM , LOM , LON , LON                                   
042939,000081:                                                                                                  #  ARE STORED AS LOMO, LOMR, LONO, AND LONR IN RATESP.                                         0     R     0     R
042940,000082:                                                                                                  #  THE THREE PHIS ARE STORED AS AARG, BARG, AND CARG(SUN).  ALL CONSTANTS ARE UPDATED BY YEAR.
042941,000083: 
042942,000084:                                                                                                  #  CALLING SEQUENCE

Page 985

042944,000086:                                                                                                  #        CALL LSPOS.  RETURN IS VIA CPRET.
042945,000087: 
042946,000088:                                                                                                  #  ALARMS OR ABORTS
042947,000089:                                                                                                  #        NONE
042948,000090: 
042949,000091:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED
042950,000092:                                                                                                  #        TEPHEM - TIME FROM MIDNIGHT 1 JULY PRECEDING THE LAUNCH TO THE TIME OF THE LAUNCH (WHEN THE AGC CLOCK WENT
042951,000093:                                                                                                  #        TO ZERO).  TEPHEM IS TP WITH UNITS OF CENTI-SECONDS.
042952,000094: 
042953,000095:                                                                                                  #        TIME2 AND TIME1 ARE IN MPAC AND MPAC +1 WHEN PROGRAM IS CALLED.
042954,000096: 
042955,000097:                                                                                                  #  OUTPUT
042956,000098:                                                                                                  #        UNIT POSITIONAL VECTOR OF SUN IN VSUN.  (SCALED B-1)
042957,000099:                                                                                                  #        UNIT POSITIONAL VECTOR OF MOON IN VMOON.  (SCALED B-1)
042958,000100: 
042959,000101:                                                                                                  #  SUBROUTINES USED
042960,000102:                                                                                                  #        NONE
042961,000103: 
042962,000104:                                                                                                  #  DEBRIS
042963,000105:                                                                                                  #        CURRENT CORE SET, WORK AREA AND FREEFLAG
042964,000106: 
042965,000107: 04,3027                                           BANK     04                                    
042966,000108: 15,2000                                           SETLOC   EPHEM                                 
042967,000109: 15,2000                                           BANK                                           
042968,000110: 
042969,000111: 15,3664  E5,1714                                  EBANK=   VSUN                                  
042970,000112: 15,3664                                           COUNT*   $$/EPHEM                              
042971,000113: 15,3664  15,3664               LUNPOS             EQUALS   LSPOS                                 
042972,000114: 
042973,000115: 15,3664           54201        LSPOS              SETPD    SR                                    
042974,000116: 15,3665           00001                                    0                                     
042975,000117: 15,3666           20617                                    14D                                   #  TP
042976,000118: 15,3667           56371                           TAD      DDV                                   

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

042978,000120: 15,3670           01707                                    TEPHEM                                #  TIME OF LAUNCH
042979,000121: 15,3671           12024                                    CSTODAY                               #  24 HOURS-8640000 CENTI-SECS/DAY B-33

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

042981,000123: 15,3672           00031                           STORE    TIMEP                                 #  T IN DAYS

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

042983,000125: 15,3673           77170                           AXT,1    AXT,2                                 
042984,000126: 15,3674           00000                                    0                                     
042985,000127: 15,3675           00000                                    0                                     
042986,000128: 15,3676           77614                           CLEAR                                          
042987,000129: 15,3677           00274                                    FREEFLAG                              #  SWITCH BIT
042988,000130: 15,3700           77745        POSITA             DLOAD                                          
042989,000131: 15,3701           12004                                    KONMAT     +2                         #  ZEROS
042990,000132: 15,3702           00027                           STORE    GTMP                                  
042991,000133: 15,3703           40745        POSITB             DLOAD    DMP*                                  
042992,000134: 15,3704           00031                                    TIMEP                                 #  T
042993,000135: 15,3705           12050                                    VAL67      +4,1                       #  1/27 OR 1/32 OR 1/365

Page 986

042995,000137: 15,3706           42661                           SL       DAD*                                  
042996,000138: 15,3707           20211                                    8D                                    
042997,000139: 15,3710           12046                                    VAL67      +2,1                       #  AARG
042998,000140: 15,3711           40756                           SIN      DMP*                                  #  SIN(T/27+PHI) OR T/32 OR T/365
042999,000141: 15,3712           12044                                    VAL67,1                               #  (A0**2+A1**2)**1/2 SIN(X+PHIA)
043000,000142: 15,3713           62015                           DAD      INCR,1                                #  PLUS
043001,000143: 15,3714           00027                                    GTMP                                  #  (B0**2+B1**2)**1/2 SIN(X+PHIB)
043002,000144: 15,3715           77771                           DEC      -6         B-14                       
043003,000145: 15,3716           00027                           STORE    GTMP                                  #  OR (C0**2+C1**2)**1/2 SIN(X+PHIC)
043004,000146: 15,3717           77614                           BOFSET                                         
043005,000147: 15,3720           00054                                    FREEFLAG                              
043006,000148: 15,3721           33703                                    POSITB                                
043007,000149: 15,3722           40745        POSITD             DLOAD    DMP*                                  
043008,000150: 15,3723           00031                                    TIMEP                                 #  T
043009,000151: 15,3724           65747                                    RATESP,2                              #  LOMR,LOSR,LONR
043010,000152: 15,3725           42661                           SL       DAD*                                  
043011,000153: 15,3726           20206                                    5D                                    
043012,000154: 15,3727           65741                                    RATESP     +6,2                       #  LOMO,LOSO,LONO
043013,000155: 15,3730           77625                           DSU                                            
043014,000156: 15,3731           00027                                    GTMP                                  
043015,000157: 15,3732           10021                           STORE    STMP,2                                #  LOM,LOS,LON
043016,000158: 15,3733           63135                           SLOAD    INCR,2                                
043017,000159: 15,3734           00050                                    X2                                    
043018,000160: 15,3735           77775                           DEC      -2         B-14                       
043019,000161: 15,3736           53015                           DAD      BZE                                   
043020,000162: 15,3737           12026                                    RCB-13                                #  PLUS 2
043021,000163: 15,3740           33770                                    POSITE                                #  2ND
043022,000164: 15,3741           77644                           BPL                                            
043023,000165: 15,3742           33700                                    POSITA                                #  1ST
043024,000166: 15,3743           45345        POSITF             DLOAD    DSU                                   #  3RD
043025,000167: 15,3744           00021                                    STMP                                  #  LOM
043026,000168: 15,3745           00025                                    STMP       +4                         #  LON
043027,000169: 15,3746           65356                           SIN      PDDL                                  #  SIN(LOM-LON)
043028,000170: 15,3747           00021                                    STMP                                  
043029,000171: 15,3750           65356                           SIN      PDDL                                  #  SIN LOM
043030,000172: 15,3751           00021                                    STMP                                  
043031,000173: 15,3752           55546                           COS      VDEF                                  #  COS LOM
043032,000174: 15,3753           53521                           MXV      UNIT                                  
043033,000175: 15,3754           12002                                    KONMAT                                #  K1,K2,K3,K4,
043034,000176: 15,3755           02723                           STORE    VMOON                                 
043035,000177: 15,3756           65345                           DLOAD    PDDL                                  
043036,000178: 15,3757           12004                                    KONMAT     +2                         #  ZERO
043037,000179: 15,3760           00023                                    STMP       +2                         
043038,000180: 15,3761           65356                           SIN      PDDL                                  #  SIN LOS
043039,000181: 15,3762           00023                                    STMP       +2                         
043040,000182: 15,3763           55546                           COS      VDEF                                  #  COS LOS
043041,000183: 15,3764           53521                           MXV      UNIT                                  
043042,000184: 15,3765           12002                                    KONMAT                                
043043,000185: 15,3766           02715                           STORE    VSUN                                  
043044,000186: 15,3767           77616                           RVQ                                            

Page 987

043046,000188: 15,3770           77745        POSITE             DLOAD                                          
043047,000189: 15,3771           12004                                    KONMAT     +2                         #  ZEROS
043048,000190: 15,3772           00027                           STORE    GTMP                                  
043049,000191: 15,3773           77650                           GOTO                                           
043050,000192: 15,3774           33722                                    POSITD                                
043051,000193: 15,3775           77616        LUNVEL             RVQ                                            #         TO FOOL INTEGRATION
043052,000194: 05,2000                                           SETLOC   EPHEM1                                
043053,000195: 05,2000                                           BANK                                           
043054,000196: 
043055,000197: 05,3506                                           COUNT*   $$/EPHEM                              
043056,000198: 05,3506                        STMP               EQUALS   16D                                   
043057,000199: 05,3506                        GTMP               EQUALS   22D                                   
043058,000200: 05,3506                        TIMEP              EQUALS   24D                                   
043059,000201: 

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