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.

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

Page 739

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

Page 740

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

Page 741

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

Page 742

033299,000203: 26,2202           14005                           STODL    4D                                    #                                        PD -2
033300,000204: 26,2203           41425                           DSU      PUSH                                  #                                        PD -4
033301,000205: 26,2204           14216                                    ONEB4                                 
033302,000206: 26,2205           53357                           VXSC*    VAD                                   
033303,000207: 26,2206           02125                                    VECOEM     +54D,1                     
033304,000208: 26,2207           00005                                    4D                                    
033305,000209: 26,2210           72500                           TIX,1    VSL2                                  #  VEM IN METERS/CS X B-7 IN MPAC.
033306,000210: 26,2211           54200                                    VEMA                                  
033307,000211: 26,2212           77616                           RVQ                                            
033308,000212: 26,2213           22000 00000  NINEB4             2DEC     9.0        B-4                        
033309,000213: 26,2215           02000 00000  ONEB4              2DEC     1.0        B-4                        
033310,000214: 
033311,000215: 
033312,000216: 

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