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.

061162,000002:                                                                                                  ## Copyright:   Public domain.
061163,000003:                                                                                                  ## Filename:    RTB_OP_CODES.agc
061164,000004:                                                                                                  ## Purpose:     Part of the reconstructed source code for LMY99 Rev 0,
061165,000005:                                                                                                  ##              otherwise known as Luminary Rev 99, the third release
061166,000006:                                                                                                  ##              of the Apollo Guidance Computer (AGC) software for Apollo 11.
061167,000007:                                                                                                  ##              It differs from LMY99 Rev 1 (the flown version) only in the
061168,000008:                                                                                                  ##              placement of a single label. The corrections shown here have
061169,000009:                                                                                                  ##              been verified to have the same bank checksums as AGC developer
061170,000010:                                                                                                  ##              Allan Klumpp's copy of Luminary Rev 99, and so are believed
061171,000011:                                                                                                  ##              to be accurate. This file is intended to be a faithful 
061172,000012:                                                                                                  ##              recreation, except that the code format has been changed to 
061173,000013:                                                                                                  ##              conform to the requirements of the yaYUL assembler rather than 
061174,000014:                                                                                                  ##              the original YUL assembler.
061175,000015:                                                                                                  ##
061176,000016:                                                                                                  ## Assembler:   yaYUL
061177,000017:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
061178,000018:                                                                                                  ## Website:     www.ibiblio.org/apollo.
061179,000019:                                                                                                  ## Pages:       1397-1401
061180,000020:                                                                                                  ## Mod history: 2009-05-10 SN   (Sergio Navarro).  Started adapting
061181,000021:                                                                                                  ##                              from the Luminary131/ file of the same
061182,000022:                                                                                                  ##                              name, using Luminary099 page images.
061183,000023:                                                                                                  ##              2016-12-18 RSB  Proofed text comments with octopus/ProoferComments
061184,000024:                                                                                                  ##                              and corrected the errors found.
061185,000025:                                                                                                  ##              2017-08-01 MAS  Created from LMY99 Rev 1.
061186,000026: 
061187,000027:                                                                                                  ## This source code has been transcribed or otherwise adapted from
061188,000028:                                                                                                  ## digitized images of a hardcopy from the MIT Museum.  The digitization
061189,000029:                                                                                                  ## was performed by Paul Fjeld, and arranged for by Deborah Douglas of
061190,000030:                                                                                                  ## the Museum.  Many thanks to both.  The images (with suitable reduction
061191,000031:                                                                                                  ## in storage size and consequent reduction in image quality as well) are
061192,000032:                                                                                                  ## available online at www.ibiblio.org/apollo.  If for some reason you
061193,000033:                                                                                                  ## find that the images are illegible, contact me at info@sandroid.org
061194,000034:                                                                                                  ## about getting access to the (much) higher-quality images which Paul
061195,000035:                                                                                                  ## actually created.
061196,000036:                                                                                                  ##
061197,000037:                                                                                                  ## The code has been modified to match LMY99 Revision 0, otherwise
061198,000038:                                                                                                  ## known as Luminary Revision 99, the Apollo 11 software release preceeding
061199,000039:                                                                                                  ## the listing from which it was transcribed. It has been verified to
061200,000040:                                                                                                  ## contain the same bank checksums as AGC developer Allan Klumpp's listing
061201,000041:                                                                                                  ## of Luminary Revision 99 (for which we do not have scans).
061202,000042:                                                                                                  ##
061203,000043:                                                                                                  ## Notations on Allan Klumpp's listing read, in part:
061204,000044:                                                                                                  ##
061205,000045:                                                                                                  ##      ASSEMBLE REVISION 099 OF AGC PROGRAM LUMINARY BY NASA 2021112-51
061206,000046: 

Page 1397

