Source Code

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

The starting point was the source code of Comanche 51 (separately previously reconstructed from an Apollo-era listing of Comanche 55, flown on Apollo 11). Comanche 51 source code was then modified by undoing changes known to have been made between revisions 44 and 51. The now-reconstructed Comanche 44 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 match those on the Comanche 55 printout, although the source code would likely have different page numbers in a contemporary Comanche 44 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 51. Here's a guide to the Apollo documentation referenced in those annotations:
In most cases, only the titles (rather than the full texts) of PCRs are known. In addition to the explanatory annotations, there is also a step-by-step 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.

034789,000002:                                                                                                  ## Copyright:   Public domain.
034790,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
034791,000004:                                                                                                  ## Purpose:     A section of Comanche revision 044.
034792,000005:                                                                                                  ##              It is part of the reconstructed source code for the
034793,000006:                                                                                                  ##              original release of the flight software for the Command
034794,000007:                                                                                                  ##              Module's (CM) Apollo Guidance Computer (AGC) for Apollo 10.
034795,000008:                                                                                                  ##              The code has been recreated from a copy of Comanche 055. It
034796,000009:                                                                                                  ##              has been adapted such that the resulting bugger words
034797,000010:                                                                                                  ##              exactly match those specified for Comanche 44 in NASA drawing
034798,000011:                                                                                                  ##              2021153D, which gives relatively high confidence that the
034799,000012:                                                                                                  ##              reconstruction is correct.
034800,000013:                                                                                                  ## Assembler:   yaYUL
034801,000014:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
034802,000015:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
034803,000016:                                                                                                  ## Mod history: 2020-12-03 MAS  Created from Comanche 51.
034804,000017: 

Page 785

034806,000019:                                                                                                  #  LUNAR AND SOLAR EPHEMERIDES SUBROUTINES
034807,000020: 
034808,000021:                                                                                                  #  FUNCTIONAL DESCRIPTION
034809,000022: 
034810,000023:                                                                                                  #        THESE SUBROUTINES ARE USED TO DETERMINE THE POSITION AND VELOCITY
034811,000024:                                                                                                  #        VECTORS OF THE SUN AND THE MOON RELATIVE TO THE EARTH AT THE
034812,000025:                                                                                                  #        SPECIFIED GROUND ELAPSED TIME INPUT BY THE USER.
034813,000026: 
034814,000027:                                                                                                  #        THE POSITION OF THE MOON IS STORED IN THE COMPUTER IN THE FORM OF
034815,000028:                                                                                                  #        A NINTH DEGREE POLYNOMIAL APPROXIMATION WHICH IS VALID OVER A 15
034816,000029:                                                                                                  #        DAY INTERVAL BEGINNING SHORTLY BEFORE LAUNCH.  THEREFORE THE TIME
034817,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.

034825,000038: 
034826,000039:                                                                                                  #        LSPOS COMPUTES THE POSITION VECTORS OF THE SUN AND THE MOON.
034827,000040: 
034828,000041:                                                                                                  #        LUNPOS COMPUTES THE POSITION VECTOR OF THE MOON.
034829,000042: 
034830,000043:                                                                                                  #        LUNVEL COMPUTES THE VELOCITY VECTOR OF THE MOON.
034831,000044: 
034832,000045:                                                                                                  #        SOLPOS COMPUTES THE POSITION VECTOR OF THE SUN.
034833,000046: 
034834,000047:                                                                                                  #  CALLING SEQUENCE
034835,000048: 
034836,000049:                                                                                                  #        DLOAD   CALL
034837,000050:                                                                                                  #                TIME            GROUND ELAPSED TIME
034838,000051:                                                                                                  #                SUBROUTINE      LSPOS OR LUNPOS OR LUNVEL OR SOLPOS
034839,000052: 
034840,000053:                                                                                                  #  INPUT
034841,000054: 
034842,000055:                                                                                                  #        1) SPECIFIED GROUND ELAPSED TIME IN CS X B-28 LOADED IN MPAC.
034843,000056: 
034844,000057:                                                                                                  #        2) TIMEMO - TIME AT THE CENTER OF THE RANGE OVER WHICH THE LUNAR
034845,000058:                                                                                                  #        POSITION POLYNOMIAL IS VALID IN CS X B-42.
034846,000059: 
034847,000060:                                                                                                  #        3) VECOEM - VECTOR COEFFICIENTS OF THE LUNAR POSITION POLYNOMIAL
034848,000061:                                                                                                  #        LOADED IN DESCENDING SEQUENCE IN METERS/CS**N X B-2
034849,000062: 
034850,000063:                                                                                                  #        4) RESO - POSITION VECTOR OF THE SUN RELATIVE TO THE EARTH AT
034851,000064:                                                                                                  #        TIMEMO IN METERS X B-38.
034852,000065: 
034853,000066:                                                                                                  #        5) VESO - VELOCITY VECTOR OF THE SUN RELATIVE TO THE EARTH AT
034854,000067:                                                                                                  #        TIMEMO IN METERS/CS X B-9.
034855,000068:                                                                                                  #  
034856,000069:                                                                                                  #        6) OMEGAES - ANGULAR VELOCITY OF THE VECTOR RESO AT TIMEMO IN
034857,000070:                                                                                                  #        REV/CS X B+26.
034858,000071: 
034859,000072:                                                                                                  #        ALL EXCEPT THE FIRST INPUT ARE INCLUDED IN THE PRE-LAUNCH
034860,000073:                                                                                                  #        ERASABLE DATA LOAD.
034861,000074: 
034862,000075:                                                                                                  #  OUTPUT - LSPOS

