Quiz 5

This quiz covers Chapter 4 of Tanenbaum. Please allow yourself up to 1 hour to take the quiz, and return it to me by 10:00 AM, Tuesday, October, 21, if you would like for me to mark it. I will post my answers via the course homepage later that day.

  1. Explain the difference between a horizontal and vertical microarchitecture. In what ways is the Mic-1 microarchitecture horizontal or vertical?

    A horizontal architecture eliminates gate delays and reduces clock cycle times by providing as many bits in each word of the control store as are necessary to manipulate the control lines, i.e., one bit per control line. A vertical control store seeks to minimize the width of the control store by adding combinational circuits, encoding values when selecting one-of-many related lines, and other techniques.

    The Mic-1 is mostly horizontal, i.e., one bit per control line, but a few space-saving features commonly found in a vertical architecture are also implemented, most notably, the A, B, and C fields are encoded as 4-bit values which are each decoded using 4-to-16 demultiplexers near the register hardware.

  2. In the MAL microcode for Mic-1, the following instruction is encountered:
    tir := lshift( ir + ir ) ; if n then goto 19 ;
    
    1. Give a conceptual description of what's happening in this line, that is, explain it in terms of the purpose of the microprogram.

      Take twice the instruction register (ir), left shift it, and store it in the temporary instruction register (tir). If the high-order bit of twice the instruction register (i.e., the second-highest-order bit of the ir) is set, then jump to instruction 19 in the control store.

    2. Give a literal or technical description of what's happening in this line, that is, explain it in terms of registers, busses, control lines, and other components of the hardware.

      Select the IR register on bus A by asserting the appropriate lines, select the IR register on bus B by asserting the appropriate lines, set the AMUX control line to select the A bus as the left input to the ALU, set the ALU function control lines to select the addition function, set the shifter control lines to select a left shift, enable the C bus, select the TIR register on the C bus by asserting the appropriate lines, set the inputs to the micro sequencing logic circuit to select the right input of MMUX if the ALU output N is true, and assert the value 19 (decimal) in the 8-bit address entering the right inputs to MMUX. Negate the WR, RD, MBR, and MAR lines.

  3. Mac-1 has three load instructions: LODD (Load Direct), LOCO (Load Constant), and LODL (Load Local). Describe the function of each. Feel free to include the technical definitions given by Tanenbaum. For example, ADDD is "ax := ax + m[x]". In your description, give an indication of when each might be used in a program.

    LODD loads the value at a memory location into the accumulator, where the location is stored as the low-order 12 bits of the LODD instruction. This would be used to load a value from a global variable, for example. In MAL, this would be "ac := m[ x ] ;".

    LOCO loads a constant value into the accumulator, where the constant is stored as the low-order 12 bits of the LOCO instruction. This would be used to place a constant into the accumulator, or perhaps the base-address of an array when computing the address of an array element. In MAL, this would be "ac := x ;".

    LODL loads a value which is a specific distance from the stack pointer into the accumulator, where the distance is stored as the low-order 12 bits of the LODL instruction. This would be used to load a value from a local variable or procedure parameter, for example. In MAL, this would be "ac := m[ sp + x ] ;"

  4. Mac-1 has a number of instructions devoted to parameter passing: CALL, RETN, INSP, DESP, PUSH, POP, PSHI, and POPI. Explain how these are used to implement a simple procedure call and return with parameter passing by giving an example and explicating the code. (You should use at least six of these eight instructions in your example.)

    A typical call sequence might look like this:

    1. The calling module uses PUSH or PSHI to push any parameter values onto the stack.
    2. The calling module uses CALL to invoke the called proedure
    3. The called procedure uses INSP to reserve any space needed for local variables.
    4. The called procedure does whatever it does.
    5. The called procedure uses DESP to unreserve any space it previously reserved for local variables.
    6. The called procedure uses RETN to return to the calling module.
    7. The calling module uses POP or POPI to remove from the stack any parameters passed.
    For example, a simple program to calculate the 10th fibonacci number an place it in memory location 100:
    N = 5
    A = 3
    B = 2
    C = 1
    I = 0
    M = 100
    
           LOCO 10
           PUSH
           CALL FIB
           POP
           STOD M
           HALT
           
    FIB:   INSP 4
           LOCO 0
           STOL A     ;; a := 0
           LOCO 1
           STOL B     ;; b := 1
           LOCO 0
           STOL I     ;; i := 0
    LOOP:  LODL A
           ADDL B
           STOL C     ;; c := a + b
           LODL B
           STOL A     ;; a := b
           LODL C
           STOL B     ;; b := c
           LOCO 1
           ADDL I 
           STOL I     ;; i := i + 1
           SUBL N
           JNEG LOOP  ;; if i < n goto loop 
           LODL B
           STOL N     ;; n := b
           DESP 4
           RETN
    

Copyright © 1997, Ray Ontko (rayo@ontko.com).
If you're curious about why I copyright, see Peter Suber's Why Copyright Web Documents?.