Source Code

This source code is very close to the Apollo Guidance Computer software for the Apollo 13 Lunar module. This revision of the Luminary 131 program is from December of 1969, whereas there was a later revision in January of 1970, and still another revision in February, which is the code that flew on the mission. As far as this transcription is concerned, it was originally from a copy made in 1991 of a printout from the collection of AGC developer Don Eyles for collector David Craig. It was subsequently scanned by Gary Neff, reprocessed for online presentation at the now-discontinued History of Recent Science and Technology (HRST) website of MIT's Dibner Institute (the full-quality scans being discarded in the process), and finally transcribed by Ron Burkey for the Virtual AGC Project. Although a high-quality replacement scan for a completely illegible page was later provided by Gary Neff, the reduced legibility of the reprocessed HRST posting nevertheless caused many errors to be introduced into the transcription. Accordingly, a second scan of the same physical printout was made in 2017 for the Virtual AGC Project's collection at the Internet Archive, and used to correct the transcription errors. All of the scanned materials mentioned, as well as other Luminary 131 related material, are available online. Don Eyles apprently made additional hand-written notes in printout between 1991 and 2017, so the two scans are not identical in that respect. The page-headings in the printout read, in part:
	GAP:  ASSEMBLE REVISION 131 OF AGC PROGRAM LUMINARY BY NASA 2021112-091
	17:53 DEC. 19, 1969
Note that the date is the date the printout was made, not the date on which the program revision was released, although these happen to be very close together.

020778,000002:                                                                                                  ## Copyright:   Public domain.
020779,000003:                                                                                                  ## Filename:    S-BAND_ANTENNA_FOR_LM.agc
020780,000004:                                                                                                  ## Purpose:     A section of Luminary 1C, revision 131.
020781,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
020782,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 13.
020783,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
020784,000008:                                                                                                  ##              that the code format has been changed to conform to the
020785,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the 
020786,000010:                                                                                                  ##              original YUL assembler.
020787,000011:                                                                                                  ## Reference:   pp. 490-493
020788,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
020789,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
020790,000014:                                                                                                  ## Mod history: 05/14/03 RSB.   Began transcribing.
020791,000015:                                                                                                  ##              05/14/05 RSB    Corrected website references above.
020792,000016:                                                                                                  ##              2017-01-06 RSB  Page numbers now agree with those on the
020793,000017:                                                                                                  ##                              original harcopy, as opposed to the PDF page
020794,000018:                                                                                                  ##                              numbers in 1701.pdf.
020795,000019:                                                                                                  ##              2017-02-24 RSB  Proofed comment text using octopus/ProoferComments.
020796,000020: 

Page 490

