Source Code

These source-code files are part of a reconstructed copy of Luminary 69/2, the flown, final release of the Apollo 10 Lunar Module (LM) Apollo Guidance Computer (AGC) software.

The reconstruction is based on the source code of Luminary 69 — i.e., the initial, unflown version, "revision 0" — of which a contemporary listing was available. The code was then updated by incorporating the differences between Luminary 69 and Luminary 69/2, known from other contemporary documentation. The only such difference is the implementation in Luminary 69/2 of the "R-2 Lunar Potential Model", the source code for which was taken from program Luminary 99/1 (Apollo 11 LM), of which a contemporary listing was also available. Finally, the now-reconstructed Luminary 69/2 was then validated by assembling it to executable form and verifying that its memory banks had the correct checksums, known from still other contemporary documentation.

Note that page numbers in the reconstructed code match those in the original Luminary 69 program listing, or in the ORBITAL INTEGRATION log section, in Luminary 99/1. Page numbers would certainly differ somewhat in a contemporary Luminary 69/2 listing. Moreover, annotations that were not present in the contemporary source code have been added to the reconstructed code to justify each change in Luminary 69/2 relative to Luminary 69. Here's a guide to the Apollo documentation referenced in those annotations:
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.

043043,000002:                                                                                                  ## Copyright:   Public domain.
043044,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
043045,000004:                                                                                                  ## Purpose:     A section of LUM69 revision 2.
043046,000005:                                                                                                  ##              It is part of the reconstructed source code for the flown
043047,000006:                                                                                                  ##              version of the flight software for the Lunar Module's (LM)
043048,000007:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 10. The code has
043049,000008:                                                                                                  ##              been recreated from a copy of Luminary revsion 069, using
043050,000009:                                                                                                  ##              changes present in Luminary 099 which were described in
043051,000010:                                                                                                  ##              Luminary memos 75 and 78. The code has been adapted such
043052,000011:                                                                                                  ##              that the resulting bugger words exactly match those specified
043053,000012:                                                                                                  ##              for LUM69 revision 2 in NASA drawing 2021152B, which gives
043054,000013:                                                                                                  ##              relatively high confidence that the reconstruction is correct.
043055,000014:                                                                                                  ## Reference:   pp. 979-982
043056,000015:                                                                                                  ## Assembler:   yaYUL
043057,000016:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
043058,000017:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
043059,000018:                                                                                                  ## Mod history: 2019-07-27 MAS  Created from Luminary 69.
043060,000019: 

Page 979