061208,000048: 22,3773                                           BANK     22                                    
061209,000049: 10,2000                                           SETLOC   RTBCODES                              
061210,000050: 10,2000                                           BANK                                           
061211,000051: 
061212,000052: 10,3573  E5,1664                                  EBANK=   XNB                                   
061213,000053: 10,3573                                           COUNT*   $$/RTB                                
061214,000054: 
061215,000055:                                                                                                  #  LOAD TIME2, TIME1 INTO MPAC:
061216,000056: 
061217,000057: 10,3573           00006        LOADTIME           EXTEND                                         
061218,000058: 10,3574           30025                           DCA      TIME2                                 
061219,000059: 10,3575           16055                           TCF      SLOAD2                                
061220,000060: 
061221,000061:                                                                                                  #  CONVERT THE SINGLE PRECISION 2'S COMPLEMENT NUMBER ARRIVING IN MPAC (SCALED IN HALF-REVOLUTIONS) TO A
061222,000062:                                                                                                  #  DP 1'S COMPLEMENT NUMBER SCALED IN REVOLUTIONS.
061223,000063: 
061224,000064: 10,3576           10154        CDULOGIC           CCS      MPAC                                  
061225,000065: 10,3577           34755                           CAF      ZERO                                  
061226,000066: 10,3600           13603                           TCF      +3                                    
061227,000067: 10,3601           13602                           NOOP                                           
061228,000068: 10,3602           44736                           CS       HALF                                  
061229,000069: 
061230,000070: 10,3603           54155                           TS       MPAC       +1                         
061231,000071: 10,3604           34755                           CAF      ZERO                                  
061232,000072: 10,3605           56154                           XCH      MPAC                                  
061233,000073: 10,3606           00006                           EXTEND                                         
061234,000074: 10,3607           74736                           MP       HALF                                  
061235,000075: 10,3610           20155                           DAS      MPAC                                  
061236,000076: 10,3611           16061                           TCF      DANZIG                                #  MODE IS ALREADY AT DOUBLE-PRECISION
061237,000077: 
061238,000078:                                                                                                  #  FORCE TP SIGN AGREEMENT IN MPAC:
061239,000079: 
061240,000080: 10,3612           07257        SGNAGREE           TC       TPAGREE                               
061241,000081: 10,3613           16061                           TCF      DANZIG                                
061242,000082: 
061243,000083:                                                                                                  #  CONVERT THE DP 1'S COMPLEMENT ANGLE SCALED IN REVOLUTIONS TO A SINGLE PRECISION 2'S COMPLEMENT ANGLE
061244,000084:                                                                                                  #  SCALED IN HALF-REVOLUTIONS.
061245,000085: 
061246,000086: 10,3614           03644        1STO2S             TC       1TO2SUB                               
061247,000087: 10,3615           34755                           CAF      ZERO                                  
061248,000088: 10,3616           54155                           TS       MPAC       +1                         
061249,000089: 10,3617           16060                           TCF      NEWMODE                               
061250,000090: 
061251,000091:                                                                                                  #  DO 1STO2S ON A VECTOR OF ANGLES:
061252,000092: 
061253,000093: 10,3620           03644        V1STO2S            TC       1TO2SUB                               #  ANSWER ARRIVES IN A AND MPAC.
061254,000094: 
061255,000095: 10,3621           52162                           DXCH     MPAC       +5                         
061256,000096: 10,3622           52155                           DXCH     MPAC                                  
061257,000097: 10,3623           03644                           TC       1TO2SUB                               

Page 1398

