Source Code

These source-code files are part of a reconstructed copy of Comanche 45/2 (AKA Manche45 revision 2), the final, flown mission release of the Apollo 10 Command Module (CM) Apollo Guidance Computer (AGC) software. Comanche 45/2 was preceded by Comanche 44 and Comanche 45. The reconstruction is believed to be exactly accurate, but in the absence of an actual Apollo-era listing of Comanche 45/2, some explanation of the reconstruction process is needed to insure confidence in that accuracy.

The starting point was the source code of Comanche 45 (itself previously accurately reconstructed). Comanche 45 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 45 and 45/2. The now-reconstructed Comanche 45/2 source code was verified by assembling it and checking that the assembled code had the expected known-correct memory-bank checksums. Note that page numbers in the reconstructed code tend to match those in the Comanche 55, the most-similar revision of Comanche for which we have access to an actual non-reconstructed hardcopy; the source code would likely have different page numbers in a contemporary Comanche 45 listing.

Annotations that were not present in the contemporary source code have been added to the reconstructed code to justify each change relative to Comanche 44. Here's a guide to the Apollo documentation referenced in those annotations:
Comments expected to have been present in 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.

034284,000002:                                                                                                  ## Copyright:   Public domain.
034285,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
034286,000004:                                                                                                  ## Purpose:     A section of Manche45 revision 2.
034287,000005:                                                                                                  ##              It is part of the reconstructed source code for the
034288,000006:                                                                                                  ##              final, flown release of the flight software for the Command
034289,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
034290,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
034291,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
034292,000010:                                                                                                  ##              exactly match those specified for Manche 45/2 in NASA drawing
034293,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
034294,000012:                                                                                                  ##              reconstruction is correct.
034295,000013:                                                                                                  ## Assembler:   yaYUL
034296,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
034297,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
034298,000016:                                                                                                  ## Mod history: 2020-12-24 MAS  Created from Comanche 45.
034299,000017: 

Page 785

034301,000019:                                                                                                  #  LUNAR AND SOLAR EPHEMERIDES SUBROUTINES
034302,000020: 
034303,000021:                                                                                                  #  FUNCTIONAL DESCRIPTION
034304,000022: 
034305,000023:                                                                                                  #        THESE SUBROUTINES ARE USED TO DETERMINE THE POSITION AND VELOCITY
034306,000024:                                                                                                  #        VECTORS OF THE SUN AND THE MOON RELATIVE TO THE EARTH AT THE
034307,000025:                                                                                                  #        SPECIFIED GROUND ELAPSED TIME INPUT BY THE USER.
034308,000026: 
034309,000027:                                                                                                  #        THE POSITION OF THE MOON IS STORED IN THE COMPUTER IN THE FORM OF
034310,000028:                                                                                                  #        A NINTH DEGREE POLYNOMIAL APPROXIMATION WHICH IS VALID OVER A 15
034311,000029:                                                                                                  #        DAY INTERVAL BEGINNING SHORTLY BEFORE LAUNCH.  THEREFORE THE TIME
034312,000030:                                                                                                  #        INPUT BY THE USER SHOULD FALL WITHIN THIS 15 DAY INTERVAL.

The 9th-degree polynomial spoken of here is a pad load, meaning that it is not actually hardcoded into the software. Additional information about calculating the polynomial can be found on the Orbiter NASSP wiki, as well as information about calculation of the solar ephemerides.

034320,000038: 
034321,000039:                                                                                                  #        LSPOS COMPUTES THE POSITION VECTORS OF THE SUN AND THE MOON.
034322,000040: 
034323,000041:                                                                                                  #        LUNPOS COMPUTES THE POSITION VECTOR OF THE MOON.
034324,000042: 
034325,000043:                                                                                                  #        LUNVEL COMPUTES THE VELOCITY VECTOR OF THE MOON.
034326,000044: 
034327,000045:                                                                                                  #        SOLPOS COMPUTES THE POSITION VECTOR OF THE SUN.
034328,000046: 
034329,000047:                                                                                                  #  CALLING SEQUENCE
034330,000048: 
034331,000049:                                                                                                  #        DLOAD   CALL
034332,000050:                                                                                                  #                TIME            GROUND ELAPSED TIME
034333,000051:                                                                                                  #                SUBROUTINE      LSPOS OR LUNPOS OR LUNVEL OR SOLPOS
034334,000052: 
034335,000053:                                                                                                  #  INPUT
034336,000054: 
034337,000055:                                                                                                  #        1) SPECIFIED GROUND ELAPSED TIME IN CS X B-28 LOADED IN MPAC.
034338,000056: 
034339,000057:                                                                                                  #        2) TIMEMO - TIME AT THE CENTER OF THE RANGE OVER WHICH THE LUNAR
034340,000058:                                                                                                  #        POSITION POLYNOMIAL IS VALID IN CS X B-42.
034341,000059: 
034342,000060:                                                                                                  #        3) VECOEM - VECTOR COEFFICIENTS OF THE LUNAR POSITION POLYNOMIAL
034343,000061:                                                                                                  #        LOADED IN DESCENDING SEQUENCE IN METERS/CS**N X B-2
034344,000062: 
034345,000063:                                                                                                  #        4) RESO - POSITION VECTOR OF THE SUN RELATIVE TO THE EARTH AT
034346,000064:                                                                                                  #        TIMEMO IN METERS X B-38.
034347,000065: 
034348,000066:                                                                                                  #        5) VESO - VELOCITY VECTOR OF THE SUN RELATIVE TO THE EARTH AT
034349,000067:                                                                                                  #        TIMEMO IN METERS/CS X B-9.
034350,000068:                                                                                                  #  
034351,000069:                                                                                                  #        6) OMEGAES - ANGULAR VELOCITY OF THE VECTOR RESO AT TIMEMO IN
034352,000070:                                                                                                  #        REV/CS X B+26.
034353,000071: 
034354,000072:                                                                                                  #        ALL EXCEPT THE FIRST INPUT ARE INCLUDED IN THE PRE-LAUNCH
034355,000073:                                                                                                  #        ERASABLE DATA LOAD.
034356,000074: 
034357,000075:                                                                                                  #  OUTPUT - LSPOS

