Source Code

This is the source-code for the Apollo 9 Command Module's Guidance Computer. These files were derived originally from the scan from MIT's Dibner Institute's now-discontinued website titled "History of Recent Science and Technology", which in turn was originally created by Gary Neff, though his high-quality scans were unfortunately reduced in legibility when presented online. The markings on the front of the printout imply that it was the original AGC developer Norm Brodeur's copy. A scan by Ron Burkey has superceded it, made from a more-legible copy from the collection of original AGC developer Fred Martin. The source code was transcribed from those images by Ron Burkey. Note that the page images presented online are of reduced quality, and that higher-quality images are available. Report any conversion errors or legibility problems in page images to info@sandroid.org. Notations on the program listing read, in part:

	ASSEMBLE REVISION 249 OF AGC PROGRAM COLOSSUS BY NASA 2021111-041
	20'35 OCT. 28,1968
Note that the date is the date of the printout, not the date of the program revision.

033085,000002:                                                                                                  ## Copyright:   Public domain.
033086,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
033087,000004:                                                                                                  ## Purpose:     Part of the source code for Colossus, build 249.
033088,000005:                                                                                                  ##              It is part of the source code for the Command Module's (CM)
033089,000006:                                                                                                  ##              Apollo Guidance Computer (AGC), for Apollo 9.
033090,000007:                                                                                                  ## Assembler:   yaYUL
033091,000008:                                                                                                  ## Reference:   pp. 739-742.
033092,000009:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
033093,000010:                                                                                                  ## Website:     www.ibiblio.org/apollo.
033094,000011:                                                                                                  ## Mod history: 08/22/04 RSB.   Split off from P51-P53.agc.
033095,000012:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
033096,000013:                                                                                                  ##                              original harcopy, as opposed to the PDF page
033097,000014:                                                                                                  ##                              numbers in 1701.pdf.
033098,000015:                                                                                                  ##              2017-01-15 RSB  Cross-diff'd comment text (not whitespace)
033099,000016:                                                                                                  ##                              vs the already-proofed corresponding Colossus
033100,000017:                                                                                                  ##                              237 and Comanche 55 source-code files
033101,000018:                                                                                                  ##                              and corrected errors found. There were no
033102,000019:                                                                                                  ##                              differences between the comment text in the 
033103,000020:                                                                                                  ##                              different versions after these corrections.
033104,000021:                                                                                                  ##
033105,000022:                                                                                                  ## The contents of the "Colossus249" files, in general, are transcribed 
033106,000023:                                                                                                  ## from a scanned copy of the program listing.  Notations on this
033107,000024:                                                                                                  ## document read, in part:
033108,000025:                                                                                                  ##
033109,000026:                                                                                                  ##      Assemble revision 249 of AGC program Colossus by NASA
033110,000027:                                                                                                  ##      2021111-041.  October 28, 1968.  
033111,000028:                                                                                                  ##
033112,000029:                                                                                                  ##      This AGC program shall also be referred to as
033113,000030:                                                                                                  ##                              Colossus 1A
033114,000031:                                                                                                  ##
033115,000032:                                                                                                  ##      Prepared by
033116,000033:                                                                                                  ##                      Massachusetts Institute of Technology
033117,000034:                                                                                                  ##                      75 Cambridge Parkway
033118,000035:                                                                                                  ##                      Cambridge, Massachusetts
033119,000036:                                                                                                  ##      under NASA contract NAS 9-4065.
033120,000037:                                                                                                  ##
033121,000038:                                                                                                  ## Refer directly to the online document mentioned above for further information.
033122,000039:                                                                                                  ## Please report any errors (relative to the scanned pages) to info@sandroid.org.
033123,000040:                                                                                                  ##
033124,000041:                                                                                                  ## In some cases, where the source code for Luminary 131 overlaps that of 
033125,000042:                                                                                                  ## Colossus 249, this code is instead copied from the corresponding Luminary 131
033126,000043:                                                                                                  ## source file, and then is proofed to incorporate any changes.
033127,000044: 

Page 739