020798,000022:                                                                                                  #  SUBROUTINE NAME: R05 - S-BAND ANTENNA FOR LM
020799,000023: 
020800,000024:                                                                                                  #  MOD0 BY T. JAMES
020801,000025:                                                                                                  #  MOD1 BY P. SHAKIR
020802,000026: 
020803,000027:                                                                                                  #  FUNCTIONAL DESCRIPTION
020804,000028: 
020805,000029:                                                                                                  #  THE S-BAND ANTENNA ROUTINE, R05, COMPUTES AND DISPLAYS THE PITCH AND
020806,000030:                                                                                                  #  YAW ANTENNA GIMBAL ANGLES REQUIRED TO POINT THE LM STEERABLE ANTENNA
020807,000031:                                                                                                  #  TOWARD THE CENTER OF THE EARTH.  THIS ROUTINE IS SELECTED BY THE ASTRO-
020808,000032:                                                                                                  #  NAUT VIA DSKY ENTRY DURING COASTING FLIGHT OR WHEN THE LM IS ON THE MOON
020809,000033:                                                                                                  #  SURFACE.  THE EARTH OR MOON REFERENCE COORDINATE SYSTEM IS USED DEPENDING
020810,000034:                                                                                                  #  ON WHETHER THE LM IS ABOUT TO ENTER OR HAS ALREADY ENTERED THE MOON
020811,000035:                                                                                                  #  SPHERE OF INFLUENCE, RESPECTIVELY.  CAN BE CALLED ANY TIME EXCEPT WHEN
020812,000036:                                                                                                  #  ANOTHER EXTENDED VERB IS IN USE.  DISPLAY IS MEANINGLESS WITH IMU OFF.
020813,000037: 
020814,000038:                                                                                                  #  TO CALL SUBROUTINE, ASTRONAUT KEYS IN V 64 E
020815,000039: 
020816,000040:                                                                                                  #  SUBROUTINES CALLED -
020817,000041:                                                                                                  #        INTPRET
020818,000042:                                                                                                  #        LOADTIME
020819,000043:                                                                                                  #        LEMCONIC
020820,000044:                                                                                                  #        LUNPOS
020821,000045:                                                                                                  #        CDUTRIG
020822,000046:                                                                                                  #        *SMNB*
020823,000047:                                                                                                  #        BANKCALL
020824,000048:                                                                                                  #        B5OFF
020825,000049:                                                                                                  #        ENDOFJOB
020826,000050:                                                                                                  #        BLANKET
020827,000051: 
020828,000052:                                                                                                  #  RETURNS WITH
020829,000053:                                                                                                  #        PITCH ANGLE IN PITCHANG         REV. B0
020830,000054:                                                                                                  #        YAW ANGLE IN YAWANG             REV. B0
020831,000055: 
020832,000056:                                                                                                  #  ERASABLES USED
020833,000057:                                                                                                  #        PITCHANG
020834,000058:                                                                                                  #        YAWANG
020835,000059:                                                                                                  #        RLM
020836,000060:                                                                                                  #        VAC AREA
020837,000061: 
020838,000062: 41,3750                                           BANK     41                                    
020839,000063: 42,2000                                           SETLOC   SBAND                                 
020840,000064: 42,2000                                           BANK                                           
020841,000065: 
020842,000066: 42,3606  E7,1471                                  EBANK=   WHOCARES                              
020843,000067: 42,3606                                           COUNT*   $$/R05                                
020844,000068: 42,3606           06042        SBANDANT           TC       INTPRET                               

Page 491