061259,000099: 10,3624           54156                           TS       MPAC       +2                         
061260,000100: 
061261,000101: 10,3625           52160                           DXCH     MPAC       +3                         
061262,000102: 10,3626           52155                           DXCH     MPAC                                  
061263,000103: 10,3627           03644                           TC       1TO2SUB                               
061264,000104: 10,3630           54155                           TS       MPAC       +1                         
061265,000105: 
061266,000106: 10,3631           30161                           CA       MPAC       +5                         
061267,000107: 10,3632           54154                           TS       MPAC                                  
061268,000108: 
061269,000109: 10,3633           34753        TPMODE             CAF      ONE                                   #  MODE IS TP.
061270,000110: 10,3634           16060                           TCF      NEWMODE                               
061271,000111: 
061272,000112:                                                                                                  #  V1STO2S FOR 2 COMPONENT VECTOR. USED BY RR.
061273,000113: 
061274,000114: 10,3635           03644        2V1STO2S           TC       1TO2SUB                               
061275,000115: 10,3636           52160                           DXCH     MPAC       +3                         
061276,000116: 10,3637           52155                           DXCH     MPAC                                  
061277,000117: 10,3640           03644                           TC       1TO2SUB                               
061278,000118: 10,3641           54001                           TS       L                                     
061279,000119: 10,3642           30157                           CA       MPAC       +3                         
061280,000120: 10,3643           16055                           TCF      SLOAD2                                
061281,000121: 
061282,000122:                                                                                                  #  SUBROUTINE TO DO DOUBLING AND 1'S TO 2'S CONVERSION:
061283,000123: 
061284,000124: 10,3644           52155        1TO2SUB            DXCH     MPAC                                  #  FINAL MPAC +1 UNSPECIFIED.
061285,000125: 10,3645           20001                           DDOUBL                                         
061286,000126: 10,3646           10000                           CCS      A                                     
061287,000127: 10,3647           64753                           AD       ONE                                   
061288,000128: 10,3650           13652                           TCF      +2                                    
061289,000129: 10,3651           40000                           COM                                            #  THIS WAS REVERSE OF MSU.
061290,000130: 
061291,000131: 10,3652           54154                           TS       MPAC                                  #  AND SKIP ON OVERFLOW.
061292,000132: 10,3653           00002                           TC       Q                                     
061293,000133: 
061294,000134: 10,3654           50000                           INDEX    A                                     #  OVERFLOW UNCORRECT AND IN MSU.
061295,000135: 10,3655           34734                           CAF      LIMITS                                
061296,000136: 10,3656           26154                           ADS      MPAC                                  
061297,000137: 10,3657           00002                           TC       Q                                     
061298,000138: 
061299,000139:                                                                                                  #  THE FOLLOWING ROUTINE INCREMENTS IN 2S COMPLEMENT THE REGISTER WHOSE ADDRESS IS IN BUF BY THE 1S COMPL.
061300,000140:                                                                                                  #  QUANTITY FOUND IN TEM2.  THIS MAY BE USED TO INCREMENT DESIRED IMU AND OPTICS CDU ANGLES OR ANY OTHER 2S COMPL.
061301,000141:                                                                                                  #  (+0 UNEQUAL TO -0) QUANTITY.  MAY BE CALLED BY BANKCALL/SWCALL.
061302,000142: 
061303,000143: 10,3660           54142        CDUINC             TS       TEM2                                  #  1S COMPL.QUANT. ARRIVES IN ACC.  STORE IT
061304,000144: 10,3661           50130                           INDEX    BUF                                   
061305,000145: 10,3662           10000                           CCS      0                                     #  CHANGE 2S COMPL. ANGLE(IN BUF)INTO 1S
061306,000146: 10,3663           64753                           AD       ONE                                   
061307,000147: 10,3664           13670                           TCF      +4                                    
061308,000148: 10,3665           64753                           AD       ONE                                   

Page 1399

061310,000150: 10,3666           64753                           AD       ONE                                   #  OVERFLOW HERE IF 2S COMPL. IS 180 DEG.
061311,000151: 10,3667           40000                           COM                                            
061312,000152: 
061313,000153: 10,3670           60142                           AD       TEM2                                  #  SULT MOVES FROM 2ND TO 3D QUAD. (OR BACK)
061314,000154: 10,3671           10000                           CCS      A                                     #  BACK TO 2S COMPL.
061315,000155: 10,3672           64753                           AD       ONE                                   
061316,000156: 10,3673           13675                           TCF      +2                                    
061317,000157: 10,3674           40000                           COM                                            
061318,000158: 10,3675           54142                           TS       TEM2                                  #  STORE 14BIT QUANTITY WITH PRESENT SIGN
061319,000159: 10,3676           13702                           TCF      +4                                    
061320,000160: 10,3677           50000                           INDEX    A                                     #  SIGN.
061321,000161: 10,3700           34734                           CAF      LIMITS                                #  FIX IT, BY ADDING IN 37777 OR 40000
061322,000162: 10,3701           60142                           AD       TEM2                                  
061323,000163: 
061324,000164: 10,3702           50130                           INDEX    BUF                                   
061325,000165: 10,3703           54000                           TS       0                                     #  STORE NEW ANGLE IN 2S COMPLEMENT.
061326,000166: 10,3704           00002                           TC       Q                                     
061327,000167: 