Page 786

034864,000077: 
034865,000078:                                                                                                  #        1) 2D OF VAC AREA CONTAINS THE POSITION VECTOR OF THE SUN RELATIVE
034866,000079:                                                                                                  #        TO THE EARTH AT TIME INPUT BY THE USER IN METERS X B-38.
034867,000080: 
034868,000081:                                                                                                  #        2) MPAC CONTAINS THE POSITION VECTOR OF THE MOON RELATIVE TO THE
034869,000082:                                                                                                  #        EARTH AT TIME INPUT BY THE USER IN METERS X B-29.
034870,000083: 
034871,000084:                                                                                                  #  OUTPUT - LUNPOS
034872,000085: 
034873,000086:                                                                                                  #        MPAC CONTAINS THE POSITION VECTOR OF THE MOON RELATIVE TO THE
034874,000087:                                                                                                  #        EARTH AT THE TIME INPUT BY USER IN METERS X B-29.
034875,000088: 
034876,000089:                                                                                                  #  OUTPUT - LUNVEL
034877,000090: 
034878,000091:                                                                                                  #        MPAC CONTAINS THE VELOCITY VECTOR OF THE MOON RELATIVE TO THE
034879,000092:                                                                                                  #        EARTH AT TIME INPUT BY THE USER IN METERS/CS X B-7.
034880,000093: 
034881,000094:                                                                                                  #  OUTPUT - SOLPOS
034882,000095: 
034883,000096:                                                                                                  #        MPAC CONTAINS THE POSITION VECTOR OF THE SUN RELATIVE TO THE EARTH
034884,000097:                                                                                                  #        AT TIME INPUT BY THE USER IN METERS X B-38.
034885,000098: 
034886,000099:                                                                                                  #  SUBROUTINES USED
034887,000100: 
034888,000101:                                                                                                  #        NONE
034889,000102: 
034890,000103:                                                                                                  #  REMARKS
034891,000104: 
034892,000105:                                                                                                  #        THE VAC AREA IS USED FOR STORAGE OF INTERMEDIATE AND FINAL RESULTS
034893,000106:                                                                                                  #        OF COMPUTATIONS.
034894,000107: 
034895,000108:                                                                                                  #        S1, X1 AND X2 ARE USED BY THESE SUBROUTINES.
034896,000109: 
034897,000110:                                                                                                  #        PRELAUNCH ERASABLE DATA LOAD ARE ONLY ERASABLE STORAGE USED BY
034898,000111:                                                                                                  #        THESE SUBROUTINES.
034899,000112: 
034900,000113:                                                                                                  #        RESTARTS DURING OPERATION OF THESE SUBROUTINES MUST BE HANDLED BY
034901,000114:                                                                                                  #        THE USER.
034902,000115: 
034903,000116: 36,2454                                           BANK     36                                    
034904,000117: 26,2000                                           SETLOC   EPHEM                                 
034905,000118: 26,2000                                           BANK                                           
034906,000119: 
034907,000120: 26,2110                                           COUNT*   $$/EPHEM                              
034908,000121: 26,2110  E7,1777                                  EBANK=   END-E7                                
034909,000122: 26,2110           77774        LSPOS              AXT,2                                          #  COMPUTES POSITION VECTORS OF BOTH THE
034910,000123: 26,2111           54161                                    RESA                                  #  SUN AND THE MOON.  THE POSITION VECTOR
034911,000124: 26,2112           52170                           AXT,1    GOTO                                  #  OF THE SUN IS STORED IN 2D OF THE VAC
034912,000125: 26,2113           54143                                    RES                                   #  AREA.  THE POSITION VECTOR OF THE MOON
034913,000126: 26,2114           54126                                    LSTIME                                #  IS STORED IN MPAC.
034914,000127: 26,2115           52170        LUNPOS             AXT,1    GOTO                                  #  COMPUTES THE POSITION VECTOR OF THE MOON
034915,000128: 26,2116           54162                                    REM                                   #  AND STORES IT IN MPAC.
034916,000129: 26,2117           54126                                    LSTIME                                

Page 787

