Source Code

This is a reconstruction of the AGC program Luminary 99 Rev 0. It was the second release of the Lunar Module flight software targeted for use in Apollo 11, after Luminary 97. A bug (which had been around since at least Apollo 10, Luminary 69) was discovered in Rev 0 shortly before the Apollo 11 flight, resulting in a last minute revision into Rev 1, which is what actually flew rather than the Rev 0 presented here. A hardcopy of Rev 0 is known to exist — it belonged to AGC developer Allan Klumpp for many years — but unfortunately the Virtual AGC Project has not had access to that hardcopy. Thus the code you see here had been reconstructed (we believe accurately) rather than transcribed. The first step of the reconstruction of the Rev 0 source code was the transcription of the Rev 1 source code from a hardcopy in the MIT Museum collection. The process of reverting the active portion of the source code (i.e., other than program comments) from Rev 1 to Rev 0 was very minor, consisting only of moving the position of the STARTSB1 label in FRESH START AND RESTART. Allan had previously given us the checksums of the memory banks of Rev 0, and we have verified the program presented here has checksums identical to all banks of Allan's listing of Rev 0. The notations on Allan's Rev 0 program listing read, in part:

	GAP:  ASSEMBLE REVISION 099 OF AGC PROGRAM LUMINARY BY NASA 2021112-051

A single program comment is known to differ between Rev 0 and Rev 1, but these are harder to reconstruct and verify than changes to the active portion of the code. Thus it is possible that there are additional differences between the program comments in Rev 0 and Rev 1 that are unknown to us, and therefore are not reflected in the code presented here.

043623,000002:                                                                                                  ## Copyright:   Public domain.
043624,000003:                                                                                                  ## Filename:    LUNAR_AND_SOLAR_EPHEMERIDES_SUBROUTINES.agc
043625,000004:                                                                                                  ## Purpose:     Part of the reconstructed source code for LMY99 Rev 0,
043626,000005:                                                                                                  ##              otherwise known as Luminary Rev 99, the second release
043627,000006:                                                                                                  ##              of the Apollo Guidance Computer (AGC) software for Apollo 11.
043628,000007:                                                                                                  ##              It differs from LMY99 Rev 1 (the flown version) only in the
043629,000008:                                                                                                  ##              placement of a single label. The corrections shown here have
043630,000009:                                                                                                  ##              been verified to have the same bank checksums as AGC developer
043631,000010:                                                                                                  ##              Allan Klumpp's copy of Luminary Rev 99, and so are believed
043632,000011:                                                                                                  ##              to be accurate. This file is intended to be a faithful 
043633,000012:                                                                                                  ##              recreation, except that the code format has been changed to 
043634,000013:                                                                                                  ##              conform to the requirements of the yaYUL assembler rather than 
043635,000014:                                                                                                  ##              the original YUL assembler.
043636,000015:                                                                                                  ##
043637,000016:                                                                                                  ## Assembler:   yaYUL
043638,000017:                                                                                                  ## Contact:     Hartmuth Gutsche <hgutsche@xplornet.com>.
043639,000018:                                                                                                  ## Website:     www.ibiblio.org/apollo.
043640,000019:                                                                                                  ## Pages:       984-987
043641,000020:                                                                                                  ## Mod history: 2009-05-24 HG   Transcribed from page images.
043642,000021:                                                                                                  ##              2016-12-17 RSB  Proofed text comments with octopus/ProoferComments
043643,000022:                                                                                                  ##                              and corrected the errors found.
043644,000023:                                                                                                  ##              2017-03-13 RSB  Comment-text fixes noted in proofing Luminary 116.
043645,000024:                                                                                                  ##              2017-08-01 MAS  Created from LMY99 Rev 1.
043646,000025:                                                                                                  ##              2017-08-26 MAS  Fixed comment-text errors found while transcribing Zerlina 56.
043647,000026: 
043648,000027:                                                                                                  ## This source code has been transcribed or otherwise adapted from
043649,000028:                                                                                                  ## digitized images of a hardcopy from the MIT Museum.  The digitization
043650,000029:                                                                                                  ## was performed by Paul Fjeld, and arranged for by Deborah Douglas of
043651,000030:                                                                                                  ## the Museum.  Many thanks to both.  The images (with suitable reduction
043652,000031:                                                                                                  ## in storage size and consequent reduction in image quality as well) are
043653,000032:                                                                                                  ## available online at www.ibiblio.org/apollo.  If for some reason you
043654,000033:                                                                                                  ## find that the images are illegible, contact me at info@sandroid.org
043655,000034:                                                                                                  ## about getting access to the (much) higher-quality images which Paul
043656,000035:                                                                                                  ## actually created.
043657,000036:                                                                                                  ##
043658,000037:                                                                                                  ## The code has been modified to match LMY99 Revision 0, otherwise
043659,000038:                                                                                                  ## known as Luminary Revision 99, the Apollo 11 software release preceeding
043660,000039:                                                                                                  ## the listing from which it was transcribed. It has been verified to
043661,000040:                                                                                                  ## contain the same bank checksums as AGC developer Allan Klumpp's listing
043662,000041:                                                                                                  ## of Luminary Revision 99 (for which we do not have scans).
043663,000042:                                                                                                  ##
043664,000043:                                                                                                  ## Notations on Allan Klumpp's listing read, in part:
043665,000044:                                                                                                  ##
043666,000045:                                                                                                  ##      ASSEMBLE REVISION 099 OF AGC PROGRAM LUMINARY BY NASA 2021112-51
043667,000046: 

