Source Code

These source-code files are part of a reconstructed copy of LM131 revision 1, the final release of the Apollo 13 Lunar Module (LM) Apollo Guidance Computer (AGC) software.

The source reconstruction began with source code of Luminary 131 previously transcribed from a digitized copy of that program. A dump of the flight spare core rope memory module B5, part number 2010802-171, serial number RAY 411, was obtained. This module is the only module different between Luminary 131 and LM131 revision 1. The dump was disassembled and all changes were incorporated into these source files. Note that page numbers in the reconstructed code match those on the Luminary 131 printout, although the changed code would likely have changed page numbers for a real LM131 revision 1 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.

041835,000002:                                                                                                  ## Copyright:   Public domain.
041836,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
041837,000004:                                                                                                  ## Purpose:     A section of LM131 revision 1.
041838,000005:                                                                                                  ##              It is part of the reconstructed source code for the final
041839,000006:                                                                                                  ##              release of the flight software for the Lunar Module's (LM)
041840,000007:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13. The code has
041841,000008:                                                                                                  ##              been reconstructed from a listing of Luminary 131 and a dump
041842,000009:                                                                                                  ##              of a core rope memory module B5, part number 2010802-171,
041843,000010:                                                                                                  ##              which is the only module different between LM131 revision 1
041844,000011:                                                                                                  ##              and Luminary 131. The executable generated from this source
041845,000012:                                                                                                  ##              has been verified against the module dump, so while the names,
041846,000013:                                                                                                  ##              comments, and ordering may not be exactly correct, the
041847,000014:                                                                                                  ##              resulting binary is.
041848,000015:                                                                                                  ## Reference:   pp. 978-981
041849,000016:                                                                                                  ## Assembler:   yaYUL
041850,000017:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
041851,000018:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
041852,000019:                                                                                                  ## Mod history: 2022-10-28 MAS  Created from Luminary 131.
041853,000020: 

Page 978

