home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 308_01 / readme.dat < prev    next >
Text File  |  1990-06-17  |  14KB  |  385 lines

  1. << PART I >>
  2.  
  3. 1. The MSU.C program is run under the VMS operating system
  4.    on the DEC VAX 8820.
  5.  
  6. 2. The input data for MSU.C program is called MSU.DATA.
  7.  
  8. 3. The output file for MSU.C program is called MSU.OUT.
  9.  
  10. 4. A program runs on the MSU1 computer if the user 
  11.    follows the input specifications for the object code
  12.    program. The user can see the data that is stored in
  13.    the memory, the value of bit field changes in PSW, 
  14.    and the kinds of instructions in IR. The user can
  15.    also determine the time spent executing the program
  16.    or why the program failed to work. One can understand
  17.    general computer organization and operations by writing
  18.    programs for MSU1. The user can modify MSU1 to simulate
  19.    other machine.
  20.  
  21.  
  22. << PART II >>
  23.  
  24.      The MSU.C program is used to simulate a computer 
  25. (MSU1). The MSU1 is described by four sections. These 
  26. sections are Hardware, Instruction Set, Software 
  27. Interface to the Simulated System, and INPUT and 
  28. OUTPUT Format. 
  29.  
  30. 1. Hardware
  31.  
  32.    1) Memory
  33.  
  34.       * 4K word memory space (from 0 to 4095).
  35.       * each word of memory consists of 32 bits.
  36.            
  37.    2) CPU:
  38.  
  39.       * contains four segment origin registers.
  40.            
  41.         -- code segment
  42.         -- input segment
  43.         -- output segment
  44.         -- workspace segment
  45.  
  46.       * each segment origin register is 32 bits.
  47.       * format of the segment origin register
  48.  
  49.         +--------------------+------------------------+
  50.         |    base address    |   length of segment    |
  51.         +--------------------+------------------------+
  52.          31                18 17                     0
  53.  
  54.         base address: the beginning address of a segment
  55.                       in main memory.
  56.         length of segment: the length of that segment in
  57.                            main memory.
  58.  
  59.       * maintain two 32 bit registers: 
  60.  
  61.         -- IR (Instruction Register) and 
  62.         -- PSW (Program Status Word) register.
  63.  
  64.       * format of PSW
  65.  
  66.         +------+------+-------------------------------+
  67.         |  CC  |  IC  |     PC (program counter)      |
  68.         +------+------+-------------------------------+
  69.          31  28 27  24 23                            0
  70.  
  71.         CC: Condition Code.
  72.         IC: Interrupt Code.
  73.         PC: Program Counter.
  74.  
  75.    3) Input/Output Devices:
  76.  
  77.       One card reader and one line printer are available.
  78.       Both are simulated by files on the system.
  79.  
  80.    4) Clock:
  81.  
  82.       * used to time the execution of programs within the 
  83.         system.
  84.       * when the termination of each job, the clock must be
  85.         reset to 0.
  86.  
  87. 2. Instruction Set
  88.  
  89.    1) addressing mode:
  90.  
  91.       * The fundamental addressing mode on MSU1 is base plus
  92.         displacement addressing.
  93.       * The effective memory address refers to a byte in 
  94.         memory.
  95.    
  96.    2) instruction type:
  97.  
  98.       * GI (General Instruction) and BI (Branch Instruction).
  99.       * format of GI instructions
  100.  
  101.         +--------+------+----------+------+----------+
  102.         | opcode |  S1  |    D1    |  S2  |    D2    |
  103.         +--------+------+----------+------+----------+
  104.          31    26 25  22 21      13 12  11 10       0
  105.  
  106.         S1: origin register of the operand1.
  107.         S2: origin register of the operand2.
  108.         D1: displacement value of the operand1.
  109.         D2: displacement value of the operand2.
  110.  
  111.         operand1 = effective address specified by C(S1) + D1.
  112.         operand2 = effective address specified by C(S2) + D2.
  113.  
  114.         C(X): contents of X, where X may be an origin register
  115.               or the effective address of an operand.
  116.  
  117.       * format of BI instructions
  118.  
  119.         +--------+------+----------+------+----------+
  120.         | opcode |  M   | not used |  S1  |    D1    |
  121.         +--------+------+----------+------+----------+
  122.          31    26 25  22 21      13 12  11 10       0
  123.  
  124.         M: mask mode.
  125.  
  126.         operand1 = effective address specified by C(S1) + D1.
  127.         operand2 = mask bits contained in field M.
  128.       
  129.    3) The bit set to 1 for PSW
  130.  
  131.       * after an arithmetic operation
  132.  
  133.             Result       Bit Set to 1
  134.             ======       ============
  135.  
  136.               = 0           PSW(31)
  137.               < 0           PSW(30)
  138.               > 0           PSW(29)
  139.            overflow         PSW(28)
  140.  
  141.       * after a logical comparison operation
  142.  
  143.             Result         Bit Set to 1
  144.             ======         ============
  145.  
  146.         C(op1) = C(op2)       PSW(31)
  147.         C(op1) < C(op2)       PSW(30)
  148.         C(op1) > C(op2)       PSW(29)
  149.  
  150.    4) Summary of Instructions
  151.  
  152.       Opcode  Mnemonic  Type    Operation
  153.       ======  ========  ====    =========
  154.  
  155.       000000     NOP     GI     No operation
  156.       000001     ADD     GI     op1 = C(op1) + C(op2)
  157.       000100     MOV     GI     op1 = C(op2)
  158.       001011     BC      BI     if branch condition true,
  159.                                 PC = op1
  160.       011000     MLT     GI     op1 = C(op1) * C(op2)
  161.       011011     RD      GI     op2 = input
  162.       100001     SUB     GI     op1 = C(op1) - C(op2)
  163.       101010     CMP     GI     CC set upon logical
  164.                                 comparison
  165.       110011     WR      GI     output = C(op2)
  166.       111111     HLT     GI     program terminate
  167.  
  168.       * The branch condition (BC) instruction utilizes
  169.         the mask bits within the instruction and the 
  170.         CC bits of PSW register to determine whether or
  171.         not a branching condition is true. A branch 
  172.         occurs only if any bit that is set ON in the 
  173.         instruction mask has a corresponding bit set ON
  174.         in the CC. 
  175.  
  176.       * examples of truth table for the branch condition
  177.  
  178.          CC   Mask   Branching Condition
  179.         ====  ====   ===================
  180.  
  181.         0001  1110          false
  182.         0010  1010          true
  183.         0100  0110          true
  184.         1000  1111          true
  185.  
  186. 3. Software Interface to the Simulated System
  187.  
  188.      The main driver program for MSU1 is SYSTEM. It 
  189.    contains subroutines LOADER, CPU, MEMORY, and
  190.    INTERRUPT.
  191.  
  192.    1) LOADER operation
  193.  
  194.       * reading user programs from the card reader
  195.         into main memory.
  196.       * LOADER needs to access main memory. This 
  197.         access is made via the subroutine MEMORY.
  198.  
  199.    2) CPU operation
  200.  
  201.       * CPU loops indefinitely, fetching, decoding,
  202.         and executing instructions until a HLT
  203.         instruction or an I/O instruction is interpreted.
  204.       * The system clock is incremented by 4 for every
  205.         GI instruction and by 1 for every BI instruction.
  206.       * When an I/O instruction is encountered, control
  207.         is returned to SYSTEM, and the clock is 
  208.         incremented by an additional 16 time units.
  209.       * The clock is incremented by CPU as the first step
  210.         of executing all instructions.
  211.       * If a HLT insruction is encountered, control is 
  212.         returned to SYSTEM, the job is terminated, and 
  213.         the next job in the batch is started.
  214.       * An invalid opcode takes 4 time units, and 
  215.         currnet job is terminated automatically by SYSTEM.
  216.       * if another job is available, SYSTEM switches to the
  217.         new job and continues to execute the program.
  218.  
  219.    3) MEMORY operation
  220.  
  221.       * Main memory cannot be accessed directly by SYSTEM.
  222.         Access to main memory can be made only via the
  223.         subroutine MEMORY.
  224.  
  225.    4) INTERRUPT operation
  226.  
  227.       * When an interrupt fault is recognized by CPU, the
  228.         exceptional condition will be handled by INTERRUPT.
  229.       * The IC filed of the PSW is loaded with the 
  230.         appropriate interrupt code, and control returns
  231.         back to the SYSTEM routine.
  232.       * The condition for the interrupt code
  233.  
  234.         IC Code    Condition
  235.         =======    ===========
  236.  
  237.            1       I/O operation initiated.
  238.            3       Boundary fault. (An attempt has been
  239.                    made to reference a full word operand
  240.                    or instruction on other than a full
  241.                    word memory boundary.)
  242.            4       HLT instruction executed.
  243.            5       Invalid opcode.
  244.            6       Attempt to divide by 0.
  245.            7       Segment address fault. (If the value
  246.                    in the displacement field of an
  247.                    instruction is greater than [length
  248.                    of the segment] - 1.)
  249.       
  250.  
  251.  4. INPUT and OUTPUT Format
  252.  
  253.     1) INPUT
  254.  
  255.        * first card
  256.  
  257.          format = I L0 L1 L2 L3
  258.  
  259.          where:
  260.  
  261.               I indicates that this card is the first card 
  262.          of a job. This symbol can be used to find another
  263.          job card when the current job is finished.
  264.          
  265.               L0 is a 4 character hexadecimal number that indicates
  266.          the length of the program in bytes. L0 is the length of 
  267.          the executable segment used to store the object code. The
  268.          The length of the segment field of the segment origin
  269.          register 0 is loaded with this number. In MSU1, the base 
  270.          address field of the segment origin register 0 is always 
  271.          the value 0.
  272.  
  273.               L1 is a 4 character hexadecimal number that indicates
  274.          the length of the input buffer in bytes. The length of the
  275.          segment field of segment origin register 1 is loaded with 
  276.          this number. The base address field of segment origin 
  277.          register 1 is loaded with the address of the next available 
  278.          byte in memory.
  279.  
  280.               L2 is a 4 character hexadecimal number that gives the 
  281.          length of output buffer in bytes. L2 is the length of the 
  282.          output segment. The length of the segment field of segment 
  283.          origin register 2 is loaded with this number. The base 
  284.          address field of the segment origin register 2 is loaded 
  285.          with the address of the next available byte in memory.
  286.  
  287.               L3 is a 4 character hexadecimal number that tells the 
  288.          length of the workspace in bytes. L3 gives the length of 
  289.          the workspace segment. The length of the segment field of 
  290.          segment origin register 3 is loaded with this number. The 
  291.          base address field of segment origin register 3 is loaded 
  292.          with the address of the next available byte in memory.
  293.  
  294.        * Object program cards
  295.  
  296.          format = P1 P2
  297.  
  298.          where:
  299.  
  300.               P1 is 2 character hexadecimal number that specifies 
  301.          the number of nibbles of object code on this card. A 
  302.          nibble is a single hexadecimal character (4 bits) and Two 
  303.          nibbles make a byte. P2 is the object code on this card
  304.          where the number of nibbles is specified by P1. This 
  305.          information is loaded into the code segment.
  306.  
  307.        * First Initialization Card
  308.  
  309.          format = WKS N1
  310.  
  311.          where:
  312.  
  313.               WKS identifies the beginning of the workspace
  314.          initialization cards data. The number (N1) indicates the
  315.          number of cards that follows this card. The N1 is a 4
  316.          character hexadecimal number.
  317.  
  318.        * Initialization cards
  319.  
  320.          format = O1 V1
  321.  
  322.          where:
  323.               
  324.               O1 is a 4 character hexadecimal number that indicates
  325.          the offset address in words for the starting word of the 
  326.          workspace segment. V1 is an 8 character hexadecimal number
  327.          representing the value to be stored at the specified memory
  328.          address. The memory address is computed as the base address
  329.          of segment origin register 3 plus four times O1.
  330.  
  331.        * Last Card
  332.  
  333.          format = S1 T1
  334.  
  335.          where:
  336.         
  337.               S1 is the byte address of the first instruction to be
  338.          executed and is a 4 character hexadecimal number. This value
  339.          becomes the value of the PC in the PSW.
  340.  
  341.               T1 is a trace bit, represented by a one character 
  342.          hexadecimal number that specifies whether a trace is 
  343.          requested. A trace of the program execution is requested by 
  344.          setting T1 to 1. Other values of T1 are considered to be 0 
  345.          in MSU1.
  346.  
  347.     2) OUTPUT
  348.  
  349.        * The following items are printed by a job.
  350.  
  351.          -- The job number.
  352.          -- A message indicating the cause of termination (normal
  353.             or abnormal, error message if abnormal),
  354.          -- The clock value at termination, and
  355.          -- The output or result of the program.
  356.  
  357.        * If the trace switch is on, the program prints information
  358.          in the format shown in below before each instructions is
  359.          executed. All numbers are printed as 8 character 
  360.          hexadecimal numbers.
  361.  
  362.           PSW       IR    TYPE  MNE     OP1      OP2    CLOCK
  363.         xxxxxxxx xxxxxxxx  tt   nnn  ---01--- ---02--- xxxxxxxx
  364.  
  365.         Note: - only one trace heading per job.
  366.               - xxxxxxxx is an 8 character hexadecimal number.
  367.               - tt  is the instruction type (GI or BI).
  368.               - nnn is the mnemonic name of the instruction.
  369.               - 01  is the contents of memory of the effective
  370.                     address of operand1. The format of 01 is:
  371.       
  372.                        xxxxxxxx if operand1 is the effective
  373.                                 address.
  374.                          space  if it is not used.
  375.               - 02  is the contents of memory of the effective 
  376.                     address of operand2. The format of 02 is:
  377.                      
  378.                        xxxxxxxx if operand2 is the effective
  379.                                 address,
  380.                          bbbb   if operand2 is the mask bits,
  381.                          space  if it is not used.
  382.               - bbbb is the mask bits specified in the BC
  383.                      instruction.
  384.  
  385.