033129,000046:                                                                                                  #  LUNAR AND SOLAR EPHEMERIDES SUBROUTINES
033130,000047: 
033131,000048:                                                                                                  #  FUNCTIONAL DESCRIPTION
033132,000049: 
033133,000050:                                                                                                  #        THESE SUBROUTINES ARE USED TO DETERMINE THE POSITION AND VELOCITY
033134,000051:                                                                                                  #        VECTORS OF THE SUN AND THE MOON RELATIVE TO THE EARTH AT THE
033135,000052:                                                                                                  #        SPECIFIED GROUND ELAPSED TIME INPUT BY THE USER.
033136,000053: 
033137,000054:                                                                                                  #        THE POSITION OF THE MOON IS STORED IN THE COMPUTER IN THE FORM OF
033138,000055:                                                                                                  #        A NINTH DEGREE POLYNOMIAL APPROXIMATION WHICH IS VALID OVER A 15
033139,000056:                                                                                                  #        DAY INTERVAL BEGINNING SHORTLY BEFORE LAUNCH.  THEREFORE THE TIME
033140,000057:                                                                                                  #        INPUT BY THE USER SHOULD FALL WITHIN THIS 15 DAY INTERVAL.
033141,000058: 
033142,000059:                                                                                                  #        LSPOS COMPUTES THE POSITION VECTORS OF THE SUN AND THE MOON.
033143,000060: 
033144,000061:                                                                                                  #        LUNPOS COMPUTES THE POSITION VECTOR OF THE MOON.
033145,000062: 
033146,000063:                                                                                                  #        LUNVEL COMPUTES THE VELOCITY VECTOR OF THE MOON.
033147,000064: 
033148,000065:                                                                                                  #        SOLPOS COMPUTES THE POSITION VECTOR OF THE SUN.
033149,000066: 
033150,000067:                                                                                                  #  CALLING SEQUENCE
033151,000068: 
033152,000069:                                                                                                  #        DLOAD   CALL
033153,000070:                                                                                                  #                TIME            GROUND ELAPSED TIME
033154,000071:                                                                                                  #                SUBROUTINE      LSPOS OR LUNPOS OR LUNVEL OR SOLPOS
033155,000072: 
033156,000073:                                                                                                  #  INPUT
033157,000074: 
033158,000075:                                                                                                  #        1) SPECIFIED GROUND ELAPSED TIME IN CS X B-28 LOADED IN MPAC.
033159,000076: 
033160,000077:                                                                                                  #        2) TIMEMO - TIME AT THE CENTER OF THE RANGE OVER WHICH THE LUNAR
033161,000078:                                                                                                  #        POSITION POLYNOMIAL IS VALID IN CS X B-42.
033162,000079: 
033163,000080:                                                                                                  #        3) VECOEM - VECTOR COEFFICIENTS OF THE LUNAR POSITION POLYNOMIAL
033164,000081:                                                                                                  #        LOADED IN DESCENDING SEQUENCE IN METERS/CS**N X B-2
033165,000082: 
033166,000083:                                                                                                  #        4) RESO - POSITION VECTOR OF THE SUN RELATIVE TO THE EARTH AT
033167,000084:                                                                                                  #        TIMEMO IN METERS X B-38.
033168,000085: 
033169,000086:                                                                                                  #        5) VESO - VELOCITY VECTOR OF THE SUN RELATIVE TO THE EARTH AT
033170,000087:                                                                                                  #        TIMEMO IN METERS/CS X B-9.
033171,000088:                                                                                                  #  
033172,000089:                                                                                                  #        6) OMEGAES - ANGULAR VELOCITY OF THE VECTOR RESO AT TIMEMO IN
033173,000090:                                                                                                  #        REV/CS X B+26.
033174,000091: 
033175,000092:                                                                                                  #        ALL EXCEPT THE FIRST INPUT ARE INCLUDED IN THE PRE-LAUNCH
033176,000093:                                                                                                  #        ERASABLE DATA LOAD.
033177,000094: 
033178,000095:                                                                                                  #  OUTPUT - LSPOS

Page 740

