Source Code

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

The starting point was the source code of Comanche 44 (itself previously accurately reconstructed). Comanche 44 source code was then modified by incorporating changes known from contemporary documentation to have been made between revisions 44 and 45. The now-reconstructed Comanche 45 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:
There is also a detailed commentary about the reconstruction process.

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.

034337,000002:                                                                                                  ## Copyright:   Public domain.
034338,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
034339,000004:                                                                                                  ## Purpose:     A section of Comanche revision 045.
034340,000005:                                                                                                  ##              It is part of the reconstructed source code for the
034341,000006:                                                                                                  ##              second release of the flight software for the Command
034342,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
034343,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
034344,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
034345,000010:                                                                                                  ##              exactly match those specified for Comanche 45 in NASA drawing
034346,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
034347,000012:                                                                                                  ##              reconstruction is correct.
034348,000013:                                                                                                  ## Assembler:   yaYUL
034349,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
034350,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
034351,000016:                                                                                                  ## Mod history: 2020-12-06 MAS  Created from Comanche 44.
034352,000017: 

Page 785

034354,000019:                                                                                                  #  LUNAR AND SOLAR EPHEMERIDES SUBROUTINES
034355,000020: 
034356,000021:                                                                                                  #  FUNCTIONAL DESCRIPTION
034357,000022: 
034358,000023:                                                                                                  #        THESE SUBROUTINES ARE USED TO DETERMINE THE POSITION AND VELOCITY
034359,000024:                                                                                                  #        VECTORS OF THE SUN AND THE MOON RELATIVE TO THE EARTH AT THE
034360,000025:                                                                                                  #        SPECIFIED GROUND ELAPSED TIME INPUT BY THE USER.
034361,000026: 
034362,000027:                                                                                                  #        THE POSITION OF THE MOON IS STORED IN THE COMPUTER IN THE FORM OF
034363,000028:                                                                                                  #        A NINTH DEGREE POLYNOMIAL APPROXIMATION WHICH IS VALID OVER A 15
034364,000029:                                                                                                  #        DAY INTERVAL BEGINNING SHORTLY BEFORE LAUNCH.  THEREFORE THE TIME
034365,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.

034373,000038: 
034374,000039:                                                                                                  #        LSPOS COMPUTES THE POSITION VECTORS OF THE SUN AND THE MOON.
034375,000040: 
034376,000041:                                                                                                  #        LUNPOS COMPUTES THE POSITION VECTOR OF THE MOON.
034377,000042: 
034378,000043:                                                                                                  #        LUNVEL COMPUTES THE VELOCITY VECTOR OF THE MOON.
034379,000044: 
034380,000045:                                                                                                  #        SOLPOS COMPUTES THE POSITION VECTOR OF THE SUN.
034381,000046: 
034382,000047:                                                                                                  #  CALLING SEQUENCE
034383,000048: 
034384,000049:                                                                                                  #        DLOAD   CALL
034385,000050:                                                                                                  #                TIME            GROUND ELAPSED TIME
034386,000051:                                                                                                  #                SUBROUTINE      LSPOS OR LUNPOS OR LUNVEL OR SOLPOS
034387,000052: 
034388,000053:                                                                                                  #  INPUT
034389,000054: 
034390,000055:                                                                                                  #        1) SPECIFIED GROUND ELAPSED TIME IN CS X B-28 LOADED IN MPAC.
034391,000056: 
034392,000057:                                                                                                  #        2) TIMEMO - TIME AT THE CENTER OF THE RANGE OVER WHICH THE LUNAR
034393,000058:                                                                                                  #        POSITION POLYNOMIAL IS VALID IN CS X B-42.
034394,000059: 
034395,000060:                                                                                                  #        3) VECOEM - VECTOR COEFFICIENTS OF THE LUNAR POSITION POLYNOMIAL
034396,000061:                                                                                                  #        LOADED IN DESCENDING SEQUENCE IN METERS/CS**N X B-2
034397,000062: 
034398,000063:                                                                                                  #        4) RESO - POSITION VECTOR OF THE SUN RELATIVE TO THE EARTH AT
034399,000064:                                                                                                  #        TIMEMO IN METERS X B-38.
034400,000065: 
034401,000066:                                                                                                  #        5) VESO - VELOCITY VECTOR OF THE SUN RELATIVE TO THE EARTH AT
034402,000067:                                                                                                  #        TIMEMO IN METERS/CS X B-9.
034403,000068:                                                                                                  #  
034404,000069:                                                                                                  #        6) OMEGAES - ANGULAR VELOCITY OF THE VECTOR RESO AT TIMEMO IN
034405,000070:                                                                                                  #        REV/CS X B+26.
034406,000071: 
034407,000072:                                                                                                  #        ALL EXCEPT THE FIRST INPUT ARE INCLUDED IN THE PRE-LAUNCH
034408,000073:                                                                                                  #        ERASABLE DATA LOAD.
034409,000074: 
034410,000075:                                                                                                  #  OUTPUT - LSPOS