Page 984

043669,000048:                                                                                                  #  NAME - LSPOS - LOCATE SUN AND MOON                    DATE - 25 OCT 67
043670,000049:                                                                                                  #  MOD NO. 1
043671,000050:                                                                                                  #  MOD BY NEVILLE                                        ASSEMBLY SUNDANCE
043672,000051: 
043673,000052:                                                                                                  #  FUNCTIONAL DESCRIPTION
043674,000053: 
043675,000054:                                                                                                  #         COMPUTES UNIT POSITION VECTOR OF THE SUN AND MOON IN THE BASIC REFERENCE SYSTEM. THE SUN VECTOR S IS
043676,000055:                                                                                                  #  LOCATED VIA TWO ANGLES. THE FIRST ANGLE(OBLIQUITY) IS THE ANGLE BETWEEN THE EARTH EQUATOR AND THE ECLIPTIC. THE
043677,000056:                                                                                                  #  SECOND ANGLE IS THE LONGITUDE OF THE SUN MEASURED IN THE ECLIPTIC.
043678,000057:                                                                                                  #  THE POSITION VECTOR OF THE SUN IS
043679,000058:                                                                                                  #        -
043680,000059:                                                                                                  #        S = (COS(LOS), COS(OBL)*SIN(LOS), SIN(OBL)*SIN(LOS)), WHERE
043681,000060: 
043682,000061:                                                                                                  #        LOS = LOS +LOS *T-(C *SIN(2PI*T)/365.24 +C *COS(2PI*T)/365.24)
043683,000062:                                                                                                  #                 0    R     0                     1
043684,000063:                                                                                                  #        LOS  (RAD) IS THE LONGITUDE OF THE SUN FOR MIDNIGHT JUNE 30TH OF THE PARTICULAR YEAR.
043685,000064:                                                                                                  #           0
043686,000065:                                                                                                  #        LOS  (RAD/DAY) IS THE MEAN RATE FOR THE PARTICULAR YEAR.
043687,000066:                                                                                                  #           R
043688,000067: 
043689,000068:                                                                                                  #  LOS  AND LOS  ARE STORED AS LOSC AND LOSR IN RATESP.
043690,000069:                                                                                                  #     0        R
043691,000070:                                                                                                  #  COS(OBL) AND SIN(OBL) ARE STORED IN THE MATRIX KONMAT.
043692,000071: 
043693,000072:                                                                                                  #  T, TIME MEASURED IN DAYS (24 HOURS), IS STORED IN TIMEP.
043694,000073: 
043695,000074:                                                                                                  #  C  AND C  ARE FUDGE FACTORS TO MINIMIZE THE DEVIATION.  THEY ARE STORED AS ONE CONSTANT (CMOD), SINCE
043696,000075:                                                                                                  #   0      1                               2  2 1/2
043697,000076:                                                                                                  #  C *SIN(X)+C *COS(X) CAN BE WRITTEN AS (C +C )   *SIN(X+PHI), WHERE PHI=ARCTAN(C /C ).
043698,000077:                                                                                                  #   0         1                            0  1                                   1  0
043699,000078: 
043700,000079:                                                                                                  #  THE MOON IS LOCATED VIA FOUR ANGLES. THE FIRST IS THE OBLIQUITY. THE SECOND IS THE MEAN LONGITUDE OF THE MOON,
043701,000080:                                                                                                  #  MEASURED IN THE ECLIPTIC FROM THE MEAN EQUINOX TO THE MEAN ASCENDING NODE OF THE LUNAR ORBIT, AND THEN ALONG THE
043702,000081:                                                                                                  #  ORBIT.  THE THIRD ANGLE IS THE ANGLE BETWEEN THE ECLIPTIC AND THE LUNAR ORBIT.  THE FOURTH ANGLE IS THE LONGITUDE
043703,000082:                                                                                                  #  OF THE NODE OF THE MOON, MEASURED IN THE LUNAR ORBIT.  LET THESE ANGLES BE OBL,LOM,IM, AND LON RESPECTIVELY.
043704,000083: 
043705,000084:                                                                                                  #  THE SIMPLIFIED POSITION VECTOR OF THE MOON IS
043706,000085:                                                                                                  #        -
043707,000086:                                                                                                  #        M=(COS(LOM), COS(OBL)*SIN(LOM)-SIN(OBL)*SIN(IM)*SIN(LOM-LON), SIN(OBL)*SIN(LOM)+COS(OBL)*SIN(IM)*SIN(LOM-LON))
043708,000087: 
043709,000088:                                                                                                  #  WHERE
043710,000089:                                                                                                  #        LOM=LOM +LOM *T-(A *SIN 2PI*T/27.5545+A *COS(2PI*T/27.5545)+B *SIN 2PI*T/32+B *COS(2PI*T/32)), AND
043711,000090:                                                                                                  #               0    R     0                    1                     0               1
043712,000091:                                                                                                  #        LON=LON +LON
043713,000092:                                                                                                  #               0    R
043714,000093:                                                                                                  #  A , A , B  AND B  ARE STORED AS AMOD AND BMOD (SEE DESCRIPTION OF CMOD, ABOVE).  COS(OBL), SIN(OBL)*SIN(IM),
043715,000094:                                                                                                  #   0   1   0      1
043716,000095:                                                                                                  #  SIN(OBL), AND COS(OBL)*SIN(IM) ARE STORED IN KONMAT AS K1, K2, K3 AND K4, RESPECTIVELY.  LOM , LOM , LON , LON                                   
043717,000096:                                                                                                  #  ARE STORED AS LOMO, LOMR, LONO, AND LONR IN RATESP.                                         0     R     0     R
043718,000097:                                                                                                  #  THE THREE PHIS ARE STORED AS AARG, BARG, AND CARG(SUN).  ALL CONSTANTS ARE UPDATED BY YEAR.
043719,000098: 
043720,000099:                                                                                                  #  CALLING SEQUENCE