Page 1400

061329,000169:                                                                                                  #  RTB TO TORQUE GYROS, EXCEPT FOR THE CALL TO IMUSTALL.  ECADR OF COMMANDS ARRIVES IN X1.
061330,000170: 
061331,000171: 10,3705           50120        PULSEIMU           INDEX    FIXLOC                                #  ADDRESS OF GYRO COMMANDS SHOULD BE IN X1
061332,000172: 10,3706           30046                           CA       X1                                    
061333,000173: 10,3707           04616                           TC       BANKCALL                              
061334,000174: 10,3710           17323                           CADR     IMUPULSE                              
061335,000175: 10,3711           16061                           TCF      DANZIG                                
061336,000176: 

Page 1401

061338,000178:                                                                                                  #  THE SUBROUTINE SIGNMPAC SETS C(MPAC, MPAC +1) TO SIGN(MPAC).
061339,000179:                                                                                                  #  FOR THIS, ONLY THE CONTENTS OF MPAC ARE EXAMINED.  ALSO +0 YIELDS POSMAX AND -0 YIELDS NEGMAX.
061340,000180: 
061341,000181:                                                                                                  #  ENTRY MAY BE BY EITHER OF THE FOLLOWING:
061342,000182:                                                                                                  #        1.      LIMIT THE SIZE OF MPAC ON INTERPRETIVE OVERFLOW:
061343,000183:                                                                                                  #                ENTRY:          BOVB
061344,000184:                                                                                                  #                                        SIGNMPAC
061345,000185:                                                                                                  #        2.      GENERATE IN MPAC THE SIGNUM FUNCTION OF MPAC:
061346,000186:                                                                                                  #                ENTRY:          RTB
061347,000187:                                                                                                  #                                        SIGNMPAC
061348,000188:                                                                                                  #  IN EITHER CASE, RETURN IS TO THE NEXT INTERPRETIVE INSTRUCTION IN THE CALLING SEQUENCE.
061349,000189: 
061350,000190: 10,3712           00006        SIGNMPAC           EXTEND                                         
061351,000191: 10,3713           34733                           DCA      DPOSMAX                               
061352,000192: 10,3714           52155                           DXCH     MPAC                                  
061353,000193: 10,3715           10000                           CCS      A                                     
061354,000194: 10,3716           34755        DPMODE             CAF      ZERO                                  #  SETS MPAC +2 TO ZERO IN THE PROCESS
061355,000195: 10,3717           16057                           TCF      SLOAD2     +2                         
061356,000196: 10,3720           13721                           TCF      +1                                    
061357,000197: 10,3721           00006                           EXTEND                                         
061358,000198: 10,3722           44733                           DCS      DPOSMAX                               
061359,000199: 10,3723           16055                           TCF      SLOAD2                                
061360,000200: 
061361,000201:                                                                                                  #  RTB OP CODE NORMUNIT IS LIKE INTERPRETIVE INSTRUCTION UNIT, EXCEPT THAT IT CAN BE DEPENDED ON NOT TO BLOW
061362,000202:                                                                                                  #  UP WHEN THE VECTOR BEING UNITIZED IS VERY SMALL -- IT WILL BLOW UP WHEN ALL COMPONENTS ARE ZERO.  IF NORMUNIT
061363,000203:                                                                                                  #  IS USED AND THE UPPER ORDER HALVES OF ALL COMPONENTS ARE ZERO, THE MAGNITUDE RETURNED IN 36D WILL BE TOO LARGE
061364,000204:                                                                                                  #  BY A FACTOR OF 2(13) AND THE SQUARED MAGNITUDE RETURNED AT 34D WILL BE TOO BIG BY A FACTOR OF 2(26).
061365,000205: 
061366,000206: 10,3724           34753        NORMUNX1           CAF      ONE                                   
061367,000207: 10,3725           13727                           TCF      NORMUNIT   +1                         
061368,000208: 10,3726           34755        NORMUNIT           CAF      ZERO                                  
061369,000209: 10,3727           60120                           AD       FIXLOC                                
061370,000210: 10,3730           54156                           TS       MPAC       +2                         
061371,000211: 10,3731           04616                           TC       BANKCALL                              #  GET SIGN AGREEMENT IN ALL COMPONENTS
061372,000212: 10,3732           01010                           CADR     VECAGREE                              
061373,000213: 10,3733           10154                           CCS      MPAC                                  
061374,000214: 10,3734           13770                           TCF      NOSHIFT                               
061375,000215: 10,3735           13737                           TCF      +2                                    
061376,000216: 10,3736           13770                           TCF      NOSHIFT                               
061377,000217: 10,3737           10157                           CCS      MPAC       +3                         
061378,000218: 10,3740           13770                           TCF      NOSHIFT                               
061379,000219: 10,3741           13743                           TCF      +2                                    
061380,000220: 10,3742           13770                           TCF      NOSHIFT                               
061381,000221: 10,3743           10161                           CCS      MPAC       +5                         
061382,000222: 10,3744           13770                           TCF      NOSHIFT                               
061383,000223: 10,3745           13747                           TCF      +2                                    
061384,000224: 10,3746           13770                           TCF      NOSHIFT                               

