Source Code

These source code files are a reconstruction of Sundance, the Apollo 9 LM (Lunar Module) AGC (Apollo Guidance Computer) flight software, created from binary dumps of original core rope program modules, as follows:
  • B1 — Revision 292
  • B2 — Revision 302
  • B3 — Revision 302
  • B4 — Revision 302
  • B5 — Revision 292
  • B6 — Revision 306
This means that source code does not represent a specific historical revision of Sundance, but rather a mixture of the three released versions. Nonetheless, it is capable of flying the whole Apollo 9 mission. This source code matches the binary dumps, as closely as feasible, but 100% match is not possible, due mostly to changes in memory addresses at which code and variables were allocated in different revisions of Sundance. Refer to this list of explanations for each binary mismatch.

Since only binary dumps (rather than listings) of Sundance are available as source material, all comments and labels are approximate. They have been taken from other AGC programs where possible, or, in some places, written from scratch to match what we believe would have been in the original listing.

054932,000002:                                                                                                  ## Copyright:   Public domain.
054933,000003:                                                                                                  ## Filename:    RTB_OP_CODES.agc
054934,000004:                                                                                                  ## Purpose:     A section of a reconstructed, mixed version of Sundance
054935,000005:                                                                                                  ##              It is part of the reconstructed source code for the Lunar
054936,000006:                                                                                                  ##              Module's (LM) Apollo Guidance Computer (AGC) for Apollo 9.
054937,000007:                                                                                                  ##              No original listings of this program are available;
054938,000008:                                                                                                  ##              instead, this file was created via disassembly of dumps
054939,000009:                                                                                                  ##              of various revisions of Sundance core rope modules.
054940,000010:                                                                                                  ## Assembler:   yaYUL
054941,000011:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
054942,000012:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
054943,000013:                                                                                                  ## Mod history: 2020-06-17 MAS  Created from Luminary 69.
054944,000014: 
054945,000015:                                                                                                  ## Sundance 302
054946,000016: 
054947,000017: 22,3644                                           BANK     22                                    
054948,000018: 10,2000                                           SETLOC   RTBCODES                              
054949,000019: 10,2000                                           BANK                                           
054950,000020: 
054951,000021: 10,3454  E5,1664                                  EBANK=   XNB                                   
054952,000022: 10,3454                                           COUNT*   $$/RTB                                
054953,000023: 
054954,000024:                                                                                                  #  LOAD TIME2, TIME1 INTO MPAC:
054955,000025: 
054956,000026: 10,3454           00006        LOADTIME           EXTEND                                         
054957,000027: 10,3455           30025                           DCA      TIME2                                 
054958,000028: 10,3456           16031                           TCF      SLOAD2                                
054959,000029: 
054960,000030:                                                                                                  #  CONVERT THE SINGLE PRECISION 2'S COMPLEMENT NUMBER ARRIVING IN MPAC (SCALED IN HALF-REVOLUTIONS) TO A
054961,000031:                                                                                                  #  DP 1'S COMPLEMENT NUMBER SCALED IN REVOLUTIONS.
054962,000032: 
054963,000033: 10,3457           10154        CDULOGIC           CCS      MPAC                                  
054964,000034: 10,3460           35030                           CAF      ZERO                                  
054965,000035: 10,3461           13464                           TCF      +3                                    
054966,000036: 10,3462           13463                           NOOP                                           
054967,000037: 10,3463           45011                           CS       HALF                                  
054968,000038: 
054969,000039: 10,3464           54155                           TS       MPAC       +1                         
054970,000040: 10,3465           35030                           CAF      ZERO                                  
054971,000041: 10,3466           56154                           XCH      MPAC                                  
054972,000042: 10,3467           00006                           EXTEND                                         
054973,000043: 10,3470           75011                           MP       HALF                                  
054974,000044: 10,3471           20155                           DAS      MPAC                                  
054975,000045: 10,3472           16035                           TCF      DANZIG                                #  MODE IS ALREADY AT DOUBLE-PRECISION
054976,000046: 
054977,000047:                                                                                                  #  READ THE PIPS INTO MPAC WITHOUT CHANGING THEM:
054978,000048: 
054979,000049: 10,3473           00004        READPIPS           INHINT                                         
054980,000050: 10,3474           30037                           CA       PIPAX                                 
054981,000051: 10,3475           54154                           TS       MPAC                                  
054982,000052: 10,3476           30040                           CA       PIPAY                                 
054983,000053: 10,3477           54157                           TS       MPAC       +3                         
054984,000054: 10,3500           30041                           CA       PIPAZ                                 
054985,000055: 10,3501           00003                           RELINT                                         
054986,000056: 10,3502           54161                           TS       MPAC       +5                         
054987,000057: 
054988,000058: 10,3503           35030                           CAF      ZERO                                  
054989,000059: 10,3504           54155                           TS       MPAC       +1                         
054990,000060: 10,3505           54160                           TS       MPAC       +4                         
054991,000061: 10,3506           54162                           TS       MPAC       +6                         
054992,000062: 
054993,000063: 10,3507           16475        VECMODE            TCF      VMODE                                 
054994,000064: 
054995,000065:                                                                                                  #  FORCE TP SIGN AGREEMENT IN MPAC:
054996,000066: 
054997,000067: 10,3510           07231        SGNAGREE           TC       TPAGREE                               
054998,000068: 10,3511           16035                           TCF      DANZIG                                
054999,000069: 
055000,000070:                                                                                                  #  CONVERT THE DP 1'S COMPLEMENT ANGLE SCALED IN REVOLUTIONS TO A SINGLE PRECISION 2'S COMPLEMENT ANGLE
055001,000071:                                                                                                  #  SCALED IN HALF-REVOLUTIONS.
055002,000072: 
055003,000073: 10,3512           03542        1STO2S             TC       1TO2SUB                               
055004,000074: 10,3513           35030                           CAF      ZERO                                  
055005,000075: 10,3514           54155                           TS       MPAC       +1                         
055006,000076: 10,3515           16034                           TCF      NEWMODE                               
055007,000077: 
055008,000078:                                                                                                  #  DO 1STO2S ON A VECTOR OF ANGLES:
055009,000079: 
055010,000080: 10,3516           03542        V1STO2S            TC       1TO2SUB                               #  ANSWER ARRIVES IN A AND MPAC.
055011,000081: 
055012,000082: 10,3517           52162                           DXCH     MPAC       +5                         
055013,000083: 10,3520           52155                           DXCH     MPAC                                  
055014,000084: 10,3521           03542                           TC       1TO2SUB                               
055015,000085: 10,3522           54156                           TS       MPAC       +2                         
055016,000086: 
055017,000087: 10,3523           52160                           DXCH     MPAC       +3                         
055018,000088: 10,3524           52155                           DXCH     MPAC                                  
055019,000089: 10,3525           03542                           TC       1TO2SUB                               
055020,000090: 10,3526           54155                           TS       MPAC       +1                         
055021,000091: 
055022,000092: 10,3527           30161                           CA       MPAC       +5                         
055023,000093: 10,3530           54154                           TS       MPAC                                  
055024,000094: 
055025,000095: 10,3531           35026        TPMODE             CAF      ONE                                   #  MODE IS TP.
055026,000096: 10,3532           16034                           TCF      NEWMODE                               
055027,000097: 
055028,000098:                                                                                                  #  V1STO2S FOR 2 COMPONENT VECTOR. USED BY RR.
055029,000099: 
055030,000100: 10,3533           03542        2V1STO2S           TC       1TO2SUB                               
055031,000101: 10,3534           52160                           DXCH     MPAC       +3                         
055032,000102: 10,3535           52155                           DXCH     MPAC                                  
055033,000103: 10,3536           03542                           TC       1TO2SUB                               
055034,000104: 10,3537           54001                           TS       L                                     
055035,000105: 10,3540           30157                           CA       MPAC       +3                         
055036,000106: 10,3541           16031                           TCF      SLOAD2                                
055037,000107: 
055038,000108:                                                                                                  #  SUBROUTINE TO DO DOUBLING AND 1'S TO 2'S CONVERSION:
055039,000109: 
055040,000110: 10,3542           52155        1TO2SUB            DXCH     MPAC                                  #  FINAL MPAC +1 UNSPECIFIED.
055041,000111: 10,3543           20001                           DDOUBL                                         
055042,000112: 10,3544           10000                           CCS      A                                     
055043,000113: 10,3545           65026                           AD       ONE                                   
055044,000114: 10,3546           13550                           TCF      +2                                    
055045,000115: 10,3547           40000                           COM                                            #  THIS WAS REVERSE OF MSU.
055046,000116: 
055047,000117: 10,3550           54154                           TS       MPAC                                  #  AND SKIP ON OVERFLOW.
055048,000118: 10,3551           00002                           TC       Q                                     
055049,000119: 
055050,000120: 10,3552           50000                           INDEX    A                                     #  OVERFLOW UNCORRECT AND IN MSU.
055051,000121: 10,3553           35007                           CAF      LIMITS                                
055052,000122: 10,3554           26154                           ADS      MPAC                                  
055053,000123: 10,3555           00002                           TC       Q                                     
055054,000124:                                                                                                  #  SUBROUTINE TO INCREMENT CDUS
055055,000125: 10,3556           33571        INCRCDUS           CAF      LOCTHETA                              
055056,000126: 10,3557           54130                           TS       BUF                                   #  PLACE ADRES(THETA) IN BUF.
055057,000127: 10,3560           30154                           CAE      MPAC                                  #  INCREMENT IN 1S COMPL.
055058,000128: 10,3561           03572                           TC       CDUINC                                
055059,000129: 
055060,000130: 10,3562           24130                           INCR     BUF                                   
055061,000131: 10,3563           30157                           CAE      MPAC       +3                         
055062,000132: 10,3564           03572                           TC       CDUINC                                
055063,000133: 
055064,000134: 10,3565           24130                           INCR     BUF                                   
055065,000135: 10,3566           30161                           CAE      MPAC       +5                         
055066,000136: 10,3567           03572                           TC       CDUINC                                
055067,000137: 
055068,000138: 10,3570           13507                           TCF      VECMODE                               
055069,000139: 
055070,000140: 10,3571           01206        LOCTHETA           ADRES    THETAD                                
055071,000141: 
055072,000142:                                                                                                  #  THE FOLLOWING ROUTINE INCREMENTS IN 2S COMPLEMENT THE REGISTER WHOSE ADDRESS IS IN BUF BY THE 1S COMPL.
055073,000143:                                                                                                  #  QUANTITY FOUND IN TEM2.  THIS MAY BE USED TO INCREMENT DESIRED IMU AND OPTICS CDU ANGLES OR ANY OTHER 2S COMPL.
055074,000144:                                                                                                  #  (+0 UNEQUAL TO -0) QUANTITY.  MAY BE CALLED BY BANKCALL/SWCALL.
055075,000145: 
055076,000146: 10,3572           54142        CDUINC             TS       TEM2                                  #  1S COMPL.QUANT. ARRIVES IN ACC.  STORE IT
055077,000147: 10,3573           50130                           INDEX    BUF                                   
055078,000148: 10,3574           10000                           CCS      0                                     #  CHANGE 2S COMPL. ANGLE(IN BUF)INTO 1S
055079,000149: 10,3575           65026                           AD       ONE                                   
055080,000150: 10,3576           13602                           TCF      +4                                    
055081,000151: 10,3577           65026                           AD       ONE                                   
055082,000152: 10,3600           65026                           AD       ONE                                   #  OVERFLOW HERE IF 2S COMPL. IS 180 DEG.
055083,000153: 10,3601           40000                           COM                                            
055084,000154: 
055085,000155: 10,3602           60142                           AD       TEM2                                  #  SULT MOVES FROM 2ND TO 3D QUAD.(OR BACK)
055086,000156: 10,3603           10000                           CCS      A                                     #  BACK TO 2S COMPL.
055087,000157: 10,3604           65026                           AD       ONE                                   
055088,000158: 10,3605           13607                           TCF      +2                                    
055089,000159: 10,3606           40000                           COM                                            
055090,000160: 10,3607           54142                           TS       TEM2                                  #  STORE 14BIT QUANTITY WITH PRESENT SIGN
055091,000161: 10,3610           13614                           TCF      +4                                    
055092,000162: 10,3611           50000                           INDEX    A                                     #   SIGN.
055093,000163: 10,3612           35007                           CAF      LIMITS                                #  FIX IT, BY ADDING IN 37777 OR 40000
055094,000164: 10,3613           60142                           AD       TEM2                                  
055095,000165: 
055096,000166: 10,3614           50130                           INDEX    BUF                                   
055097,000167: 10,3615           54000                           TS       0                                     #  STORE NEW ANGLE IN 2S COMPLEMENT.
055098,000168: 10,3616           00002                           TC       Q                                     
055099,000169: 
055100,000170:                                                                                                  #  RTB TO TORQUE GYROS, EXCEPT FOR THE CALL TO IMUSTALL. ECADR OF COMMANDS ARRIVES IN X1.
055101,000171: 
055102,000172: 10,3617           50120        PULSEIMU           INDEX    FIXLOC                                #  ADDRESS OF GYRO COMMANDS SHOULD BE IN X1
055103,000173: 10,3620           30046                           CA       X1                                    
055104,000174: 10,3621           04655                           TC       BANKCALL                              
055105,000175: 10,3622           17234                           CADR     IMUPULSE                              
055106,000176: 10,3623           16035                           TCF      DANZIG                                
055107,000177: 
055108,000178:                                                                                                  #  EACH ROUTINE TAKES A 3X3 MATRIX STORED IN DOUBLE PRECISION IN A FIXED AREA OF ERASABLE MEMORY AND REPLACES IT
055109,000179:                                                                                                  #  WITH THE TRANSPOSE MATRIX. TRANSP1 USES LOCATIONS XNB+0,+1 THROUGH XNB+16D, 17D AND TRANSP2 USES LOCATIONS
055110,000180:                                                                                                  #  XNB1+0,+1 THROUGH XNB1+16D, 17D. EACH MATRIX IS STORED BY ROWS.
055111,000181: 
055112,000182: 10,3624           02664        XNBEB              ECADR    XNB                                   
055113,000183: 10,3625           03456        XNB1EB             ECADR    XNB1                                  
055114,000184: 
055115,000185: 10,3626  E5,1664                                  EBANK=   XNB                                   
055116,000186: 
055117,000187: 10,3626           33624        TRANSP1            CAF      XNBEB                                 
055118,000188: 10,3627           54003                           TS       EBANK                                 
055119,000189: 10,3630           53667                           DXCH     XNB        +2                         
055120,000190: 10,3631           53673                           DXCH     XNB        +6                         
055121,000191: 10,3632           53667                           DXCH     XNB        +2                         
055122,000192: 
055123,000193: 10,3633           53671                           DXCH     XNB        +4                         
055124,000194: 10,3634           53701                           DXCH     XNB        +12D                       
055125,000195: 10,3635           53671                           DXCH     XNB        +4                         
055126,000196: 
055127,000197: 10,3636           53677                           DXCH     XNB        +10D                       
055128,000198: 10,3637           53703                           DXCH     XNB        +14D                       
055129,000199: 10,3640           53677                           DXCH     XNB        +10D                       
055130,000200: 10,3641           16035                           TCF      DANZIG                                
055131,000201: 
055132,000202: 10,3642  E7,1456                                  EBANK=   XNB1                                  
055133,000203: 
055134,000204: 10,3642           33625        TRANSP2            CAF      XNB1EB                                
055135,000205: 10,3643           54003                           TS       EBANK                                 
055136,000206: 10,3644           53461                           DXCH     XNB1       +2                         
055137,000207: 10,3645           53465                           DXCH     XNB1       +6                         
055138,000208: 10,3646           53461                           DXCH     XNB1       +2                         
055139,000209: 
055140,000210: 10,3647           53463                           DXCH     XNB1       +4                         
055141,000211: 10,3650           53473                           DXCH     XNB1       +12D                       
055142,000212: 10,3651           53463                           DXCH     XNB1       +4                         
055143,000213: 
055144,000214: 10,3652           53471                           DXCH     XNB1       +10D                       
055145,000215: 10,3653           53475                           DXCH     XNB1       +14D                       
055146,000216: 10,3654           53471                           DXCH     XNB1       +10D                       
055147,000217: 10,3655           16035                           TCF      DANZIG                                
055148,000218: 
055149,000219:                                                                                                  #  THE SUBROUTINE SIGNMPAC SETS C(MPAC, MPAC +1) TO SIGN(MPAC).
055150,000220:                                                                                                  #  FOR THIS, ONLY THE CONTENTS OF MPAC ARE EXAMINED.  ALSO +0 YIELDS POSMAX AND -0 YIELDS NEGMAX.
055151,000221: 
055152,000222:                                                                                                  #  ENTRY MAY BE BY EITHER OF THE FOLLOWING:
055153,000223:                                                                                                  #        1.      LIMIT THE SIZE OF MPAC ON INTERPRETIVE OVERFLOW:
055154,000224:                                                                                                  #                ENTRY:          BOVB
055155,000225:                                                                                                  #                                        SIGNMPAC
055156,000226:                                                                                                  #        2.      GENERATE IN MPAC THE SIGNUM FUNCTION OF MPAC:
055157,000227:                                                                                                  #                ENTRY:          RTB
055158,000228:                                                                                                  #                                        SIGNMPAC
055159,000229:                                                                                                  #  IN EITHER CASE, RETURN IS TO THE NEXT INTERPRETIVE INSTRUCTION IN THE CALLING SEQUENCE.
055160,000230: 
055161,000231: 10,3656           00006        SIGNMPAC           EXTEND                                         
055162,000232: 10,3657           35006                           DCA      DPOSMAX                               
055163,000233: 10,3660           52155                           DXCH     MPAC                                  
055164,000234: 10,3661           10000                           CCS      A                                     
055165,000235: 10,3662           35030        DPMODE             CAF      ZERO                                  #  SETS MPAC +2 TO ZERO IN THE PROCESS
055166,000236: 10,3663           16033                           TCF      SLOAD2     +2                         
055167,000237: 10,3664           13665                           TCF      +1                                    
055168,000238: 10,3665           00006                           EXTEND                                         
055169,000239: 10,3666           45006                           DCS      DPOSMAX                               
055170,000240: 10,3667           16031                           TCF      SLOAD2                                
055171,000241: 
055172,000242:                                                                                                  #  RTB OP CODE NORMUNIT IS LIKE INTERPRETIVE INSTRUCTION UNIT, EXCEPT THAT IT CAN BE DEPENDED ON NOT TO BLOW
055173,000243:                                                                                                  #  UP WHEN THE VECTOR BEING UNITIZED IS VERY SMALL -- IT WILL BLOW UP WHEN ALL COMPONENTS ARE ZERO.  IF NORMUNIT
055174,000244:                                                                                                  #  IS USED AND THE UPPER ORDER HALVES OF ALL COMPONENTS ARE ZERO, THE MAGNITUDE RETURNED IN 36D WILL BE TOO LARGE
055175,000245:                                                                                                  #  BY A FACTOR OF 2(13) AND THE SQUARED MAGNITUDE RETURNED AT 34D WILL BE TOO BIG BY A FACTOR OF 2(26).
055176,000246: 
055177,000247: 10,3670           35026        NORMUNX1           CAF      ONE                                   
055178,000248: 10,3671           13673                           TCF      NORMUNIT   +1                         
055179,000249: 10,3672           35030        NORMUNIT           CAF      ZERO                                  
055180,000250: 10,3673           60120                           AD       FIXLOC                                
055181,000251: 10,3674           54156                           TS       MPAC       +2                         
055182,000252: 10,3675           04655                           TC       BANKCALL                              #  GET SIGN AGREEMENT IN ALL COMPONENTS
055183,000253: 10,3676           01010                           CADR     VECAGREE                              
055184,000254: 10,3677           10154                           CCS      MPAC                                  
055185,000255: 10,3700           13734                           TCF      NOSHIFT                               
055186,000256: 10,3701           13703                           TCF      +2                                    
055187,000257: 10,3702           13734                           TCF      NOSHIFT                               
055188,000258: 10,3703           10157                           CCS      MPAC       +3                         
055189,000259: 10,3704           13734                           TCF      NOSHIFT                               
055190,000260: 10,3705           13707                           TCF      +2                                    
055191,000261: 10,3706           13734                           TCF      NOSHIFT                               
055192,000262: 10,3707           10161                           CCS      MPAC       +5                         
055193,000263: 10,3710           13734                           TCF      NOSHIFT                               
055194,000264: 10,3711           13713                           TCF      +2                                    
055195,000265: 10,3712           13734                           TCF      NOSHIFT                               
055196,000266: 10,3713           30155                           CA       MPAC       +1                         #  SHIFT ALL COMPONENTS LEFT 13
055197,000267: 10,3714           00006                           EXTEND                                         
055198,000268: 10,3715           75011                           MP       BIT14                                 
055199,000269: 10,3716           20155                           DAS      MPAC                                  #  DAS GAINS A LITTLE ACCURACY
055200,000270: 10,3717           30160                           CA       MPAC       +4                         
055201,000271: 10,3720           00006                           EXTEND                                         
055202,000272: 10,3721           75011                           MP       BIT14                                 
055203,000273: 10,3722           20160                           DAS      MPAC       +3                         
055204,000274: 10,3723           30162                           CA       MPAC       +6                         
055205,000275: 10,3724           00006                           EXTEND                                         
055206,000276: 10,3725           75011                           MP       BIT14                                 
055207,000277: 10,3726           20162                           DAS      MPAC       +5                         
055208,000278: 10,3727           35034                           CAF      THIRTEEN                              
055209,000279: 10,3730           50156                           INDEX    MPAC       +2                         
055210,000280: 10,3731           54045                           TS       37D                                   
055211,000281: 10,3732           04674        OFFTUNIT           TC       POSTJUMP                              
055212,000282: 10,3733           01024                           CADR     UNIT       +1                         #  SKIP THE "TC VECAGREE" DONE AT UNIT
055213,000283: 
055214,000284: 10,3734           35030        NOSHIFT            CAF      ZERO                                  
055215,000285: 10,3735           13730                           TCF      OFFTUNIT   -2                         
055216,000286: 
055217,000287:                                                                                                  #  RTB VECSGNAG ... FORCES SIGN AGREEMENT OF VECTOR IN MPAC.
055218,000288: 
055219,000289: 10,3736           04655        VECSGNAG           TC       BANKCALL                              
055220,000290: 10,3737           01010                           CADR     VECAGREE                              
055221,000291: 10,3740           06035                           TC       DANZIG                                

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