020846,000070: 42,3607           47001                           SETPD    RTB                                   
020847,000071: 42,3610           00001                                    0D                                    
020848,000072: 42,3611           21574                                    LOADTIME                              #  PICK UP CURRENT TIME
020849,000073: 42,3612           34041                           STCALL   TDEC1                                 #  ADVANCE INTEGRATION TO TIME IN TDEC1
020850,000074: 42,3613           27077                                    LEMCONIC                              #  USING CONIC INTEGRATION
020851,000075: 42,3614           46135                           SLOAD    BHIZ                                  
020852,000076: 42,3615           00050                                    X2                                    #  X2 =0 EARTH SPHERE, X2 =2 MOON SPHERE
020853,000077: 42,3616           65634                                    CONV4                                 
020854,000078: 42,3617           77775                           VLOAD                                          
020855,000079: 42,3620           00001                                    RATT                                  
020856,000080: 42,3621           16205                           STODL    RLM                                   
020857,000081: 42,3622           00015                                    TAT                                   
020858,000082: 42,3623           77624        CONV3              CALL                                           
020859,000083: 42,3624           33647                                    LUNPOS                                #  UNIT POSITION VECTOR FROM EARTH TO MOON
020860,000084: 42,3625           74375                           VLOAD    VXSC                                  
020861,000085: 42,3626           02723                                    VMOON                                 
020862,000086: 42,3627           24001                                    REMDIST                               #  MEAN DISTANCE FROM EARTH TO MOON
020863,000087: 42,3630           53372                           VSL1     VAD                                   
020864,000088: 42,3631           02205                                    RLM                                   
020865,000089: 42,3632           77650                           GOTO                                           
020866,000090: 42,3633           65636                                    CONV5                                 
020867,000091: 42,3634           77775        CONV4              VLOAD                                          
020868,000092: 42,3635           00001                                    RATT                                  #  UE = -UNIT(RATT)              EARTH SPHERE
020869,000093: 42,3636           53401        CONV5              SETPD    UNIT                                  #  UE = -UNIT((REM)(UEM) + RL)   MOON SPHERE
020870,000094: 42,3637           00001                                    0D                                    #  SET PL POINTER TO 0
020871,000095: 42,3640           45076                           VCOMP    CALL                                  
020872,000096: 42,3641           47541                                    CDUTRIG                               #  COMPUTE SINES AND COSINES OF CDU ANGLES
020873,000097: 42,3642           76521                           MXV      VSL1                                  #  TRANSFORM REF. COORDINATE SYSTEM TO
020874,000098: 42,3643           01734                                    REFSMMAT                              #  STABLE MEMBER B-1 X B-1 X B+1 = B-1
020875,000099: 42,3644           71206                           PUSH     DLOAD                                 #  8D
020876,000100: 42,3645           06524                                    HI6ZEROS                              
020877,000101: 42,3646           02201                           STORE    PITCHANG                              
020878,000102: 42,3647           26203                           STOVL    YAWANG                                #  ZERO OUT ANGLES
020879,000103: 42,3650           77624                           CALL                                           
020880,000104: 42,3651           47673                                    *SMNB*                                
020881,000105: 42,3652           16205                           STODL    RLM                                   #  PRE-MULTIPLY RLM BY (NBSA) MATRIX(B0)
020882,000106: 42,3653           02207                                    RLM        +2                         
020883,000107: 42,3654           45206                           PUSH     DSU                                   
020884,000108: 42,3655           02205                                    RLM                                   
020885,000109: 42,3656           77605                           DMP                                            
020886,000110: 42,3657           25767                                    1OVSQRT2                              
020887,000111: 42,3660           16207                           STODL    RLM        +2                         
020888,000112: 42,3661           41215                           DAD      DMP                                   
020889,000113: 42,3662           02205                                    RLM                                   
020890,000114: 42,3663           25767                                    1OVSQRT2                              
020891,000115: 42,3664           26205                           STOVL    RLM                                   #  R B-1
020892,000116: 42,3665           02205                                    RLM                                   
020893,000117: 42,3666           63256                           UNIT     PDVL                                  
020894,000118: 42,3667           02205                                    RLM                                   
020895,000119: 42,3670           72431                           VPROJ    VSL2                                  #  PROJECTION OF R ONTO LM XZ PLANE

Page 492