Page 1402

061386,000226: 10,3747           30155                           CA       MPAC       +1                         #  SHIFT ALL COMPONENTS LEFT 13
061387,000227: 10,3750           00006                           EXTEND                                         
061388,000228: 10,3751           74736                           MP       BIT14                                 
061389,000229: 10,3752           20155                           DAS      MPAC                                  #  DAS GAINS A LITTLE ACCURACY
061390,000230: 10,3753           30160                           CA       MPAC       +4                         
061391,000231: 10,3754           00006                           EXTEND                                         
061392,000232: 10,3755           74736                           MP       BIT14                                 
061393,000233: 10,3756           20160                           DAS      MPAC       +3                         
061394,000234: 10,3757           30162                           CA       MPAC       +6                         
061395,000235: 10,3760           00006                           EXTEND                                         
061396,000236: 10,3761           74736                           MP       BIT14                                 
061397,000237: 10,3762           20162                           DAS      MPAC       +5                         
061398,000238: 10,3763           34761                           CAF      THIRTEEN                              
061399,000239: 10,3764           50156                           INDEX    MPAC       +2                         
061400,000240: 10,3765           54045                           TS       37D                                   
061401,000241: 10,3766           04635        OFFTUNIT           TC       POSTJUMP                              
061402,000242: 10,3767           01024                           CADR     UNIT       +1                         #  SKIP THE "TC VECAGREE" DONE AT UNIT
061403,000243: 
061404,000244: 10,3770           34755        NOSHIFT            CAF      ZERO                                  
061405,000245: 10,3771           13764                           TCF      OFFTUNIT   -2                         
061406,000246: 
061407,000247:                                                                                                  #  RTB VECSGNAG ... FORCES SIGN AGREEMENT OF VECTOR IN MPAC.
061408,000248: 
061409,000249: 10,3772           04616        VECSGNAG           TC       BANKCALL                              
061410,000250: 10,3773           01010                           CADR     VECAGREE                              
061411,000251: 10,3774           06061                           TC       DANZIG                                
061412,000252: 
061413,000253: 

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