Page 786

034412,000077: 
034413,000078:                                                                                                  #        1) 2D OF VAC AREA CONTAINS THE POSITION VECTOR OF THE SUN RELATIVE
034414,000079:                                                                                                  #        TO THE EARTH AT TIME INPUT BY THE USER IN METERS X B-38.
034415,000080: 
034416,000081:                                                                                                  #        2) MPAC CONTAINS THE POSITION VECTOR OF THE MOON RELATIVE TO THE
034417,000082:                                                                                                  #        EARTH AT TIME INPUT BY THE USER IN METERS X B-29.
034418,000083: 
034419,000084:                                                                                                  #  OUTPUT - LUNPOS
034420,000085: 
034421,000086:                                                                                                  #        MPAC CONTAINS THE POSITION VECTOR OF THE MOON RELATIVE TO THE
034422,000087:                                                                                                  #        EARTH AT THE TIME INPUT BY USER IN METERS X B-29.
034423,000088: 
034424,000089:                                                                                                  #  OUTPUT - LUNVEL
034425,000090: 
034426,000091:                                                                                                  #        MPAC CONTAINS THE VELOCITY VECTOR OF THE MOON RELATIVE TO THE
034427,000092:                                                                                                  #        EARTH AT TIME INPUT BY THE USER IN METERS/CS X B-7.
034428,000093: 
034429,000094:                                                                                                  #  OUTPUT - SOLPOS
034430,000095: 
034431,000096:                                                                                                  #        MPAC CONTAINS THE POSITION VECTOR OF THE SUN RELATIVE TO THE EARTH
034432,000097:                                                                                                  #        AT TIME INPUT BY THE USER IN METERS X B-38.
034433,000098: 
034434,000099:                                                                                                  #  SUBROUTINES USED
034435,000100: 
034436,000101:                                                                                                  #        NONE
034437,000102: 
034438,000103:                                                                                                  #  REMARKS
034439,000104: 
034440,000105:                                                                                                  #        THE VAC AREA IS USED FOR STORAGE OF INTERMEDIATE AND FINAL RESULTS
034441,000106:                                                                                                  #        OF COMPUTATIONS.
034442,000107: 
034443,000108:                                                                                                  #        S1, X1 AND X2 ARE USED BY THESE SUBROUTINES.
034444,000109: 
034445,000110:                                                                                                  #        PRELAUNCH ERASABLE DATA LOAD ARE ONLY ERASABLE STORAGE USED BY
034446,000111:                                                                                                  #        THESE SUBROUTINES.
034447,000112: 
034448,000113:                                                                                                  #        RESTARTS DURING OPERATION OF THESE SUBROUTINES MUST BE HANDLED BY
034449,000114:                                                                                                  #        THE USER.
034450,000115: 
034451,000116: 36,2454                                           BANK     36                                    
034452,000117: 26,2000                                           SETLOC   EPHEM                                 
034453,000118: 26,2000                                           BANK                                           
034454,000119: 
034455,000120: 26,2110                                           COUNT*   $$/EPHEM                              
034456,000121: 26,2110  E7,1777                                  EBANK=   END-E7                                
034457,000122: 26,2110           77774        LSPOS              AXT,2                                          #  COMPUTES POSITION VECTORS OF BOTH THE
034458,000123: 26,2111           54161                                    RESA                                  #  SUN AND THE MOON.  THE POSITION VECTOR
034459,000124: 26,2112           52170                           AXT,1    GOTO                                  #  OF THE SUN IS STORED IN 2D OF THE VAC
034460,000125: 26,2113           54143                                    RES                                   #  AREA.  THE POSITION VECTOR OF THE MOON
034461,000126: 26,2114           54126                                    LSTIME                                #  IS STORED IN MPAC.
034462,000127: 26,2115           52170        LUNPOS             AXT,1    GOTO                                  #  COMPUTES THE POSITION VECTOR OF THE MOON
034463,000128: 26,2116           54162                                    REM                                   #  AND STORES IT IN MPAC.
034464,000129: 26,2117           54126                                    LSTIME                                

Page 787

