Source Code

This is a reconstruction of the AGC program Luminary 99 Rev 0. It was the third release of the Lunar Module flight software targeted for use in Apollo 11, after Luminary 96 and 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.

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

Page 984

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

Page 985

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

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

043768,000135: 15,3670           01707                                    TEPHEM                                #  TIME OF LAUNCH
043769,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.

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

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

043773,000140: 15,3673           77170                           AXT,1    AXT,2                                 
043774,000141: 15,3674           00000                                    0                                     
043775,000142: 15,3675           00000                                    0                                     
043776,000143: 15,3676           77614                           CLEAR                                          
043777,000144: 15,3677           00274                                    FREEFLAG                              #  SWITCH BIT
043778,000145: 15,3700           77745        POSITA             DLOAD                                          
043779,000146: 15,3701           12004                                    KONMAT     +2                         #  ZEROS
043780,000147: 15,3702           00027                           STORE    GTMP                                  
043781,000148: 15,3703           40745        POSITB             DLOAD    DMP*                                  
043782,000149: 15,3704           00031                                    TIMEP                                 #  T
043783,000150: 15,3705           12050                                    VAL67      +4,1                       #  1/27 OR 1/32 OR 1/365

Page 986

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

Page 987

043836,000203: 15,3770           77745        POSITE             DLOAD                                          
043837,000204: 15,3771           12004                                    KONMAT     +2                         #  ZEROS
043838,000205: 15,3772           00027                           STORE    GTMP                                  
043839,000206: 15,3773           77650                           GOTO                                           
043840,000207: 15,3774           33722                                    POSITD                                
043841,000208: 15,3775           77616        LUNVEL             RVQ                                            #         TO FOOL INTEGRATION
043842,000209: 05,2000                                           SETLOC   EPHEM1                                
043843,000210: 05,2000                                           BANK                                           
043844,000211: 
043845,000212: 05,3506                                           COUNT*   $$/EPHEM                              
043846,000213: 05,3506                        STMP               EQUALS   16D                                   
043847,000214: 05,3506                        GTMP               EQUALS   22D                                   
043848,000215: 05,3506                        TIMEP              EQUALS   24D                                   
043849,000216: 

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