043062,000021:                                                                                                  #  NAME - LSPOS  - LOCATE SUN AND MOON                   DATE - 25 OCT 67
043063,000022:                                                                                                  #  MOD NO.1
043064,000023:                                                                                                  #  MOD BY NEVILLE                                        ASSEMBLY SUNDANCE
043065,000024: 
043066,000025:                                                                                                  #  FUNCTIONAL DESCRIPTION
043067,000026: 
043068,000027:                                                                                                  #         COMPUTES UNIT POSITION VECTOR OF THE SUN AND MOON IN THE BASIC REFERENCE SYSTEM. THE SUN VECTOR S IS
043069,000028:                                                                                                  #  LOCATED VIA TWO ANGLES. THE FIRST ANGLE(OBLIQUITY) IS THE ANGLE BETWEEN THE EARTH EQUATOR AND THE ECLIPTIC. THE
043070,000029:                                                                                                  #  SECOND ANGLE IS THE LONGITUDE OF THE SUN MEASURED IN THE ECLIPTIC.
043071,000030:                                                                                                  #  THE POSITION VECTOR OF THE SUN IS
043072,000031:                                                                                                  #        -
043073,000032:                                                                                                  #        S = (COS(LOS), COS(OBL)*SIN(LOS), SIN(OBL)*SIN(LOS)), WHERE
043074,000033: 
043075,000034:                                                                                                  #        LOS = LOS +LOS *T-(C *SIN(2PI*T)/365.24 +C *COS(2PI*T)/365.24)
043076,000035:                                                                                                  #                 0    R     0                     1
043077,000036:                                                                                                  #        LOS  (RAD) IS THE LONGITUDE OF THE SUN FOR MIDNIGHT JUNE 30TH OF THE PARTICULAR YEAR.
043078,000037:                                                                                                  #           0
043079,000038:                                                                                                  #        LOS  (RAD/DAY) IS THE MEAN RATE FOR THE PARTICULAR YEAR.
043080,000039:                                                                                                  #           R
043081,000040: 
043082,000041:                                                                                                  #  LOS  AND LOS  ARE STORED AS LOSC AND LOSR IN RATESP.
043083,000042:                                                                                                  #     0        R
043084,000043:                                                                                                  #  COS(OBL) AND SIN(OBL) ARE STORED IN THE MATRIX KONMAT.
043085,000044:                                                                                                  #  T, TIME MEASURED IN DAYS (24 HOURS), IS STORED IN TIMEP.
043086,000045:                                                                                                  #  C  AND C  ARE FUDGE FACTORS TO MINIMIZE THE DEVIATION.  THEY ARE STORED AS ONE CONSTANT (CMOD), SINCE
043087,000046:                                                                                                  #   0      1                               2  2 1/2
043088,000047:                                                                                                  #  C *SIN(X)+C *COS(X) CAN BE WRITTEN AS (C +C )   *SIN(X+PHI), WHERE PHI=ARCTAN(C /C ).
043089,000048:                                                                                                  #   0         1                            0  1                                   1  0
043090,000049: 
043091,000050:                                                                                                  #  THE MOON IS LOCATED VIA FOUR ANGLES. THE FIRST IS THE OBLIQUITY. THE SECOND IS THE MEAN LONGITUDE OF THE MOON,
043092,000051:                                                                                                  #  MEASURED IN THE ECLIPTIC FROM THE MEAN EQUINOX TO THE MEAN ASCENDING NODE OF THE LUNAR ORBIT, AND THEN ALONG THE
043093,000052:                                                                                                  #  ORBIT.  THE THIRD ANGLE IS THE ANGLE BETWEEN THE ECLIPTIC AND THE LUNAR ORBIT.  THE FOURTH ANGLE IS THE LONGITUDE
043094,000053:                                                                                                  #  OF THE NODE OF THE MOON, MEASURED IN THE LUNAR ORBIT.  LET THESE ANGLES BE OBL,LOM,IM, AND LON RESPECTIVELY.
043095,000054: 
043096,000055:                                                                                                  #  THE SIMPLIFIED POSITION VECTOR OF THE MOON IS
043097,000056:                                                                                                  #        -
043098,000057:                                                                                                  #        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))
043099,000058: 
043100,000059:                                                                                                  #  WHERE
043101,000060:                                                                                                  #        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
043102,000061:                                                                                                  #               0    R     0                    1                     0               1
043103,000062:                                                                                                  #        LON=LON +LON
043104,000063:                                                                                                  #               0    R
043105,000064:                                                                                                  #  A , A , B  AND B  ARE STORED AS AMOD AND BMOD (SEE DESCRIPTION OF CMOD, ABOVE).  COS(OBL), SIN(OBL)*SIN(IM),
043106,000065:                                                                                                  #   0   1   0      1
043107,000066:                                                                                                  #  SIN(OBL), AND COS(OBL)*SIN(IM) ARE STORED IN KONMAT AS K1, K2, K3 AND K4, RESPECTIVELY.  LOM , LOM , LON , LON                                   
043108,000067:                                                                                                  #  ARE STORED AS LOMO, LOMR, LONO, AND LONR IN RATESP.                                         0     R     0     R
043109,000068:                                                                                                  #  THE THREE PHIS ARE STORED AS AARG, BARG, AND CARG(SUN).  ALL CONSTANTS ARE UPDATED BY YEAR.
043110,000069: 
043111,000070:                                                                                                  #  CALLING SEQUENCE

Page 980