Page 786

034359,000077: 
034360,000078:                                                                                                  #        1) 2D OF VAC AREA CONTAINS THE POSITION VECTOR OF THE SUN RELATIVE
034361,000079:                                                                                                  #        TO THE EARTH AT TIME INPUT BY THE USER IN METERS X B-38.
034362,000080: 
034363,000081:                                                                                                  #        2) MPAC CONTAINS THE POSITION VECTOR OF THE MOON RELATIVE TO THE
034364,000082:                                                                                                  #        EARTH AT TIME INPUT BY THE USER IN METERS X B-29.
034365,000083: 
034366,000084:                                                                                                  #  OUTPUT - LUNPOS
034367,000085: 
034368,000086:                                                                                                  #        MPAC CONTAINS THE POSITION VECTOR OF THE MOON RELATIVE TO THE
034369,000087:                                                                                                  #        EARTH AT THE TIME INPUT BY USER IN METERS X B-29.
034370,000088: 
034371,000089:                                                                                                  #  OUTPUT - LUNVEL
034372,000090: 
034373,000091:                                                                                                  #        MPAC CONTAINS THE VELOCITY VECTOR OF THE MOON RELATIVE TO THE
034374,000092:                                                                                                  #        EARTH AT TIME INPUT BY THE USER IN METERS/CS X B-7.
034375,000093: 
034376,000094:                                                                                                  #  OUTPUT - SOLPOS
034377,000095: 
034378,000096:                                                                                                  #        MPAC CONTAINS THE POSITION VECTOR OF THE SUN RELATIVE TO THE EARTH
034379,000097:                                                                                                  #        AT TIME INPUT BY THE USER IN METERS X B-38.
034380,000098: 
034381,000099:                                                                                                  #  SUBROUTINES USED
034382,000100: 
034383,000101:                                                                                                  #        NONE
034384,000102: 
034385,000103:                                                                                                  #  REMARKS
034386,000104: 
034387,000105:                                                                                                  #        THE VAC AREA IS USED FOR STORAGE OF INTERMEDIATE AND FINAL RESULTS
034388,000106:                                                                                                  #        OF COMPUTATIONS.
034389,000107: 
034390,000108:                                                                                                  #        S1, X1 AND X2 ARE USED BY THESE SUBROUTINES.
034391,000109: 
034392,000110:                                                                                                  #        PRELAUNCH ERASABLE DATA LOAD ARE ONLY ERASABLE STORAGE USED BY
034393,000111:                                                                                                  #        THESE SUBROUTINES.
034394,000112: 
034395,000113:                                                                                                  #        RESTARTS DURING OPERATION OF THESE SUBROUTINES MUST BE HANDLED BY
034396,000114:                                                                                                  #        THE USER.
034397,000115: 
034398,000116: 36,2454                                           BANK     36                                    
034399,000117: 26,2000                                           SETLOC   EPHEM                                 
034400,000118: 26,2000                                           BANK                                           
034401,000119: 
034402,000120: 26,2110                                           COUNT*   $$/EPHEM                              
034403,000121: 26,2110  E7,1777                                  EBANK=   END-E7                                
034404,000122: 26,2110           77774        LSPOS              AXT,2                                          #  COMPUTES POSITION VECTORS OF BOTH THE
034405,000123: 26,2111           54161                                    RESA                                  #  SUN AND THE MOON.  THE POSITION VECTOR
034406,000124: 26,2112           52170                           AXT,1    GOTO                                  #  OF THE SUN IS STORED IN 2D OF THE VAC
034407,000125: 26,2113           54143                                    RES                                   #  AREA.  THE POSITION VECTOR OF THE MOON
034408,000126: 26,2114           54126                                    LSTIME                                #  IS STORED IN MPAC.
034409,000127: 26,2115           52170        LUNPOS             AXT,1    GOTO                                  #  COMPUTES THE POSITION VECTOR OF THE MOON
034410,000128: 26,2116           54162                                    REM                                   #  AND STORES IT IN MPAC.
034411,000129: 26,2117           54126                                    LSTIME                                