041855,000022:                                                                                                  #  NAME - LSPOS - LOCATE SUN AND MOON                    DATE - 25 OCT 67
041856,000023:                                                                                                  #  MOD NO.1
041857,000024:                                                                                                  #  MOD BY NEVILLE                                        ASSEMBLY SUNDANCE
041858,000025: 
041859,000026:                                                                                                  #  FUNCTIONAL DESCRIPTION
041860,000027: 
041861,000028:                                                                                                  #  COMPUTES UNIT POSITION VECTOR OF THE SUN AND MOON IN THE BASIC REFERENCE SYSTEM.  THE SUN VECTOR S IS
041862,000029:                                                                                                  #  LOCATED VIA TWO ANGLES.  THE FIRST ANGLE (OBLIQUITY) IS THE ANGLE BETWEEN THE EARTH EQUATOR AND THE ECLIPTIC. THE
041863,000030:                                                                                                  #  SECOND ANGLE IS THE LONGITUDE OF THE SUN MEASURED IN THE ECLIPTIC.
041864,000031:                                                                                                  #  THE POSITION VECTOR OF THE SUN IS
041865,000032:                                                                                                  #        -
041866,000033:                                                                                                  #        S = (COS(LOS), COS(OBL)*SIN(LOS), SIN(OBL)*SIN(LOS)), WHERE
041867,000034: 
041868,000035:                                                                                                  #        LOS = LOS +LOS *T-(C *SIN(2PI*T)/365.24 +C *COS(2PI*T)/365.24)
041869,000036:                                                                                                  #                 0    R     0                     1
041870,000037:                                                                                                  #        LOS  (RAD) IS THE LONGITUDE OF THE SUN FOR MIDNIGHT JUNE 30TH OF THE PARTICULAR YEAR.
041871,000038:                                                                                                  #           0
041872,000039:                                                                                                  #        LOS  (RAD/DAY) IS THE MEAN RATE FOR THE PARTICULAR YEAR.
041873,000040:                                                                                                  #           R
041874,000041: 
041875,000042:                                                                                                  #  LOS  AND LOS  ARE STORED AS LOSC AND LOSR IN RATESP.
041876,000043:                                                                                                  #     0        R
041877,000044:                                                                                                  #  COS(OBL) AND SIN(OBL) ARE STORED IN THE MATRIX KONMAT.
041878,000045: 
041879,000046:                                                                                                  #  T, TIME MEASURED IN DAYS (24 HOURS), IS STORED IN TIMEP.
041880,000047: 
041881,000048:                                                                                                  #  C  AND C  ARE FUDGE FACTORS TO MINIMIZE THE DEVIATION.  THEY ARE STORED AS ONE CONSTANT (CMOD), SINCE
041882,000049:                                                                                                  #   0      1                               2  2 1/2
041883,000050:                                                                                                  #  C *SIN(X)+C *COS(X) CAN BE WRITTEN AS (C +C )   *SIN(X+PHI), WHERE PHI=ARCTAN(C /C ).
041884,000051:                                                                                                  #   0         1                            0  1                                   1  0
041885,000052: 
041886,000053:                                                                                                  #  THE MOON IS LOCATED VIA FOUR ANGLES. THE FIRST IS THE OBLIQUITY. THE SECOND IS THE MEAN LONGITUDE OF THE MOON,
041887,000054:                                                                                                  #  MEASURED IN THE ECLIPTIC FROM THE MEAN EQUINOX TO THE MEAN ASCENDING NODE OF THE LUNAR ORBIT, AND THEN ALONG THE
041888,000055:                                                                                                  #  ORBIT.  THE THIRD ANGLE IS THE ANGLE BETWEEN THE ECLIPTIC AND THE LUNAR ORBIT.  THE FOURTH ANGLE IS THE LONGITUDE
041889,000056:                                                                                                  #  OF THE NODE OF THE MOON, MEASURED IN THE LUNAR ORBIT.  LET THESE ANGLES BE OBL,LOM,IM, AND LON RESPECTIVELY.
041890,000057: 
041891,000058:                                                                                                  #  THE SIMPLIFIED POSITION VECTOR OF THE MOON IS
041892,000059:                                                                                                  #        -
041893,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))
041894,000061: 
041895,000062:                                                                                                  #  WHERE
041896,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
041897,000064:                                                                                                  #               0    R     0                    1                     0               1
041898,000065:                                                                                                  #        LON=LON +LON
041899,000066:                                                                                                  #               0    R
041900,000067:                                                                                                  #  A , A , B  AND B  ARE STORED AS AMOD AND BMOD (SEE DESCRIPTION OF CMOD, ABOVE).  COS(OBL), SIN(OBL)*SIN(IM),
041901,000068:                                                                                                  #   0   1   0      1
041902,000069:                                                                                                  #  SIN(OBL), AND COS(OBL)*SIN(IM) ARE STORED IN KONMAT AS K1, K2, K3  AND K4, RESPECTIVELY.  LOM , LOM , LON , LON
041903,000070:                                                                                                  #  ARE STORED AS LOMO, LOMR, LONO, AND LONR IN RATESP.                                          0     R     0     R
041904,000071: 
041905,000072:                                                                                                  #  THE THREE PHIS ARE STORED AS AARG, BARG, AND CARG(SUN).  ALL CONSTANTS ARE UPDATED BY YEAR.
041906,000073: 
041907,000074:                                                                                                  #  CALLING SEQUENCE

Page 979