Page 985

043722,000101:                                                                                                  #        CALL LSPOS.  RETURN IS VIA CPRET.
043723,000102: 
043724,000103:                                                                                                  #  ALARMS OR ABORTS
043725,000104:                                                                                                  #        NONE
043726,000105: 
043727,000106:                                                                                                  #  ERASABLE INITIALIZATION REQUIRED
043728,000107:                                                                                                  #        TEPHEM - TIME FROM MIDNIGHT 1 JULY PRECEDING THE LAUNCH TO THE TIME OF THE LAUNCH (WHEN THE AGC CLOCK WENT
043729,000108:                                                                                                  #        TO ZERO).  TEPHEM IS TP WITH UNITS OF CENTI-SECONDS.
043730,000109: 
043731,000110:                                                                                                  #        TIME2 AND TIME1 ARE IN MPAC AND MPAC +1 WHEN PROGRAM IS CALLED.
043732,000111: 
043733,000112:                                                                                                  #  OUTPUT
043734,000113:                                                                                                  #        UNIT POSITIONAL VECTOR OF SUN IN VSUN.  (SCALED B-1)
043735,000114:                                                                                                  #        UNIT POSITIONAL VECTOR OF MOON IN VMOON.  (SCALED B-1)
043736,000115: 
043737,000116:                                                                                                  #  SUBROUTINES USED
043738,000117:                                                                                                  #        NONE
043739,000118: 
043740,000119:                                                                                                  #  DEBRIS
043741,000120:                                                                                                  #        CURRENT CORE SET, WORK AREA AND FREEFLAG
043742,000121: 
043743,000122: 04,3027                                           BANK     04                                    
043744,000123: 15,2000                                           SETLOC   EPHEM                                 
043745,000124: 15,2000                                           BANK                                           
043746,000125: 
043747,000126: 15,3664  E5,1714                                  EBANK=   VSUN                                  
043748,000127: 15,3664                                           COUNT*   $$/EPHEM                              
043749,000128: 15,3664  15,3664               LUNPOS             EQUALS   LSPOS                                 
043750,000129: 
043751,000130: 15,3664           54201        LSPOS              SETPD    SR                                    
043752,000131: 15,3665           00001                                    0                                     
043753,000132: 15,3666           20617                                    14D                                   #  TP
043754,000133: 15,3667           56371                           TAD      DDV                                   

