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.

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

Page 1397

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

Page 1398

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

Page 1399

061289,000150: 10,3666           64753                           AD       ONE                                   #  OVERFLOW HERE IF 2S COMPL. IS 180 DEG.
061290,000151: 10,3667           40000                           COM                                            
061291,000152: 
061292,000153: 10,3670           60142                           AD       TEM2                                  #  SULT MOVES FROM 2ND TO 3D QUAD. (OR BACK)
061293,000154: 10,3671           10000                           CCS      A                                     #  BACK TO 2S COMPL.
061294,000155: 10,3672           64753                           AD       ONE                                   
061295,000156: 10,3673           13675                           TCF      +2                                    
061296,000157: 10,3674           40000                           COM                                            
061297,000158: 10,3675           54142                           TS       TEM2                                  #  STORE 14BIT QUANTITY WITH PRESENT SIGN
061298,000159: 10,3676           13702                           TCF      +4                                    
061299,000160: 10,3677           50000                           INDEX    A                                     #  SIGN.
061300,000161: 10,3700           34734                           CAF      LIMITS                                #  FIX IT, BY ADDING IN 37777 OR 40000
061301,000162: 10,3701           60142                           AD       TEM2                                  
061302,000163: 
061303,000164: 10,3702           50130                           INDEX    BUF                                   
061304,000165: 10,3703           54000                           TS       0                                     #  STORE NEW ANGLE IN 2S COMPLEMENT.
061305,000166: 10,3704           00002                           TC       Q                                     
061306,000167: 

Page 1400

061308,000169:                                                                                                  #  RTB TO TORQUE GYROS, EXCEPT FOR THE CALL TO IMUSTALL.  ECADR OF COMMANDS ARRIVES IN X1.
061309,000170: 
061310,000171: 10,3705           50120        PULSEIMU           INDEX    FIXLOC                                #  ADDRESS OF GYRO COMMANDS SHOULD BE IN X1
061311,000172: 10,3706           30046                           CA       X1                                    
061312,000173: 10,3707           04616                           TC       BANKCALL                              
061313,000174: 10,3710           17323                           CADR     IMUPULSE                              
061314,000175: 10,3711           16061                           TCF      DANZIG                                
061315,000176: 

Page 1401

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

Page 1402

061365,000226: 10,3747           30155                           CA       MPAC       +1                         #  SHIFT ALL COMPONENTS LEFT 13
061366,000227: 10,3750           00006                           EXTEND                                         
061367,000228: 10,3751           74736                           MP       BIT14                                 
061368,000229: 10,3752           20155                           DAS      MPAC                                  #  DAS GAINS A LITTLE ACCURACY
061369,000230: 10,3753           30160                           CA       MPAC       +4                         
061370,000231: 10,3754           00006                           EXTEND                                         
061371,000232: 10,3755           74736                           MP       BIT14                                 
061372,000233: 10,3756           20160                           DAS      MPAC       +3                         
061373,000234: 10,3757           30162                           CA       MPAC       +6                         
061374,000235: 10,3760           00006                           EXTEND                                         
061375,000236: 10,3761           74736                           MP       BIT14                                 
061376,000237: 10,3762           20162                           DAS      MPAC       +5                         
061377,000238: 10,3763           34761                           CAF      THIRTEEN                              
061378,000239: 10,3764           50156                           INDEX    MPAC       +2                         
061379,000240: 10,3765           54045                           TS       37D                                   
061380,000241: 10,3766           04635        OFFTUNIT           TC       POSTJUMP                              
061381,000242: 10,3767           01024                           CADR     UNIT       +1                         #  SKIP THE "TC VECAGREE" DONE AT UNIT
061382,000243: 
061383,000244: 10,3770           34755        NOSHIFT            CAF      ZERO                                  
061384,000245: 10,3771           13764                           TCF      OFFTUNIT   -2                         
061385,000246: 
061386,000247:                                                                                                  #  RTB VECSGNAG ... FORCES SIGN AGREEMENT OF VECTOR IN MPAC.
061387,000248: 
061388,000249: 10,3772           04616        VECSGNAG           TC       BANKCALL                              
061389,000250: 10,3773           01010                           CADR     VECAGREE                              
061390,000251: 10,3774           06061                           TC       DANZIG                                
061391,000252: 
061392,000253: 

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