Source Code

These source-code files derive from a printout of Luminary 210 (Apollo 15-17 Lunar Module guidance computer program), from the personal library of original AGC developer Don Eyles, digitally photographed at archive.org, financially sponsored by Jim Lawton, and transcribed to source code by a team of volunteers. This colorized, syntax-highlighted form was created by assembling that transcribed source code. Note that the full page images are available on the Virtual AGC project page at archive.org, while reduced-size images are presented at the VirtualAGC project website. Report or fix any transcription errors at the Virtual AGC project code repository.

Notations on the program listing read, in part:

	GAP: ASSEMBLE REVISION 210 OF AGC PROGRAM LUMINARY 
	BY NASA 2021112-161 17:11 MAR. 19,1971
Note that the date is the date of the printout, not the date of the program revision.

060243,000002:                                                                                                  ## Copyright:   Public domain.
060244,000003:                                                                                                  ## Filename:    RTB_OP_CODES.agc
060245,000004:                                                                                                  ## Purpose:     A section of Luminary revision 210.
060246,000005:                                                                                                  ##              It is part of the source code for the Lunar Module's (LM)
060247,000006:                                                                                                  ##              Apollo Guidance Computer (AGC) for Apollo 15-17.
060248,000007:                                                                                                  ##              This file is intended to be a faithful transcription, except
060249,000008:                                                                                                  ##              that the code format has been changed to conform to the
060250,000009:                                                                                                  ##              requirements of the yaYUL assembler rather than the
060251,000010:                                                                                                  ##              original YUL assembler.
060252,000011:                                                                                                  ## Reference:   pp. 1394-1399
060253,000012:                                                                                                  ## Assembler:   yaYUL
060254,000013:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
060255,000014:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
060256,000015:                                                                                                  ## Mod history: 2016-11-17 JL   Created from Luminary131 version.
060257,000016:                                                                                                  ##              2016-12-06 RRB  Updated from Luminary210 scans.
060258,000017:                                                                                                  ##              2016-12-09 HG   Add missing SETLOC RTBCODES (changes to Bank 10, because Bank 14 is full)
060259,000018:                                                                                                  ##              2016-12-26 RSB  Comment-text proofed using ProoferComments
060260,000019:                                                                                                  ##                              and corrected errors found.
060261,000020: 

Page 1394

060263,000022: 22,3774                                           BANK     22                                    
060264,000023: 10,2000                                           SETLOC   RTBCODES                              
060265,000024: 10,2000                                           BANK                                           
060266,000025: 
060267,000026: 10,3603  E5,1664                                  EBANK=   XNB                                   
060268,000027: 10,3603                                           COUNT*   $$/RTB                                
060269,000028: 
060270,000029:                                                                                                  #        LOAD TIME2, TIME1 INTO MPAC:
060271,000030: 
060272,000031: 10,3603           00006        LOADTIME           EXTEND                                         
060273,000032: 10,3604           30025                           DCA      TIME2                                 
060274,000033: 10,3605           16076                           TCF      SLOAD2                                
060275,000034: 
060276,000035:                                                                                                  #        CONVERT THE SINGLE PRECISION 2'S COMPLEMENT NUMBER ARRIVING IN MPAC (SCALED IN HALF-REVOLUTIONS) TO A
060277,000036:                                                                                                  #  DP 1'S COMPLEMENT NUMBER SCALED IN REVOLUTIONS.
060278,000037: 
060279,000038: 10,3606           10154        CDULOGIC           CCS      MPAC                                  
060280,000039: 10,3607           34746                           CAF      ZERO                                  
060281,000040: 10,3610           13613                           TCF      +3                                    
060282,000041: 10,3611           13612                           NOOP                                           
060283,000042: 10,3612           44727                           CS       HALF                                  
060284,000043: 
060285,000044: 10,3613           54155                           TS       MPAC       +1                         
060286,000045: 10,3614           34746                           CAF      ZERO                                  
060287,000046: 10,3615           56154                           XCH      MPAC                                  
060288,000047: 10,3616           00006                           EXTEND                                         
060289,000048: 10,3617           74727                           MP       HALF                                  
060290,000049: 10,3620           20155                           DAS      MPAC                                  
060291,000050: 10,3621           16102                           TCF      DANZIG                                #  MODE IS ALREADY AT DOUBLE-PRECISION
060292,000051: 
060293,000052:                                                                                                  #        FORCE TP SIGN AGREEMENT IN MPAC:
060294,000053: 
060295,000054: 10,3622           07300        SGNAGREE           TC       TPAGREE                               
060296,000055: 10,3623           16102                           TCF      DANZIG                                
060297,000056: 
060298,000057:                                                                                                  #        CONVERT THE DP 1'S COMPLEMENT ANGLE SCALED IN REVOLUTIONS TO A SINGLE PRECISION 2'S COMPLEMENT ANGLE
060299,000058:                                                                                                  #  SCALED IN HALF-REVOLUTIONS.
060300,000059: 
060301,000060: 10,3624           03654        1STO2S             TC       1TO2SUB                               
060302,000061: 10,3625           34746                           CAF      ZERO                                  
060303,000062: 10,3626           54155                           TS       MPAC       +1                         
060304,000063: 10,3627           16101                           TCF      NEWMODE                               
060305,000064: 
060306,000065:                                                                                                  #        DO 1STO2S ON A VECTOR OF ANGLES:
060307,000066: 
060308,000067: 10,3630           03654        V1STO2S            TC       1TO2SUB                               #  ANSWER ARRIVES IN A AND MPAC.
060309,000068: 
060310,000069: 10,3631           52162                           DXCH     MPAC       +5                         
060311,000070: 10,3632           52155                           DXCH     MPAC                                  
060312,000071: 10,3633           03654                           TC       1TO2SUB                               