The hand-written notation "in centisec B 42" appears to the right.

043756,000135: 15,3670           01707                                    TEPHEM                                #  TIME OF LAUNCH
043757,000136: 15,3671           12024                                    CSTODAY                               #  24 HOURS-8640000 CENTI-SECS/DAY B-33

The hand-written notation "@ B 9 = 512 days" appears to the right.

043759,000138: 15,3672           00031                           STORE    TIMEP                                 #  T IN DAYS

The hand-written notation "∴ granularity ≈ 0.164 sec" appears to the right.

043761,000140: 15,3673           77170                           AXT,1    AXT,2                                 
043762,000141: 15,3674           00000                                    0                                     
043763,000142: 15,3675           00000                                    0                                     
043764,000143: 15,3676           77614                           CLEAR                                          
043765,000144: 15,3677           00274                                    FREEFLAG                              #  SWITCH BIT
043766,000145: 15,3700           77745        POSITA             DLOAD                                          
043767,000146: 15,3701           12004                                    KONMAT     +2                         #  ZEROS
043768,000147: 15,3702           00027                           STORE    GTMP                                  
043769,000148: 15,3703           40745        POSITB             DLOAD    DMP*                                  
043770,000149: 15,3704           00031                                    TIMEP                                 #  T
043771,000150: 15,3705           12050                                    VAL67      +4,1                       #  1/27 OR 1/32 OR 1/365

Page 986