033180,000097: 
033181,000098:                                                                                                  #        1) 2D OF VAC AREA CONTAINS THE POSITION VECTOR OF THE SUN RELATIVE
033182,000099:                                                                                                  #        TO THE EARTH AT TIME INPUT BY THE USER IN METERS X B-38.
033183,000100: 
033184,000101:                                                                                                  #        2) MPAC CONTAINS THE POSITION VECTOR OF THE MOON RELATIVE TO THE
033185,000102:                                                                                                  #        EARTH AT TIME INPUT BY THE USER IN METERS X B-29.
033186,000103: 
033187,000104:                                                                                                  #  OUTPUT - LUNPOS
033188,000105: 
033189,000106:                                                                                                  #        MPAC CONTAINS THE POSITION VECTOR OF THE MOON RELATIVE TO THE
033190,000107:                                                                                                  #        EARTH AT THE TIME INPUT BY USER IN METERS X B-29.
033191,000108: 
033192,000109:                                                                                                  #  OUTPUT - LUNVEL
033193,000110: 
033194,000111:                                                                                                  #        MPAC CONTAINS THE VELOCITY VECTOR OF THE MOON RELATIVE TO THE
033195,000112:                                                                                                  #        EARTH AT TIME INPUT BY THE USER IN METERS/CS X B-7.
033196,000113: 
033197,000114:                                                                                                  #  OUTPUT - SOLPOS
033198,000115: 
033199,000116:                                                                                                  #        MPAC CONTAINS THE POSITION VECTOR OF THE SUN RELATIVE TO THE EARTH
033200,000117:                                                                                                  #        AT TIME INPUT BY THE USER IN METERS X B-38.
033201,000118: 
033202,000119:                                                                                                  #  SUBROUTINES USED
033203,000120: 
033204,000121:                                                                                                  #        NONE
033205,000122: 
033206,000123:                                                                                                  #  REMARKS
033207,000124: 
033208,000125:                                                                                                  #        THE VAC AREA IS USED FOR STORAGE OF INTERMEDIATE AND FINAL RESULTS
033209,000126:                                                                                                  #        OF COMPUTATIONS.
033210,000127: 
033211,000128:                                                                                                  #        S1, X1 AND X2 ARE USED BY THESE SUBROUTINES.
033212,000129: 
033213,000130:                                                                                                  #        PRELAUNCH ERASABLE DATA LOAD ARE ONLY ERASABLE STORAGE USED BY
033214,000131:                                                                                                  #        THESE SUBROUTINES.
033215,000132: 
033216,000133:                                                                                                  #        RESTARTS DURING OPERATION OF THESE SUBROUTINES MUST BE HANDLED BY
033217,000134:                                                                                                  #        THE USER.
033218,000135: 
033219,000136: 36,2502                                           BANK     36                                    
033220,000137: 26,2000                                           SETLOC   EPHEM                                 
033221,000138: 26,2000                                           BANK                                           
033222,000139: 
033223,000140: 26,2110                                           COUNT*   $$/EPHEM                              
033224,000141: 26,2110  E7,1777                                  EBANK=   END-E7                                
033225,000142: 
033226,000143: 26,2110           77774        LSPOS              AXT,2                                          #  COMPUTES POSITION VECTORS OF BOTH THE
033227,000144: 26,2111           54161                                    RESA                                  #  SUN AND THE MOON.  THE POSITION VECTOR
033228,000145: 26,2112           52170                           AXT,1    GOTO                                  #  OF THE SUN IS STORED IN 2D OF THE VAC
033229,000146: 26,2113           54143                                    RES                                   #  AREA.  THE POSITION VECTOR OF THE MOON
033230,000147: 26,2114           54126                                    LSTIME                                #  IS STORED IN MPAC.
033231,000148: 26,2115           52170        LUNPOS             AXT,1    GOTO                                  #  COMPUTES THE POSITION VECTOR OF THE MOON
033232,000149: 26,2116           54162                                    REM                                   #  AND STORES IT IN MPAC.
033233,000150: 26,2117           54126                                    LSTIME                                

Page 741