Page 1395

060314,000073: 10,3634           54156                           TS       MPAC       +2                         
060315,000074: 
060316,000075: 10,3635           52160                           DXCH     MPAC       +3                         
060317,000076: 10,3636           52155                           DXCH     MPAC                                  
060318,000077: 10,3637           03654                           TC       1TO2SUB                               
060319,000078: 10,3640           54155                           TS       MPAC       +1                         
060320,000079: 
060321,000080: 10,3641           30161                           CA       MPAC       +5                         
060322,000081: 10,3642           54154                           TS       MPAC                                  
060323,000082: 
060324,000083: 10,3643           34744        TPMODE             CAF      ONE                                   #  MODE IS TP.
060325,000084: 10,3644           16101                           TCF      NEWMODE                               
060326,000085: 
060327,000086:                                                                                                  #        V1STO2S FOR 2 COMPONENT VECTOR. USED BY RR.
060328,000087: 
060329,000088: 10,3645           03654        2V1STO2S           TC       1TO2SUB                               
060330,000089: 10,3646           52160                           DXCH     MPAC       +3                         
060331,000090: 10,3647           52155                           DXCH     MPAC                                  
060332,000091: 10,3650           03654                           TC       1TO2SUB                               
060333,000092: 10,3651           54001                           TS       L                                     
060334,000093: 10,3652           30157                           CA       MPAC       +3                         
060335,000094: 10,3653           16076                           TCF      SLOAD2                                
060336,000095: 
060337,000096:                                                                                                  #        SUBROUTINE TO DO DOUBLING AND 1'S TO 2'S CONVERSION:
060338,000097: 
060339,000098: 10,3654           52155        1TO2SUB            DXCH     MPAC                                  #  FINAL MPAC +1 UNSPECIFIED.
060340,000099: 10,3655           20001                           DDOUBL                                         
060341,000100: 10,3656           10000                           CCS      A                                     
060342,000101: 10,3657           64744                           AD       ONE                                   
060343,000102: 10,3660           13662                           TCF      +2                                    
060344,000103: 10,3661           40000                           COM                                            #  THIS WAS REVERSE OF MSU.
060345,000104: 
060346,000105: 10,3662           54154                           TS       MPAC                                  #  AND SKIP ON OVERFLOW.
060347,000106: 10,3663           00002                           TC       Q                                     
060348,000107: 
060349,000108: 10,3664           50000                           INDEX    A                                     #  OVERFLOW UNCORRECT AND IN MSU.
060350,000109: 10,3665           34725                           CAF      LIMITS                                
060351,000110: 10,3666           26154                           ADS      MPAC                                  
060352,000111: 10,3667           00002                           TC       Q                                     
060353,000112: 
060354,000113:                                                                                                  #        THE FOLLOWING ROUTINE INCREMENTS IN 2S COMPLEMENT THE REGISTER WHOSE ADDRESS IS IN BUF BY THE 1S COMPL.
060355,000114:                                                                                                  #  QUANTITY FOUND IN TEM2.  THIS MAY BE USED TO INCREMENT DESIRED IMU AND OPTICS CDU ANGLES OR ANY OTHER 2S COMPL.
060356,000115:                                                                                                  #  (+0 UNEQUAL TO -0) QUANTITY.  MAY BE CALLED BY BANKCALL/SWCALL.
060357,000116: 
060358,000117: 10,3670           54142        CDUINC             TS       TEM2                                  #  1S COMPL.QUANT. ARRIVES IN ACC.  STORE IT
060359,000118: 10,3671           50130                           INDEX    BUF                                   
060360,000119: 10,3672           10000                           CCS      0                                     #  CHANGE 2S COMPL. ANGLE(IN BUF)INTO 1S
060361,000120: 10,3673           64744                           AD       ONE                                   
060362,000121: 10,3674           13700                           TCF      +4                                    
060363,000122: 10,3675           64744                           AD       ONE                                   