034918,000131: 26,2120           52170        LUNVEL             AXT,1    GOTO                                  #  COMPUTES THE VELOCITY VECTOR OF THE MOON
034919,000132: 26,2121           54173                                    VEM                                   #  AND STORES IT IN MPAC.
034920,000133: 26,2122           54126                                    LSTIME                                
034921,000134: 26,2123           76020        SOLPOS             STQ      AXT,1                                 #  COMPUTES THE POSITION VECTOR OF THE SUN
034922,000135: 26,2124           00047                                    X2                                    #  AND STORES IT IN MPAC.
034923,000136: 26,2125           54143                                    RES                                   
034924,000137: 26,2126           54201        LSTIME             SETPD    SR                                    
034925,000138: 26,2127           00001                                    0D                                    
034926,000139: 26,2130           20617                                    14D                                   
034927,000140: 26,2131           57571                           TAD      DCOMP                                 
034928,000141: 26,2132           01707                                    TEPHEM                                
034929,000142: 26,2133           57571                           TAD      DCOMP                                 
034930,000143: 26,2134           02034                                    TIMEMO                                
034931,000144: 26,2135           66261                           SL       SSP                                   
034932,000145: 26,2136           20221                                    16D                                   
034933,000146: 26,2137           00051                                    S1                                    
034934,000147: 26,2140           00006                                    6D                                    
034935,000148: 26,2141           77650                           GOTO                                           
034936,000149: 26,2142           00046                                    X1                                    
034937,000150: 26,2143           41206        RES                PUSH     DMP                                   #                                        PD- 2
034938,000151: 26,2144           02147                                    OMEGAES                               
034939,000152: 26,2145           71406                           PUSH     COS                                   #                                        PD- 4
034940,000153: 26,2146           65361                           VXSC     PDDL                                  #                                        PD- 8
034941,000154: 26,2147           02133                                    RESO                                  
034942,000155: 26,2150           63356                           SIN      PDVL                                  #                                        PD-10
034943,000156: 26,2151           02133                                    RESO                                  
034944,000157: 26,2152           53406                           PUSH     UNIT                                  #                                        PD-16
034945,000158: 26,2153           53435                           VXV      UNIT                                  
034946,000159: 26,2154           02141                                    VESO                                  
034947,000160: 26,2155           76435                           VXV      VSL1                                  #                                        PD-10
034948,000161: 26,2156           53361                           VXSC     VAD                                   #                                        PD-02
034949,000162: 26,2157           52172                           VSL1     GOTO                                  #  RES IN METERS X B-38 IN MPAC.
034950,000163: 26,2160           00047                                    X2                                    
034951,000164: 26,2161           14003        RESA               STODL    2D                                    #  RES IN METERS X B-38 IN 2D OF VAC.    PD- 0
034952,000165: 26,2162           63370        REM                AXT,1    PDVL                                  #                                        PD- 2
034953,000166: 26,2163           00066                                    54D                                   
034954,000167: 26,2164           02037                                    VECOEM                                
034955,000168: 26,2165           52761        REMA               VXSC     VAD*                                  
034956,000169: 26,2166           00001                                    0D                                    
034957,000170: 26,2167           02133                                    VECOEM     +60D,1                     
034958,000171: 26,2170           72500                           TIX,1    VSL2                                  #  REM IN METERS X B-29 IN MPAC.
034959,000172: 26,2171           54165                                    REMA                                  
034960,000173: 26,2172           77616                           RVQ                                            
034961,000174: 26,2173           65370        VEM                AXT,1    PDDL                                  #                                        PD- 2
034962,000175: 26,2174           00060                                    48D                                   
034963,000176: 26,2175           14214                                    NINEB4                                
034964,000177: 26,2176           74206                           PUSH     VXSC                                  #                                        PD- 4
034965,000178: 26,2177           02037                                    VECOEM                                
034966,000179: 26,2200           77761        VEMA               VXSC                                           
034967,000180: 26,2201           00001                                    0D                                    

Page 788

034969,000182: 26,2202           14005                           STODL    4D                                    #                                        PD- 2
034970,000183: 26,2203           41425                           DSU      PUSH                                  #                                        PD- 4
034971,000184: 26,2204           14216                                    ONEB4                                 
034972,000185: 26,2205           53357                           VXSC*    VAD                                   
034973,000186: 26,2206           02125                                    VECOEM     +54D,1                     
034974,000187: 26,2207           00005                                    4D                                    
034975,000188: 26,2210           72500                           TIX,1    VSL2                                  #  VEM IN METERS/CS X B-7 IN MPAC.
034976,000189: 26,2211           54200                                    VEMA                                  
034977,000190: 26,2212           77616                           RVQ                                            
034978,000191: 26,2213           22000 00000  NINEB4             2DEC     9.0        B-4                        
034979,000192: 
034980,000193: 26,2215           02000 00000  ONEB4              2DEC     1.0        B-4                        
034981,000194: 
034982,000195: 
034983,000196: 

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