041909,000076:                                                                                                  #        CALL LSPOS.  RETURN IS VIA CPRET.
041910,000077: 
041911,000078:                                                                                                  #  ALARMS OR ABORTS
041912,000079:                                                                                                  #        NONE
041913,000080: 
041914,000081:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED
041915,000082:                                                                                                  #        TEPHEM - TIME FROM MIDNIGHT 1 JULY PRECEDING THE LAUNCH TO THE TIME OF THE LAUNCH (WHEN THE AGC CLOCK WENT
041916,000083:                                                                                                  #        TO ZERO).  TEPHEM IS TP WITH UNITS OF CENTI-SECONDS.
041917,000084: 
041918,000085:                                                                                                  #        TIME2 AND TIME1 ARE IN MPAC AND MPAC +1 WHEN PROGRAM IS CALLED.
041919,000086: 
041920,000087:                                                                                                  #  OUTPUT
041921,000088:                                                                                                  #        UNIT POSITIONAL VECTOR OF SUN IN VSUN.  (SCALED B-1)
041922,000089:                                                                                                  #        UNIT POSITIONAL VECTOR OF MOON IN VMOON.  (SCALED B-1)
041923,000090: 
041924,000091:                                                                                                  #  SUBROUTINES USED
041925,000092:                                                                                                  #        NONE
041926,000093: 
041927,000094:                                                                                                  #  DEBRIS
041928,000095:                                                                                                  #        CURRENT CORE SET, WORK AREA AND FREEFLAG
041929,000096: 
041930,000097: 04,2773                                           BANK     04                                    
041931,000098: 15,2000                                           SETLOC   EPHEM                                 
041932,000099: 15,2000                                           BANK                                           
041933,000100: 
041934,000101: 15,3647  E5,1714                                  EBANK=   VSUN                                  
041935,000102: 15,3647                                           COUNT*   $$/EPHEM                              
041936,000103: 15,3647  15,3647               LUNPOS             EQUALS   LSPOS                                 
041937,000104: 
041938,000105: 15,3647           54201        LSPOS              SETPD    SR                                    
041939,000106: 15,3650           00001                                    0                                     
041940,000107: 15,3651           20617                                    14D                                   #  TP
041941,000108: 15,3652           56371                           TAD      DDV                                   
041942,000109: 15,3653           01707                                    TEPHEM                                #  TIME OF LAUNCH
041943,000110: 15,3654           12024                                    CSTODAY                               #  24 HOURS-8640000 CENTI-SECS/DAY B-33
041944,000111: 15,3655           00031                           STORE    TIMEP                                 #  T IN DAYS
041945,000112: 15,3656           77170                           AXT,1    AXT,2                                 
041946,000113: 15,3657           00000                                    0                                     
041947,000114: 15,3660           00000                                    0                                     
041948,000115: 15,3661           77614                           CLEAR                                          
041949,000116: 15,3662           00274                                    FREEFLAG                              #  SWITCH BIT
041950,000117: 15,3663           77745        POSITA             DLOAD                                          
041951,000118: 15,3664           12004                                    KONMAT     +2                         #  ZEROS
041952,000119: 15,3665           00027                           STORE    GTMP                                  
041953,000120: 15,3666           40745        POSITB             DLOAD    DMP*                                  
041954,000121: 15,3667           00031                                    TIMEP                                 #  T
041955,000122: 15,3670           12050                                    VAL67      +4,1                       #  1/27 OR 1/32 OR 1/365

Page 980

