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.

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

Page 1394

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

Page 1395

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

Page 1396

060379,000124: 10,3676           64744                           AD       ONE                                   #  OVERFLOW HERE IF 2S COMPL. IS 180 DEG.
060380,000125: 10,3677           40000                           COM                                            
060381,000126: 
060382,000127: 10,3700           60142                           AD       TEM2                                  #  SULT MOVES FROM 2ND TO 3D QUAD. (OR BACK)
060383,000128: 10,3701           10000                           CCS      A                                     #  BACK TO 2S COMPL.
060384,000129: 10,3702           64744                           AD       ONE                                   
060385,000130: 10,3703           13705                           TCF      +2                                    
060386,000131: 10,3704           40000                           COM                                            
060387,000132: 10,3705           54142                           TS       TEM2                                  #  STORE 14BIT QUANTITY WITH PRESENT SIGN
060388,000133: 10,3706           13712                           TCF      +4                                    
060389,000134: 10,3707           50000                           INDEX    A                                     #   SIGN.
060390,000135: 10,3710           34725                           CAF      LIMITS                                #  FIX IT, BY ADDING IN 37777 OR 40000
060391,000136: 10,3711           60142                           AD       TEM2                                  
060392,000137: 
060393,000138: 10,3712           50130                           INDEX    BUF                                   
060394,000139: 10,3713           54000                           TS       0                                     #  STORE NEW ANGLE IN 2S COMPLEMENT.
060395,000140: 10,3714           00002                           TC       Q                                     
060396,000141: 

Page 1397

060398,000143:                                                                                                  #        RTB TO TORQUE GYROS, EXCEPT FOR THE CALL TO IMUSTALL.  ECADR OF COMMANDS ARRIVES IN X1.
060399,000144: 
060400,000145: 10,3715           50120        PULSEIMU           INDEX    FIXLOC                                #  ADDRESS OF GYRO COMMANDS SHOULD BE IN X1
060401,000146: 10,3716           30046                           CA       X1                                    
060402,000147: 10,3717           04607                           TC       BANKCALL                              
060403,000148: 10,3720           17310                           CADR     IMUPULSE                              
060404,000149: 10,3721           16102                           TCF      DANZIG                                
060405,000150: 

Page 1398

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

Page 1399

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

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