020897,000121: 42,3671           06520                                    HIUNITY                               
020898,000122: 42,3672           40045                           BVSU     BOV                                   #  CLEAR OVERFLOW INDICATOR IF ON
020899,000123: 42,3673           02205                                    RLM                                   
020900,000124: 42,3674           65675                                    COVCNV                                
020901,000125: 42,3675           40056        COVCNV             UNIT     BOV                                   #  EXIT ON OVERFLOW
020902,000126: 42,3676           65743                                    SBANDEX                               
020903,000127: 42,3677           47206                           PUSH     VXV                                   #  URP VECTOR B-1
020904,000128: 42,3700           06516                                    HIUNITZ                               
020905,000129: 42,3701           57572                           VSL1     VCOMP                                 #  UZ X URP = -(URP X UZ)
020906,000130: 42,3702           02205                           STORE    RLM                                   #  X VEC B-1
020907,000131: 42,3703           63241                           DOT      PDVL                                  #  SGN(X.UY) UNSCALED
020908,000132: 42,3704           06520                                    HIUNITY                               
020909,000133: 42,3705           02205                                    RLM                                   
020910,000134: 42,3706           75246                           ABVAL    SIGN                                  
020911,000135: 42,3707           77736                           ASIN                                           #  ASIN((SGN(X.UY))ABV(X))       REV B0
020912,000136: 42,3710           26201                           STOVL    PITCHANG                              
020913,000137: 42,3711           00007                                    URP                                   
020914,000138: 42,3712           51041                           DOT      BPL                                   
020915,000139: 42,3713           06516                                    HIUNITZ                               
020916,000140: 42,3714           65721                                    NOADJUST                              #  YES, -90 TO +90
020917,000141: 42,3715           45345                           DLOAD    DSU                                   
020918,000142: 42,3716           06522                                    HIDPHALF                              
020919,000143: 42,3717           02201                                    PITCHANG                              
020920,000144: 42,3720           02201                           STORE    PITCHANG                              
020921,000145: 42,3721           47375        NOADJUST           VLOAD    VXV                                   
020922,000146: 42,3722           00001                                    UR                                    #  Z = (UR X URP)
020923,000147: 42,3723           00007                                    URP                                   
020924,000148: 42,3724           77772                           VSL1                                           
020925,000149: 42,3725           16205                           STODL    RLM                                   #  Z VEC B-1
020926,000150: 42,3726           02201                                    PITCHANG                              
020927,000151: 42,3727           74356                           SIN      VXSC                                  
020928,000152: 42,3730           06516                                    HIUNITZ                               
020929,000153: 42,3731           71525                           PDDL     COS                                   
020930,000154: 42,3732           02201                                    PITCHANG                              
020931,000155: 42,3733           52361                           VXSC     VSU                                   
020932,000156: 42,3734           06522                                    HIUNITX                               #  (UX COS ALPHA) - (UZ SIN ALPHA)
020933,000157: 42,3735           63241                           DOT      PDVL                                  #  YAW.Z
020934,000158: 42,3736           02205                                    RLM                                   
020935,000159: 42,3737           02205                                    RLM                                   
020936,000160: 42,3740           75246                           ABVAL    SIGN                                  
020937,000161: 42,3741           77736                           ASIN                                           
020938,000162: 42,3742           02203                           STORE    YAWANG                                
020939,000163: 42,3743           77776        SBANDEX            EXIT                                           
020940,000164: 42,3744           31043                           CA       EXTVBACT                              
020941,000165: 42,3745           74747                           MASK     BIT5                                  #  IS BIT5 STILL ON
020942,000166: 42,3746           00006                           EXTEND                                         
020943,000167: 42,3747           15472                           BZF      ENDEXT                                #  NO
020944,000168: 42,3750           35017                           CAF      PRIO5                                 
020945,000169: 42,3751           05146                           TC       PRIOCHNG                              
020946,000170: 42,3752           33765                           CAF      V06N51                                #  DISPLAY ANGLES

Page 493

020948,000172: 42,3753           04616                           TC       BANKCALL                              
020949,000173: 42,3754           20353                           CADR     GOMARKFR                              
020950,000174: 42,3755           05563                           TC       B5OFF                                 #  TERMINATE
020951,000175: 42,3756           05563                           TC       B5OFF                                 #  PROCEED
020952,000176: 42,3757           05155                           TC       ENDOFJOB                              #  RECYCLE
020953,000177: 42,3760           34751                           CAF      BIT3                                  #  IMMEDIATE RETURN
020954,000178: 42,3761           05464                           TC       BLANKET                               #  BLANK R3
020955,000179: 42,3762           34740                           CAF      PRIO4                                 
020956,000180: 42,3763           05146                           TC       PRIOCHNG                              
020957,000181: 42,3764           03606                           TC       SBANDANT                              #  YES, CONTINUE DISPLAYING ANGLES.
020958,000182: 42,3765           01463        V06N51             VN       0651                                  
020959,000183: 42,3766           26501 07463  1OVSQRT2           2DEC     .7071067815                            #  1/SQRT(2)
020960,000184: 
020961,000185: 42,3770                        UR                 EQUALS   0D                                    
020962,000186: 42,3770                        URP                EQUALS   6D                                    
020963,000187: 42,3770  30,2000                                  SBANK=   LOWSUPER                              
020964,000188: 

End of include-file S-BAND_ANTENNA_FOR_LM.agc.  Parent file is MAIN.agc