Source Code

These source-code files are part of a reconstructed copy of Skylark 048, the Block II Command Module (CM) Apollo Guidance Computer (AGC) software for the Skylab-2, Skylab-3, Skylab-4, and Apollo-Soyuz Test Project missions.

They have been created via disassembly of binary dumps of the original core rope memory modules actually flown on Skylab-2, part numbers 2010802-541, 2010802-551, 2010802-561, 2010802-571, 2010802-581, and 2010802-591. Access to these modules was provided by the New Mexico Museum of Space History, who we are much indebted to.

The source code for the Apollo 15, 16, and 17 software, Artemis 072, was used as a starting point. Heavy use was made of TRW 4900.5-244, Programmed Guidance Equations for Skylark Command Module Earth Orbital Program, dated 14 February 1972. This document contains pseudocode of essentially all of Skylark, using original program labels which have been copied for this source reconstruction.

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

060422,000002:                                                                                                  ## Copyright:   Public domain.
060423,000003:                                                                                                  ## Filename:    RTB_OP_CODES.agc
060424,000004:                                                                                                  ## Purpose:     A section of Skylark revision 048.
060425,000005:                                                                                                  ##              It is part of the source code for the Apollo Guidance Computer (AGC)
060426,000006:                                                                                                  ##              for Skylab-2, Skylab-3, Skylab-4, and ASTP. No original listings of
060427,000007:                                                                                                  ##              this software are available; instead, this file was created via
060428,000008:                                                                                                  ##              disassembly of dumps of the core rope modules actually flown on
060429,000009:                                                                                                  ##              Skylab-2. Access to these modules was provided by the New Mexico
060430,000010:                                                                                                  ##              Museum of Space History.
060431,000011:                                                                                                  ## Assembler:   yaYUL
060432,000012:                                                                                                  ## Contact:     Ron Burkey <info@sandroid.org>.
060433,000013:                                                                                                  ## Website:     www.ibiblio.org/apollo/index.html
060434,000014:                                                                                                  ## Mod history: 2023-09-04 MAS  Created from Artemis 072.
060435,000015: 
060436,000016: 
060437,000017: 22,2000                                           SETLOC   RTBCODE1                              
060438,000018: 22,2000                                           BANK                                           
060439,000019: 
060440,000020: 22,3563  E5,1702                                  EBANK=   XNB                                   
060441,000021: 22,3563                                           COUNT*   $$/RTB                                
060442,000022: 
060443,000023:                                                                                                  #  LOAD TIME2, TIME1 INTO MPAC:
060444,000024: 
060445,000025: 22,3563           00006        LOADTIME           EXTEND                                         
060446,000026: 22,3564           30025                           DCA      TIME2                                 
060447,000027: 22,3565           16024                           TCF      SLOAD2                                
060448,000028: 
060449,000029:                                                                                                  #  CONVERT THE SINGLE PRECISION 2'S COMPLEMENT NUMBER ARRIVING IN MPAC (SCALED IN HALF-REVOLUTIONS) TO A
060450,000030:                                                                                                  #  DP 1'S COMPLEMENT NUMBER SCALED IN REVOLUTIONS.
060451,000031: 
060452,000032: 22,3566           10154        CDULOGIC           CCS      MPAC                                  
060453,000033: 22,3567           35003                           CAF      ZERO                                  
060454,000034: 22,3570           13573                           TCF      +3                                    
060455,000035: 22,3571           13572                           NOOP                                           
060456,000036: 22,3572           44764                           CS       HALF                                  
060457,000037: 
060458,000038: 22,3573           54155                           TS       MPAC       +1                         
060459,000039: 22,3574           35003                           CAF      ZERO                                  
060460,000040: 22,3575           56154                           XCH      MPAC                                  
060461,000041: 22,3576           00006                           EXTEND                                         
060462,000042: 22,3577           74764                           MP       HALF                                  
060463,000043: 22,3600           20155                           DAS      MPAC                                  
060464,000044: 22,3601           16030                           TCF      DANZIG                                #  MODE IS ALREADY AT DOUBLE-PRECISION
060465,000045: 
060466,000046: 22,2000                                           SETLOC   RTBCODES                              
060467,000047: 22,2000                                           BANK                                           
060468,000048: 
060469,000049: 22,3602                                           COUNT*   $$/RTB                                
060470,000050: 
060471,000051:                                                                                                  #  READ THE PIPS INTO MPAC WITHOUT CHANGING THEM:
060472,000052: 
060473,000053: 22,3602           00004        READPIPS           INHINT                                         
060474,000054: 22,3603           30037                           CA       PIPAX                                 
060475,000055: 22,3604           54154                           TS       MPAC                                  
060476,000056: 22,3605           30040                           CA       PIPAY                                 
060477,000057: 22,3606           54157                           TS       MPAC       +3                         
060478,000058: 22,3607           30041                           CA       PIPAZ                                 
060479,000059: 22,3610           00003                           RELINT                                         
060480,000060: 22,3611           54161                           TS       MPAC       +5                         
060481,000061: 
060482,000062: 22,3612           35003                           CAF      ZERO                                  
060483,000063: 22,3613           54155                           TS       MPAC       +1                         
060484,000064: 22,3614           54160                           TS       MPAC       +4                         
060485,000065: 22,3615           54162                           TS       MPAC       +6                         
060486,000066: 22,3616           16470        VECMODE            TCF      VMODE                                 
060487,000067: 
060488,000068: 
060489,000069:                                                                                                  #  FORCE TP SIGN AGREEMENT IN MPAC:
060490,000070: 
060491,000071: 22,3617           07226        SGNAGREE           TC       TPAGREE                               
060492,000072: 22,3620           16030                           TCF      DANZIG                                
060493,000073: 
060494,000074:                                                                                                  #  CONVERT THE DP 1'S COMPLEMENT ANGLE SCALED IN REVOLUTIONS TO A SINGLE PRECISION 2'S COMPLEMENT ANGLE
060495,000075:                                                                                                  #  SCALED IN HALF-REVOLUTIONS.
060496,000076: 
060497,000077: 22,3621           03642        1STO2S             TC       1TO2SUB                               
060498,000078: 22,3622           35003                           CAF      ZERO                                  
060499,000079: 22,3623           54155                           TS       MPAC       +1                         
060500,000080: 22,3624           16027                           TCF      NEWMODE                               
060501,000081: 
060502,000082:                                                                                                  #  DO 1STO2S ON A VECTOR OF ANGLES:
060503,000083: 
060504,000084: 22,3625           03642        V1STO2S            TC       1TO2SUB                               #  ANSWER ARRIVES IN A AND MPAC.
060505,000085: 
060506,000086: 22,3626           52162                           DXCH     MPAC       +5                         
060507,000087: 22,3627           52155                           DXCH     MPAC                                  
060508,000088: 22,3630           03642                           TC       1TO2SUB                               
060509,000089: 22,3631           54156                           TS       MPAC       +2                         
060510,000090: 
060511,000091: 22,3632           52160                           DXCH     MPAC       +3                         
060512,000092: 22,3633           52155                           DXCH     MPAC                                  
060513,000093: 22,3634           03642                           TC       1TO2SUB                               
060514,000094: 22,3635           54155                           TS       MPAC       +1                         
060515,000095: 
060516,000096: 22,3636           30161                           CA       MPAC       +5                         
060517,000097: 22,3637           54154                           TS       MPAC                                  
060518,000098: 
060519,000099: 22,3640           35001        TPMODE             CAF      ONE                                   #  MODE IS TP.
060520,000100: 22,3641           16027                           TCF      NEWMODE                               
060521,000101: 
060522,000102:                                                                                                  #  SUBROUTINE TO DO DOUBLING AND 1'S TO 2'S CONVERSION:
060523,000103: 
060524,000104: 22,3642           52155        1TO2SUB            DXCH     MPAC                                  #  FINAL MPAC +1 UNSPECIFIED.
060525,000105: 22,3643           20001                           DDOUBL                                         
060526,000106: 22,3644           10000                           CCS      A                                     
060527,000107: 22,3645           65001                           AD       ONE                                   
060528,000108: 22,3646           13650                           TCF      +2                                    
060529,000109: 22,3647           40000                           COM                                            #  THIS WAS REVERSE OF MSU.
060530,000110: 
060531,000111: 22,3650           54154                           TS       MPAC                                  #  AND SKIP ON OVERFLOW.
060532,000112: 22,3651           00002                           TC       Q                                     
060533,000113: 
060534,000114: 22,3652           50000                           INDEX    A                                     #  OVERFLOW UNCORRECT AND IN MSU.
060535,000115: 22,3653           34762                           CAF      LIMITS                                
060536,000116: 22,3654           26154                           ADS      MPAC                                  
060537,000117: 22,3655           00002                           TC       Q                                     
060538,000118: 
060539,000119: 
060540,000120:                                                                                                  #  THE FOLLOWING ROUTINE INCREMENTS IN 2S COMPLEMENT THE REGISTER WHOSE ADDRESS IS IN BUF BY THE 1S COMPL.
060541,000121:                                                                                                  #  QUANTITY FOUND IN TEM2. THIS MAY BE USED TO INCREMENT DESIRED IMU AND OPTICS CDU ANGLES OR ANY OTHER 2S COMPL.
060542,000122:                                                                                                  #  (+0 UNEQUAL TO -0) QUANTITY. MAY BE CALLED BY BANKCALL/SWCALL.
060543,000123: 
060544,000124: 22,3656           54142        CDUINC             TS       TEM2                                  #  1S COMPL.QUANT. ARRIVES IN ACC. STORE IT
060545,000125: 22,3657           50130                           INDEX    BUF                                   
060546,000126: 22,3660           10000                           CCS      0                                     #  CHANGE 2S COMPL. ANGLE(IN BUF)INTO 1S
060547,000127: 22,3661           65001                           AD       ONE                                   
060548,000128: 22,3662           13666                           TCF      +4                                    
060549,000129: 22,3663           65001                           AD       ONE                                   
060550,000130: 22,3664           65001                           AD       ONE                                   #  OVERFLOW HERE IF 2S COMPL. IS 180 DEG.
060551,000131: 22,3665           40000                           COM                                            
060552,000132: 
060553,000133: 22,3666           60142                           AD       TEM2                                  #  SULT MOVES FROM 2ND TO 3D QUAD. (OR BACK)
060554,000134: 22,3667           10000                           CCS      A                                     #  BACK TO 2S COMPL.
060555,000135: 22,3670           65001                           AD       ONE                                   
060556,000136: 22,3671           13673                           TCF      +2                                    
060557,000137: 22,3672           40000                           COM                                            
060558,000138: 22,3673           54142                           TS       TEM2                                  #  STORE 14BIT QUANTITY WITH PRESENT SIGN
060559,000139: 22,3674           13700                           TCF      +4                                    
060560,000140: 22,3675           50000                           INDEX    A                                     #  SIGN.
060561,000141: 22,3676           34762                           CAF      LIMITS                                #  FIX IT, BY ADDING IN 37777 OR 40000
060562,000142: 22,3677           60142                           AD       TEM2                                  
060563,000143: 
060564,000144: 22,3700           50130                           INDEX    BUF                                   
060565,000145: 22,3701           54000                           TS       0                                     #  STORE NEW ANGLE IN 2S COMPLEMENT.
060566,000146: 22,3702           00002                           TC       Q                                     
060567,000147: 
060568,000148: 
060569,000149:                                                                                                  #  RTB TO TORQUE GYROS, EXCEPT FOR THE CALL TO IMUSTALL. ECADR OF COMMANDS ARRIVES IN X1.
060570,000150: 
060571,000151: 22,3703           50120        PULSEIMU           INDEX    FIXLOC                                #  ADDRESS OF GYRO COMMANDS SHOULD BE IN X1
060572,000152: 22,3704           30046                           CA       X1                                    
060573,000153: 22,3705           04647                           TC       BANKCALL                              
060574,000154: 22,3706           17175                           CADR     IMUPULSE                              
060575,000155: 22,3707           16030                           TCF      DANZIG                                
060576,000156: 
060577,000157: 
060578,000158:                                                                                                  #  EACH ROUTINE TAKES A 3X3 MATRIX STORED IN DOUBLE PRECISION IN A FIXED AREA OF ERASABLE MEMORY AND REPLACES IT
060579,000159:                                                                                                  #  WITH THE TRANSPOSE MATRIX. TRANSP1 USES LOCATIONS XNB+0,+1 THROUGH XNB+16D, 17D AND TRANSP2 USES LOCATIONS
060580,000160:                                                                                                  #  XNB1+0,+1 THROUGH XNB1+16D, 17D. EACH MATRIX IS STORED BY ROWS.
060581,000161: 
060582,000162: 22,3710           02702        XNBEB              ECADR    XNB                                   
060583,000163: 22,3711           02554        XNB1EB             ECADR    XNB1                                  
060584,000164: 
060585,000165: 22,3712  E5,1702                                  EBANK=   XNB                                   
060586,000166: 
060587,000167: 22,3712           33710        TRANSP1            CAF      XNBEB                                 
060588,000168: 22,3713           54003                           TS       EBANK                                 
060589,000169: 22,3714           53705                           DXCH     XNB        +2                         
060590,000170: 22,3715           53711                           DXCH     XNB        +6                         
060591,000171: 22,3716           53705                           DXCH     XNB        +2                         
060592,000172: 
060593,000173: 22,3717           53707                           DXCH     XNB        +4                         
060594,000174: 22,3720           53717                           DXCH     XNB        +12D                       
060595,000175: 22,3721           53707                           DXCH     XNB        +4                         
060596,000176: 
060597,000177: 22,3722           53715                           DXCH     XNB        +10D                       
060598,000178: 22,3723           53721                           DXCH     XNB        +14D                       
060599,000179: 22,3724           53715                           DXCH     XNB        +10D                       
060600,000180: 22,3725           16030                           TCF      DANZIG                                
060601,000181: 
060602,000182: 22,3726  E5,1554                                  EBANK=   XNB1                                  
060603,000183: 
060604,000184: 22,3726           33711        TRANSP2            CAF      XNB1EB                                
060605,000185: 22,3727           54003                           TS       EBANK                                 
060606,000186: 22,3730           53557                           DXCH     XNB1       +2                         
060607,000187: 22,3731           53563                           DXCH     XNB1       +6                         
060608,000188: 22,3732           53557                           DXCH     XNB1       +2                         
060609,000189: 
060610,000190: 22,3733           53561                           DXCH     XNB1       +4                         
060611,000191: 22,3734           53571                           DXCH     XNB1       +12D                       
060612,000192: 22,3735           53561                           DXCH     XNB1       +4                         
060613,000193: 
060614,000194: 22,3736           53567                           DXCH     XNB1       +10D                       
060615,000195: 22,3737           53573                           DXCH     XNB1       +14D                       
060616,000196: 22,3740           53567                           DXCH     XNB1       +10D                       
060617,000197: 22,3741           16030                           TCF      DANZIG                                
060618,000198: 
060619,000199: 
060620,000200:                                                                                                  #  THE SUBROUTINE  SIGNMPAC  SETS C(MPAC, MPAC +1) TO SIGN(MPAC).
060621,000201:                                                                                                  #  FOR THIS, ONLY THE CONTENTS OF MPAC ARE EXAMINED. ALSO +0 YIELDS POSMAX AND -0 YIELDS NEGMAX.
060622,000202: 
060623,000203:                                                                                                  #  ENTRY MAY BE BY EITHER OF THE FOLLOWING:
060624,000204: 
060625,000205:                                                                                                  #        1.      LIMIT THE SIZE OF MPAC ON INTERPRETIVE OVERFLOW:
060626,000206:                                                                                                  #        ENTRY:          BOVB
060627,000207:                                                                                                  #                                SIGNMPAC
060628,000208:                                                                                                  #        2.      GENERATE IN MPAC THE SIGNUM FUNCTION OF MPAC:
060629,000209:                                                                                                  #        ENTRY:          RTB
060630,000210:                                                                                                  #                                SIGNMPAC
060631,000211: 
060632,000212:                                                                                                  #  IN EITHER CASE, RETURN IS TO THE NEXT INTERPRETIVE INSTRUCTION IN THE CALLING SEQUENCE.
060633,000213: 
060634,000214: 22,3742           00006        SIGNMPAC           EXTEND                                         
060635,000215: 22,3743           34761                           DCA      DPOSMAX                               
060636,000216: 22,3744           52155                           DXCH     MPAC                                  
060637,000217: 22,3745           10000                           CCS      A                                     
060638,000218: 22,3746           35003        DPMODE             CAF      ZERO                                  #  SETS MPAC +2 TO ZERO IN THE PROCESS
060639,000219: 22,3747           16026                           TCF      SLOAD2     +2                         
060640,000220: 22,3750           13751                           TCF      +1                                    
060641,000221: 22,3751           00006                           EXTEND                                         
060642,000222: 22,3752           44761                           DCS      DPOSMAX                               
060643,000223: 22,3753           16024                           TCF      SLOAD2                                
060644,000224: 
060645,000225: 

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