043113,000072:                                                                                                  #        CALL LSPOS.  RETURN IS VIA CPRET.
043114,000073: 
043115,000074:                                                                                                  #  ALARMS OR ABORTS
043116,000075:                                                                                                  #        NONE
043117,000076: 
043118,000077:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED
043119,000078:                                                                                                  #        TEPHEM - TIME FROM MIDNIGHT 1 JULY PRECEDING THE LAUNCH TO THE TIME OF THE LAUNCH (WHEN THE AGC CLOCK WENT
043120,000079:                                                                                                  #        TO ZERO).  TEPHEM IS TP WITH UNITS OF CENTI-SECONDS.
043121,000080: 
043122,000081:                                                                                                  #        TIME2 AND TIME1 ARE IN MPAC AND MPAC +1 WHEN PROGRAM IS CALLED.
043123,000082: 
043124,000083:                                                                                                  #  OUTPUT
043125,000084:                                                                                                  #        UNIT POSITIONAL VECTOR OF SUN IN VSUN.  (SCALED B-1)
043126,000085:                                                                                                  #        UNIT POSITIONAL VECTOR OF MOON IN VMOON.  (SCALED B-1)
043127,000086: 
043128,000087:                                                                                                  #  SUBROUTINES USED
043129,000088:                                                                                                  #        NONE
043130,000089: 
043131,000090:                                                                                                  #  DEBRIS
043132,000091:                                                                                                  #        CURRENT CORE SET, WORK AREA AND FREEFLAG
043133,000092: 
043134,000093: 04,2750                                           BANK     04                                    
043135,000094: 15,2000                                           SETLOC   EPHEM                                 
043136,000095: 15,2000                                           BANK                                           
043137,000096: 
043138,000097: 15,3663  E5,1714                                  EBANK=   VSUN                                  
043139,000098: 15,3663                                           COUNT*   $$/EPHEM                              
043140,000099: 15,3663  15,3663               LUNPOS             EQUALS   LSPOS                                 
043141,000100: 
043142,000101: 15,3663           54201        LSPOS              SETPD    SR                                    
043143,000102: 15,3664           00001                                    0                                     
043144,000103: 15,3665           20617                                    14D                                   #  TP
043145,000104: 15,3666           56371                           TAD      DDV                                   

In Lum99, the hand-written notation "in centisec B 42" appears to the right.

043147,000106: 15,3667           01707                                    TEPHEM                                #  TIME OF LAUNCH
043148,000107: 15,3670           12024                                    CSTODAY                               #  24 HOURS-8640000 CENTI-SECS/DAY B-33

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

043150,000109: 15,3671           00031                           STORE    TIMEP                                 #  T IN DAYS

In Lum99, the hand-written notation "∴ granularity ≈ 0.164 sec" appears to the right.

043152,000111: 15,3672           77170                           AXT,1    AXT,2                                 
043153,000112: 15,3673           00000                                    0                                     
043154,000113: 15,3674           00000                                    0                                     
043155,000114: 15,3675           77614                           CLEAR                                          
043156,000115: 15,3676           00274                                    FREEFLAG                              #  SWITCH BIT
043157,000116: 15,3677           77745        POSITA             DLOAD                                          
043158,000117: 15,3700           12004                                    KONMAT     +2                         #  ZEROS
043159,000118: 15,3701           00027                           STORE    GTMP                                  
043160,000119: 15,3702           40745        POSITB             DLOAD    DMP*                                  
043161,000120: 15,3703           00031                                    TIMEP                                 #  T
043162,000121: 15,3704           12050                                    VAL67      +4,1                       #  1/27 OR 1/32 OR 1/365

Page 981