043773,000152: 15,3706           42661                           SL       DAD*                                  
043774,000153: 15,3707           20211                                    8D                                    
043775,000154: 15,3710           12046                                    VAL67      +2,1                       #  AARG
043776,000155: 15,3711           40756                           SIN      DMP*                                  #  SIN(T/27+PHI) OR T/32 OR T/365
043777,000156: 15,3712           12044                                    VAL67,1                               #  (A0**2+A1**2)**1/2 SIN(X+PHIA)
043778,000157: 15,3713           62015                           DAD      INCR,1                                #  PLUS
043779,000158: 15,3714           00027                                    GTMP                                  #  (B0**2+B1**2)**1/2 SIN(X+PHIB)
043780,000159: 15,3715           77771                           DEC      -6         B-14                       
043781,000160: 15,3716           00027                           STORE    GTMP                                  #  OR (C0**2+C1**2)**1/2 SIN(X+PHIC)
043782,000161: 15,3717           77614                           BOFSET                                         
043783,000162: 15,3720           00054                                    FREEFLAG                              
043784,000163: 15,3721           33703                                    POSITB                                
043785,000164: 15,3722           40745        POSITD             DLOAD    DMP*                                  
043786,000165: 15,3723           00031                                    TIMEP                                 #  T
043787,000166: 15,3724           65747                                    RATESP,2                              #  LOMR,LOSR,LONR
043788,000167: 15,3725           42661                           SL       DAD*                                  
043789,000168: 15,3726           20206                                    5D                                    
043790,000169: 15,3727           65741                                    RATESP     +6,2                       #  LOMO,LOSO,LONO
043791,000170: 15,3730           77625                           DSU                                            
043792,000171: 15,3731           00027                                    GTMP                                  
043793,000172: 15,3732           10021                           STORE    STMP,2                                #  LOM,LOS,LON
043794,000173: 15,3733           63135                           SLOAD    INCR,2                                
043795,000174: 15,3734           00050                                    X2                                    
043796,000175: 15,3735           77775                           DEC      -2         B-14                       
043797,000176: 15,3736           53015                           DAD      BZE                                   
043798,000177: 15,3737           12026                                    RCB-13                                #  PLUS 2
043799,000178: 15,3740           33770                                    POSITE                                #  2ND
043800,000179: 15,3741           77644                           BPL                                            
043801,000180: 15,3742           33700                                    POSITA                                #  1ST
043802,000181: 15,3743           45345        POSITF             DLOAD    DSU                                   #  3RD
043803,000182: 15,3744           00021                                    STMP                                  #  LOM
043804,000183: 15,3745           00025                                    STMP       +4                         #  LON
043805,000184: 15,3746           65356                           SIN      PDDL                                  #  SIN(LOM-LON)
043806,000185: 15,3747           00021                                    STMP                                  
043807,000186: 15,3750           65356                           SIN      PDDL                                  #  SIN LOM
043808,000187: 15,3751           00021                                    STMP                                  
043809,000188: 15,3752           55546                           COS      VDEF                                  #  COS LOM
043810,000189: 15,3753           53521                           MXV      UNIT                                  
043811,000190: 15,3754           12002                                    KONMAT                                #  K1,K2,K3,K4,
043812,000191: 15,3755           02723                           STORE    VMOON                                 
043813,000192: 15,3756           65345                           DLOAD    PDDL                                  
043814,000193: 15,3757           12004                                    KONMAT     +2                         #  ZERO
043815,000194: 15,3760           00023                                    STMP       +2                         
043816,000195: 15,3761           65356                           SIN      PDDL                                  #  SIN LOS
043817,000196: 15,3762           00023                                    STMP       +2                         
043818,000197: 15,3763           55546                           COS      VDEF                                  #  COS LOS
043819,000198: 15,3764           53521                           MXV      UNIT                                  
043820,000199: 15,3765           12002                                    KONMAT                                
043821,000200: 15,3766           02715                           STORE    VSUN                                  
043822,000201: 15,3767           77616                           RVQ                                            

Page 987

043824,000203: 15,3770           77745        POSITE             DLOAD                                          
043825,000204: 15,3771           12004                                    KONMAT     +2                         #  ZEROS
043826,000205: 15,3772           00027                           STORE    GTMP                                  
043827,000206: 15,3773           77650                           GOTO                                           
043828,000207: 15,3774           33722                                    POSITD                                
043829,000208: 15,3775           77616        LUNVEL             RVQ                                            #         TO FOOL INTEGRATION
043830,000209: 05,2000                                           SETLOC   EPHEM1                                
043831,000210: 05,2000                                           BANK                                           
043832,000211: 
043833,000212: 05,3506                                           COUNT*   $$/EPHEM                              
043834,000213: 05,3506                        STMP               EQUALS   16D                                   
043835,000214: 05,3506                        GTMP               EQUALS   22D                                   
043836,000215: 05,3506                        TIMEP              EQUALS   24D                                   
043837,000216: 

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