034466,000131: 26,2120           52170        LUNVEL             AXT,1    GOTO                                  #  COMPUTES THE VELOCITY VECTOR OF THE MOON
034467,000132: 26,2121           54173                                    VEM                                   #  AND STORES IT IN MPAC.
034468,000133: 26,2122           54126                                    LSTIME                                
034469,000134: 26,2123           76020        SOLPOS             STQ      AXT,1                                 #  COMPUTES THE POSITION VECTOR OF THE SUN
034470,000135: 26,2124           00047                                    X2                                    #  AND STORES IT IN MPAC.
034471,000136: 26,2125           54143                                    RES                                   
034472,000137: 26,2126           54201        LSTIME             SETPD    SR                                    
034473,000138: 26,2127           00001                                    0D                                    
034474,000139: 26,2130           20617                                    14D                                   
034475,000140: 26,2131           57571                           TAD      DCOMP                                 
034476,000141: 26,2132           01707                                    TEPHEM                                
034477,000142: 26,2133           57571                           TAD      DCOMP                                 
034478,000143: 26,2134           02034                                    TIMEMO                                
034479,000144: 26,2135           66261                           SL       SSP                                   
034480,000145: 26,2136           20221                                    16D                                   
034481,000146: 26,2137           00051                                    S1                                    
034482,000147: 26,2140           00006                                    6D                                    
034483,000148: 26,2141           77650                           GOTO                                           
034484,000149: 26,2142           00046                                    X1                                    
034485,000150: 26,2143           41206        RES                PUSH     DMP                                   #                                        PD- 2
034486,000151: 26,2144           02147                                    OMEGAES                               
034487,000152: 26,2145           71406                           PUSH     COS                                   #                                        PD- 4
034488,000153: 26,2146           65361                           VXSC     PDDL                                  #                                        PD- 8
034489,000154: 26,2147           02133                                    RESO                                  
034490,000155: 26,2150           63356                           SIN      PDVL                                  #                                        PD-10
034491,000156: 26,2151           02133                                    RESO                                  
034492,000157: 26,2152           53406                           PUSH     UNIT                                  #                                        PD-16
034493,000158: 26,2153           53435                           VXV      UNIT                                  
034494,000159: 26,2154           02141                                    VESO                                  
034495,000160: 26,2155           76435                           VXV      VSL1                                  #                                        PD-10
034496,000161: 26,2156           53361                           VXSC     VAD                                   #                                        PD-02
034497,000162: 26,2157           52172                           VSL1     GOTO                                  #  RES IN METERS X B-38 IN MPAC.
034498,000163: 26,2160           00047                                    X2                                    
034499,000164: 26,2161           14003        RESA               STODL    2D                                    #  RES IN METERS X B-38 IN 2D OF VAC.    PD- 0
034500,000165: 26,2162           63370        REM                AXT,1    PDVL                                  #                                        PD- 2
034501,000166: 26,2163           00066                                    54D                                   
034502,000167: 26,2164           02037                                    VECOEM                                
034503,000168: 26,2165           52761        REMA               VXSC     VAD*                                  
034504,000169: 26,2166           00001                                    0D                                    
034505,000170: 26,2167           02133                                    VECOEM     +60D,1                     
034506,000171: 26,2170           72500                           TIX,1    VSL2                                  #  REM IN METERS X B-29 IN MPAC.
034507,000172: 26,2171           54165                                    REMA                                  
034508,000173: 26,2172           77616                           RVQ                                            
034509,000174: 26,2173           65370        VEM                AXT,1    PDDL                                  #                                        PD- 2
034510,000175: 26,2174           00060                                    48D                                   
034511,000176: 26,2175           14214                                    NINEB4                                
034512,000177: 26,2176           74206                           PUSH     VXSC                                  #                                        PD- 4
034513,000178: 26,2177           02037                                    VECOEM                                
034514,000179: 26,2200           77761        VEMA               VXSC                                           
034515,000180: 26,2201           00001                                    0D                                    

Page 788

034517,000182: 26,2202           14005                           STODL    4D                                    #                                        PD- 2
034518,000183: 26,2203           41425                           DSU      PUSH                                  #                                        PD- 4
034519,000184: 26,2204           14216                                    ONEB4                                 
034520,000185: 26,2205           53357                           VXSC*    VAD                                   
034521,000186: 26,2206           02125                                    VECOEM     +54D,1                     
034522,000187: 26,2207           00005                                    4D                                    
034523,000188: 26,2210           72500                           TIX,1    VSL2                                  #  VEM IN METERS/CS X B-7 IN MPAC.
034524,000189: 26,2211           54200                                    VEMA                                  
034525,000190: 26,2212           77616                           RVQ                                            
034526,000191: 26,2213           22000 00000  NINEB4             2DEC     9.0        B-4                        
034527,000192: 
034528,000193: 26,2215           02000 00000  ONEB4              2DEC     1.0        B-4                        
034529,000194: 
034530,000195: 
034531,000196: 

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