Page 1396

060365,000124: 10,3676           64744                           AD       ONE                                   #  OVERFLOW HERE IF 2S COMPL. IS 180 DEG.
060366,000125: 10,3677           40000                           COM                                            
060367,000126: 
060368,000127: 10,3700           60142                           AD       TEM2                                  #  SULT MOVES FROM 2ND TO 3D QUAD. (OR BACK)
060369,000128: 10,3701           10000                           CCS      A                                     #  BACK TO 2S COMPL.
060370,000129: 10,3702           64744                           AD       ONE                                   
060371,000130: 10,3703           13705                           TCF      +2                                    
060372,000131: 10,3704           40000                           COM                                            
060373,000132: 10,3705           54142                           TS       TEM2                                  #  STORE 14BIT QUANTITY WITH PRESENT SIGN
060374,000133: 10,3706           13712                           TCF      +4                                    
060375,000134: 10,3707           50000                           INDEX    A                                     #   SIGN.
060376,000135: 10,3710           34725                           CAF      LIMITS                                #  FIX IT, BY ADDING IN 37777 OR 40000
060377,000136: 10,3711           60142                           AD       TEM2                                  
060378,000137: 
060379,000138: 10,3712           50130                           INDEX    BUF                                   
060380,000139: 10,3713           54000                           TS       0                                     #  STORE NEW ANGLE IN 2S COMPLEMENT.
060381,000140: 10,3714           00002                           TC       Q                                     
060382,000141: 

Page 1397

060384,000143:                                                                                                  #        RTB TO TORQUE GYROS, EXCEPT FOR THE CALL TO IMUSTALL.  ECADR OF COMMANDS ARRIVES IN X1.
060385,000144: 
060386,000145: 10,3715           50120        PULSEIMU           INDEX    FIXLOC                                #  ADDRESS OF GYRO COMMANDS SHOULD BE IN X1
060387,000146: 10,3716           30046                           CA       X1                                    
060388,000147: 10,3717           04607                           TC       BANKCALL                              
060389,000148: 10,3720           17310                           CADR     IMUPULSE                              
060390,000149: 10,3721           16102                           TCF      DANZIG                                
060391,000150: 

Page 1398