041957,000124: 15,3671           42661                           SL       DAD*                                  
041958,000125: 15,3672           20211                                    8D                                    
041959,000126: 15,3673           12046                                    VAL67      +2,1                       #  AARG
041960,000127: 15,3674           40756                           SIN      DMP*                                  #  SIN(T/27+PHI) OR T/32 OR T/365
041961,000128: 15,3675           12044                                    VAL67,1                               #  (A0**2+A1**2)**1/2 SIN(X+PHIA)
041962,000129: 15,3676           62015                           DAD      INCR,1                                #  PLUS
041963,000130: 15,3677           00027                                    GTMP                                  #  (B0**2+B1**2)**1/2 SIN(X+PHIB)
041964,000131: 15,3700           77771                           DEC      -6         B-14                       
041965,000132: 15,3701           00027                           STORE    GTMP                                  #  OR (C0**2+C1**2)**1/2 SIN(X+PHIC)
041966,000133: 15,3702           77614                           BOFSET                                         
041967,000134: 15,3703           00054                                    FREEFLAG                              
041968,000135: 15,3704           33666                                    POSITB                                
041969,000136: 15,3705           40745        POSITD             DLOAD    DMP*                                  
041970,000137: 15,3706           00031                                    TIMEP                                 #  T
041971,000138: 15,3707           65747                                    RATESP,2                              #  LOMR,LOSR,LONR
041972,000139: 15,3710           42661                           SL       DAD*                                  
041973,000140: 15,3711           20206                                    5D                                    
041974,000141: 15,3712           65741                                    RATESP     +6,2                       #  LOMO,LOSO,LONO
041975,000142: 15,3713           77625                           DSU                                            
041976,000143: 15,3714           00027                                    GTMP                                  
041977,000144: 15,3715           10021                           STORE    STMP,2                                #  LOM,LOS,LON
041978,000145: 15,3716           63135                           SLOAD    INCR,2                                
041979,000146: 15,3717           00050                                    X2                                    
041980,000147: 15,3720           77775                           DEC      -2         B-14                       
041981,000148: 15,3721           53015                           DAD      BZE                                   
041982,000149: 15,3722           12026                                    RCB-13                                #  PLUS 2
041983,000150: 15,3723           33753                                    POSITE                                #  2ND
041984,000151: 15,3724           77644                           BPL                                            
041985,000152: 15,3725           33663                                    POSITA                                #  1ST
041986,000153: 15,3726           45345        POSITF             DLOAD    DSU                                   #  3RD
041987,000154: 15,3727           00021                                    STMP                                  #  LOM
041988,000155: 15,3730           00025                                    STMP       +4                         #  LON
041989,000156: 15,3731           65356                           SIN      PDDL                                  #  SIN(LOM-LON)
041990,000157: 15,3732           00021                                    STMP                                  
041991,000158: 15,3733           65356                           SIN      PDDL                                  #  SIN LOM
041992,000159: 15,3734           00021                                    STMP                                  
041993,000160: 15,3735           55546                           COS      VDEF                                  #  COS LOM
041994,000161: 15,3736           53521                           MXV      UNIT                                  
041995,000162: 15,3737           12002                                    KONMAT                                #  K1,K2,K3,K4,
041996,000163: 15,3740           02723                           STORE    VMOON                                 
041997,000164: 15,3741           65345                           DLOAD    PDDL                                  
041998,000165: 15,3742           12004                                    KONMAT     +2                         #  ZERO
041999,000166: 15,3743           00023                                    STMP       +2                         
042000,000167: 15,3744           65356                           SIN      PDDL                                  #  SIN LOS
042001,000168: 15,3745           00023                                    STMP       +2                         
042002,000169: 15,3746           55546                           COS      VDEF                                  #  COS LOS
042003,000170: 15,3747           53521                           MXV      UNIT                                  
042004,000171: 15,3750           12002                                    KONMAT                                
042005,000172: 15,3751           02715                           STORE    VSUN                                  
042006,000173: 15,3752           77616                           RVQ                                            

Page 981

042008,000175: 15,3753           77745        POSITE             DLOAD                                          
042009,000176: 15,3754           12004                                    KONMAT     +2                         #  ZEROS
042010,000177: 15,3755           00027                           STORE    GTMP                                  
042011,000178: 15,3756           77650                           GOTO                                           
042012,000179: 15,3757           33705                                    POSITD                                
042013,000180: 05,2000                                           SETLOC   EPHEM1                                
042014,000181: 05,2000                                           BANK                                           
042015,000182: 
042016,000183: 05,3505                                           COUNT*   $$/EPHEM                              
042017,000184: 05,3505                        STMP               EQUALS   16D                                   
042018,000185: 05,3505                        GTMP               EQUALS   22D                                   
042019,000186: 05,3505                        TIMEP              EQUALS   24D                                   
042020,000187: 

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