043164,000123: 15,3705           42661                           SL       DAD*                                  
043165,000124: 15,3706           20211                                    8D                                    
043166,000125: 15,3707           12046                                    VAL67      +2,1                       #  AARG
043167,000126: 15,3710           40756                           SIN      DMP*                                  #  SIN(T/27+PHI) OR T/32 OR T/365
043168,000127: 15,3711           12044                                    VAL67,1                               #  (A0**2+A1**2)**1/2 SIN(X+PHIA)
043169,000128: 15,3712           62015                           DAD      INCR,1                                #  PLUS
043170,000129: 15,3713           00027                                    GTMP                                  #  (B0**2+B1**2)**1/2 SIN(X+PHIB)
043171,000130: 15,3714           77771                           DEC      -6         B-14                       
043172,000131: 15,3715           00027                           STORE    GTMP                                  #  OR (C0**2+C1**2)**1/2 SIN(X+PHIC)
043173,000132: 15,3716           77614                           BOFSET                                         
043174,000133: 15,3717           00054                                    FREEFLAG                              
043175,000134: 15,3720           33702                                    POSITB                                
043176,000135: 15,3721           40745        POSITD             DLOAD    DMP*                                  
043177,000136: 15,3722           00031                                    TIMEP                                 #  T
043178,000137: 15,3723           65747                                    RATESP,2                              #  LOMR,LOSR,LONR
043179,000138: 15,3724           42661                           SL       DAD*                                  
043180,000139: 15,3725           20206                                    5D                                    
043181,000140: 15,3726           65741                                    RATESP     +6,2                       #  LOMO,LOSO,LONO
043182,000141: 15,3727           77625                           DSU                                            
043183,000142: 15,3730           00027                                    GTMP                                  
043184,000143: 15,3731           10021                           STORE    STMP,2                                #  LOM,LOS,LON
043185,000144: 15,3732           63135                           SLOAD    INCR,2                                
043186,000145: 15,3733           00050                                    X2                                    
043187,000146: 15,3734           77775                           DEC      -2         B-14                       
043188,000147: 15,3735           53015                           DAD      BZE                                   
043189,000148: 15,3736           12026                                    RCB-13                                #  PLUS 2
043190,000149: 15,3737           33767                                    POSITE                                #  2ND
043191,000150: 15,3740           77644                           BPL                                            
043192,000151: 15,3741           33677                                    POSITA                                #  1ST
043193,000152: 15,3742           45345        POSITF             DLOAD    DSU                                   #  3RD
043194,000153: 15,3743           00021                                    STMP                                  #  LOM
043195,000154: 15,3744           00025                                    STMP       +4                         #  LON
043196,000155: 15,3745           65356                           SIN      PDDL                                  #  SIN(LOM-LON)
043197,000156: 15,3746           00021                                    STMP                                  
043198,000157: 15,3747           65356                           SIN      PDDL                                  #  SIN LOM
043199,000158: 15,3750           00021                                    STMP                                  
043200,000159: 15,3751           55546                           COS      VDEF                                  #  COS LOM
043201,000160: 15,3752           53521                           MXV      UNIT                                  
043202,000161: 15,3753           12002                                    KONMAT                                #  K1,K2,K3,K4,
043203,000162: 15,3754           02723                           STORE    VMOON                                 
043204,000163: 15,3755           65345                           DLOAD    PDDL                                  
043205,000164: 15,3756           12004                                    KONMAT     +2                         #  ZERO
043206,000165: 15,3757           00023                                    STMP       +2                         
043207,000166: 15,3760           65356                           SIN      PDDL                                  #  SIN LOS
043208,000167: 15,3761           00023                                    STMP       +2                         
043209,000168: 15,3762           55546                           COS      VDEF                                  #  COS LOS
043210,000169: 15,3763           53521                           MXV      UNIT                                  
043211,000170: 15,3764           12002                                    KONMAT                                
043212,000171: 15,3765           02715                           STORE    VSUN                                  
043213,000172: 15,3766           77616                           RVQ                                            

Page 982

043215,000174: 15,3767           77745        POSITE             DLOAD                                          
043216,000175: 15,3770           12004                                    KONMAT     +2                         #  ZEROS
043217,000176: 15,3771           00027                           STORE    GTMP                                  
043218,000177: 15,3772           77650                           GOTO                                           
043219,000178: 15,3773           33721                                    POSITD                                
043220,000179: 15,3774           77616        LUNVEL             RVQ                                            #         TO FOOL INTEGRATION
043221,000180: 05,2000                                           SETLOC   EPHEM1                                
043222,000181: 05,2000                                           BANK                                           
043223,000182: 
043224,000183: 05,3430                                           COUNT*   $$/EPHEM                              
043225,000184: 05,3430                        STMP               EQUALS   16D                                   
043226,000185: 
043227,000186: 05,3430                        GTMP               EQUALS   22D                                   
043228,000187: 
043229,000188: 05,3430                        TIMEP              EQUALS   24D                                   
043230,000189: 

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