033235,000152: 26,2120           52170        LUNVEL             AXT,1    GOTO                                  #  COMPUTES THE VELOCITY VECTOR OF THE MOON
033236,000153: 26,2121           54173                                    VEM                                   #  AND STORES IT IN MPAC.
033237,000154: 26,2122           54126                                    LSTIME                                
033238,000155: 26,2123           76020        SOLPOS             STQ      AXT,1                                 #  COMPUTES THE POSITION VECTOR OF THE SUN
033239,000156: 26,2124           00047                                    X2                                    #  AND STORES IT IN MPAC.
033240,000157: 26,2125           54143                                    RES                                   
033241,000158: 26,2126           54201        LSTIME             SETPD    SR                                    
033242,000159: 26,2127           00001                                    0D                                    
033243,000160: 26,2130           20617                                    14D                                   
033244,000161: 26,2131           57571                           TAD      DCOMP                                 
033245,000162: 26,2132           01707                                    TEPHEM                                
033246,000163: 26,2133           57571                           TAD      DCOMP                                 
033247,000164: 26,2134           02034                                    TIMEMO                                
033248,000165: 26,2135           66261                           SL       SSP                                   
033249,000166: 26,2136           20221                                    16D                                   
033250,000167: 26,2137           00051                                    S1                                    
033251,000168: 26,2140           00006                                    6D                                    
033252,000169: 26,2141           77650                           GOTO                                           
033253,000170: 26,2142           00046                                    X1                                    
033254,000171: 26,2143           41206        RES                PUSH     DMP                                   #                                        PD -2
033255,000172: 26,2144           02147                                    OMEGAES                               
033256,000173: 26,2145           71406                           PUSH     COS                                   #                                        PD -4
033257,000174: 26,2146           65361                           VXSC     PDDL                                  #                                        PD -8
033258,000175: 26,2147           02133                                    RESO                                  
033259,000176: 26,2150           63356                           SIN      PDVL                                  #                                        PD-10
033260,000177: 26,2151           02133                                    RESO                                  
033261,000178: 26,2152           53406                           PUSH     UNIT                                  #                                        PD-16
033262,000179: 26,2153           53435                           VXV      UNIT                                  
033263,000180: 26,2154           02141                                    VESO                                  
033264,000181: 26,2155           76435                           VXV      VSL1                                  #                                        PD-10
033265,000182: 26,2156           53361                           VXSC     VAD                                   #                                        PD-02
033266,000183: 26,2157           52172                           VSL1     GOTO                                  #  RES IN METERS X B-38 IN MPAC.
033267,000184: 26,2160           00047                                    X2                                    
033268,000185: 26,2161           14003        RESA               STODL    2D                                    #  RES IN METERS X B-38 IN 2D OF VAC.    PD -0
033269,000186: 26,2162           63370        REM                AXT,1    PDVL                                  #                                        PD -2
033270,000187: 26,2163           00066                                    54D                                   
033271,000188: 26,2164           02037                                    VECOEM                                
033272,000189: 26,2165           52761        REMA               VXSC     VAD*                                  
033273,000190: 26,2166           00001                                    0D                                    
033274,000191: 26,2167           02133                                    VECOEM     +60D,1                     
033275,000192: 26,2170           72500                           TIX,1    VSL2                                  #  REM IN METERS X B-29 IN MPAC.
033276,000193: 26,2171           54165                                    REMA                                  
033277,000194: 26,2172           77616                           RVQ                                            
033278,000195: 26,2173           65370        VEM                AXT,1    PDDL                                  #                                        PD -2
033279,000196: 26,2174           00060                                    48D                                   
033280,000197: 26,2175           14214                                    NINEB4                                
033281,000198: 26,2176           74206                           PUSH     VXSC                                  #                                        PD -4
033282,000199: 26,2177           02037                                    VECOEM                                
033283,000200: 26,2200           77761        VEMA               VXSC                                           
033284,000201: 26,2201           00001                                    0D                                    

Page 742

033286,000203: 26,2202           14005                           STODL    4D                                    #                                        PD -2
033287,000204: 26,2203           41425                           DSU      PUSH                                  #                                        PD -4
033288,000205: 26,2204           14216                                    ONEB4                                 
033289,000206: 26,2205           53357                           VXSC*    VAD                                   
033290,000207: 26,2206           02125                                    VECOEM     +54D,1                     
033291,000208: 26,2207           00005                                    4D                                    
033292,000209: 26,2210           72500                           TIX,1    VSL2                                  #  VEM IN METERS/CS X B-7 IN MPAC.
033293,000210: 26,2211           54200                                    VEMA                                  
033294,000211: 26,2212           77616                           RVQ                                            
033295,000212: 26,2213           22000 00000  NINEB4             2DEC     9.0        B-4                        
033296,000213: 26,2215           02000 00000  ONEB4              2DEC     1.0        B-4                        
033297,000214: 
033298,000215: 
033299,000216: 

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