Page 787

034413,000131: 26,2120           52170        LUNVEL             AXT,1    GOTO                                  #  COMPUTES THE VELOCITY VECTOR OF THE MOON
034414,000132: 26,2121           54173                                    VEM                                   #  AND STORES IT IN MPAC.
034415,000133: 26,2122           54126                                    LSTIME                                
034416,000134: 26,2123           76020        SOLPOS             STQ      AXT,1                                 #  COMPUTES THE POSITION VECTOR OF THE SUN
034417,000135: 26,2124           00047                                    X2                                    #  AND STORES IT IN MPAC.
034418,000136: 26,2125           54143                                    RES                                   
034419,000137: 26,2126           54201        LSTIME             SETPD    SR                                    
034420,000138: 26,2127           00001                                    0D                                    
034421,000139: 26,2130           20617                                    14D                                   
034422,000140: 26,2131           57571                           TAD      DCOMP                                 
034423,000141: 26,2132           01707                                    TEPHEM                                
034424,000142: 26,2133           57571                           TAD      DCOMP                                 
034425,000143: 26,2134           02034                                    TIMEMO                                
034426,000144: 26,2135           66261                           SL       SSP                                   
034427,000145: 26,2136           20221                                    16D                                   
034428,000146: 26,2137           00051                                    S1                                    
034429,000147: 26,2140           00006                                    6D                                    
034430,000148: 26,2141           77650                           GOTO                                           
034431,000149: 26,2142           00046                                    X1                                    
034432,000150: 26,2143           41206        RES                PUSH     DMP                                   #                                        PD- 2
034433,000151: 26,2144           02147                                    OMEGAES                               
034434,000152: 26,2145           71406                           PUSH     COS                                   #                                        PD- 4
034435,000153: 26,2146           65361                           VXSC     PDDL                                  #                                        PD- 8
034436,000154: 26,2147           02133                                    RESO                                  
034437,000155: 26,2150           63356                           SIN      PDVL                                  #                                        PD-10
034438,000156: 26,2151           02133                                    RESO                                  
034439,000157: 26,2152           53406                           PUSH     UNIT                                  #                                        PD-16
034440,000158: 26,2153           53435                           VXV      UNIT                                  
034441,000159: 26,2154           02141                                    VESO                                  
034442,000160: 26,2155           76435                           VXV      VSL1                                  #                                        PD-10
034443,000161: 26,2156           53361                           VXSC     VAD                                   #                                        PD-02
034444,000162: 26,2157           52172                           VSL1     GOTO                                  #  RES IN METERS X B-38 IN MPAC.
034445,000163: 26,2160           00047                                    X2                                    
034446,000164: 26,2161           14003        RESA               STODL    2D                                    #  RES IN METERS X B-38 IN 2D OF VAC.    PD- 0
034447,000165: 26,2162           63370        REM                AXT,1    PDVL                                  #                                        PD- 2
034448,000166: 26,2163           00066                                    54D                                   
034449,000167: 26,2164           02037                                    VECOEM                                
034450,000168: 26,2165           52761        REMA               VXSC     VAD*                                  
034451,000169: 26,2166           00001                                    0D                                    
034452,000170: 26,2167           02133                                    VECOEM     +60D,1                     
034453,000171: 26,2170           72500                           TIX,1    VSL2                                  #  REM IN METERS X B-29 IN MPAC.
034454,000172: 26,2171           54165                                    REMA                                  
034455,000173: 26,2172           77616                           RVQ                                            
034456,000174: 26,2173           65370        VEM                AXT,1    PDDL                                  #                                        PD- 2
034457,000175: 26,2174           00060                                    48D                                   
034458,000176: 26,2175           14214                                    NINEB4                                
034459,000177: 26,2176           74206                           PUSH     VXSC                                  #                                        PD- 4
034460,000178: 26,2177           02037                                    VECOEM                                
034461,000179: 26,2200           77761        VEMA               VXSC                                           
034462,000180: 26,2201           00001                                    0D                                    

Page 788

034464,000182: 26,2202           14005                           STODL    4D                                    #                                        PD- 2
034465,000183: 26,2203           41425                           DSU      PUSH                                  #                                        PD- 4
034466,000184: 26,2204           14216                                    ONEB4                                 
034467,000185: 26,2205           53357                           VXSC*    VAD                                   
034468,000186: 26,2206           02125                                    VECOEM     +54D,1                     
034469,000187: 26,2207           00005                                    4D                                    
034470,000188: 26,2210           72500                           TIX,1    VSL2                                  #  VEM IN METERS/CS X B-7 IN MPAC.
034471,000189: 26,2211           54200                                    VEMA                                  
034472,000190: 26,2212           77616                           RVQ                                            
034473,000191: 26,2213           22000 00000  NINEB4             2DEC     9.0        B-4                        
034474,000192: 
034475,000193: 26,2215           02000 00000  ONEB4              2DEC     1.0        B-4                        
034476,000194: 
034477,000195: 
034478,000196: 

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