060393,000152:                                                                                                  #        THE SUBROUTINE SIGNMPAC SETS C(MPAC, MPAC +1) TO SIGN(MPAC).
060394,000153:                                                                                                  #  FOR THIS, ONLY THE CONTENTS OF MPAC ARE EXAMINED.  ALSO +0 YIELDS POSMAX AND -0 YIELDS NEGMAX.
060395,000154: 
060396,000155:                                                                                                  #  ENTRY MAY BE BY EITHER OF THE FOLLOWING:
060397,000156:                                                                                                  #  1.    LIMIT THE SIZE OF MPAC ON INTERPRETIVE OVERFLOW:
060398,000157:                                                                                                  #  ENTRY:        BOVB
060399,000158:                                                                                                  #                        SIGNMPAC
060400,000159:                                                                                                  #  2.    GENERATE IN MPAC THE SIGNUM FUNCTION OF MPAC:
060401,000160:                                                                                                  #  ENTRY:        RTB
060402,000161:                                                                                                  #                                SIGNMPAC
060403,000162:                                                                                                  #  IN EITHER CASE, RETURN IS TO  THE NEXT INTERPRETIVE INSTRUCTION IN THE CALLING SEQUENCE.
060404,000163: 
060405,000164: 14,2000                                           SETLOC   RTBCODE1                              
060406,000165: 14,2000                                           BANK                                           
060407,000166: 
060408,000167: 14,3765           00006        SIGNMPAC           EXTEND                                         
060409,000168: 14,3766           34724                           DCA      DPOSMAX                               
060410,000169: 14,3767           52155                           DXCH     MPAC                                  
060411,000170: 14,3770           10000                           CCS      A                                     
060412,000171: 14,3771           34746        DPMODE             CAF      ZERO                                  #  SETS MPAC +2 TO ZERO IN THE PROCESS
060413,000172: 14,3772           16100                           TCF      SLOAD2     +2                         
060414,000173: 14,3773           13774                           TCF      +1                                    
060415,000174: 14,3774           00006                           EXTEND                                         
060416,000175: 14,3775           44724                           DCS      DPOSMAX                               
060417,000176: 14,3776           16076                           TCF      SLOAD2                                
060418,000177: 
060419,000178: 10,2000                                           SETLOC   RTBCODES                              
060420,000179: 10,2000                                           BANK                                           
060421,000180: 
060422,000181:                                                                                                  #        RTB OP CODE NORMUNIT IS LIKE INTERPRETIVE INSTRUCTION UNIT, EXCEPT THAT IT CAN BE DEPENDED ON NOT TO BLOW
060423,000182:                                                                                                  #  UP WHEN THE VECTOR BEING UNITIZED IS VERY SMALL -- IT WILL BLOW UP WHEN ALL COMPONENTS ARE ZERO.  IF NORMUNIT
060424,000183:                                                                                                  #  IS USED AND THE UPPER ORDER HALVES OF ALL COMPONENTS ARE ZERO, THE MAGNITUDE RETURNED IN 36D WILL BE TOO LARGE
060425,000184:                                                                                                  #  BY A FACTOR OF 2(13) AND THE SQUARED MAGNITUDE RETURNED AT 34D WILL BE TOO BIG BY A FACTOR OF 2(26).
060426,000185: 
060427,000186: 10,3722           34744        NORMUNX1           CAF      ONE                                   
060428,000187: 10,3723           13725                           TCF      NORMUNIT   +1                         
060429,000188: 10,3724           34746        NORMUNIT           CAF      ZERO                                  
060430,000189: 10,3725           60120                           AD       FIXLOC                                
060431,000190: 10,3726           54156                           TS       MPAC       +2                         
060432,000191: 10,3727           04607                           TC       BANKCALL                              #  GET SIGN AGREEMENT IN ALL COMPONENTS
060433,000192: 10,3730           01010                           CADR     VECAGREE                              
060434,000193: 10,3731           10154                           CCS      MPAC                                  
060435,000194: 10,3732           13766                           TCF      NOSHIFT                               
060436,000195: 10,3733           13735                           TCF      +2                                    
060437,000196: 10,3734           13766                           TCF      NOSHIFT                               
060438,000197: 10,3735           10157                           CCS      MPAC       +3                         
060439,000198: 10,3736           13766                           TCF      NOSHIFT                               

Page 1399

060441,000200: 10,3737           13741                           TCF      +2                                    
060442,000201: 10,3740           13766                           TCF      NOSHIFT                               
060443,000202: 10,3741           10161                           CCS      MPAC       +5                         
060444,000203: 10,3742           13766                           TCF      NOSHIFT                               
060445,000204: 10,3743           13745                           TCF      +2                                    
060446,000205: 10,3744           13766                           TCF      NOSHIFT                               
060447,000206: 10,3745           30155                           CA       MPAC       +1                         #  SHIFT ALL COMPONENTS LEFT 13
060448,000207: 10,3746           00006                           EXTEND                                         
060449,000208: 10,3747           74727                           MP       BIT14                                 
060450,000209: 10,3750           20155                           DAS      MPAC                                  #  DAS GAINS A LITTLE ACCURACY
060451,000210: 10,3751           30160                           CA       MPAC       +4                         
060452,000211: 10,3752           00006                           EXTEND                                         
060453,000212: 10,3753           74727                           MP       BIT14                                 
060454,000213: 10,3754           20160                           DAS      MPAC       +3                         
060455,000214: 10,3755           30162                           CA       MPAC       +6                         
060456,000215: 10,3756           00006                           EXTEND                                         
060457,000216: 10,3757           74727                           MP       BIT14                                 
060458,000217: 10,3760           20162                           DAS      MPAC       +5                         
060459,000218: 10,3761           34752                           CAF      THIRTEEN                              
060460,000219: 10,3762           50156                           INDEX    MPAC       +2                         
060461,000220: 10,3763           54045                           TS       37D                                   
060462,000221: 10,3764           04626        OFFTUNIT           TC       POSTJUMP                              
060463,000222: 10,3765           01024                           CADR     UNIT       +1                         #  SKIP THE "TC VECAGREE" DONE AT UNIT
060464,000223: 
060465,000224: 10,3766           34746        NOSHIFT            CAF      ZERO                                  
060466,000225: 10,3767           13762                           TCF      OFFTUNIT   -2                         
060467,000226: 
060468,000227:                                                                                                  #  RTB VECSGNAG ... FORCES SIGN AGREEMENT OF VECTOR IN MPAC.
060469,000228: 
060470,000229: 10,3770           04607        VECSGNAG           TC       BANKCALL                              
060471,000230: 10,3771           01010                           CADR     VECAGREE                              
060472,000231: 10,3772           06102                           TC       DANZIG                                
060473,000232: 

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