CS23 Lab4 Report

 K. Ganchev
 S. Finney
 F. He
English descriptions of subroutines
see comments in source code.

Answer to 3.1:

We can use a multiplexer to select which register to apply to the bus. Then we
can and the mux output and the register values to the bus:
     
                        ZERO  ZERO
         +--------+---+   |    |
         |   REG1 |   |   |    |
         |   | |  |   V   |    V
         |   | +--|--AND--|--->OR
         |   |    V       V    V
     +---+   +---AND-----OR    |
-->MUX                    v    |
     +------------+---+   |    |
             REG2 |   |   |    |
             | |  |   |   |    V
             | +--|--AND--|--->OR
             |    V       V    V
             +-->AND>--->OR    |
                          V    |

Basically we are filetring the correct register (with and) and then applying
the value to the bus (with OR). 
Answer to 3.2:
First we notice that microinstruction 0 is jump to the location specified by
the hi 4 bits of the IR. We can create a special 1-bit register to hold the
value 0 if we are waiting for an instruction or 1 if we are currently executing
one. Then we just have to AND the 4 bits of the IR with that register. While we
wait for an instruction, we loop at 0 (since the IR AND 0 = 0), and once a
keystroke occurs, we set the register to 1. In this way, while we are actually
executing the instruction we can correctly read the instruction register.
Before we jump to 0, we would have to reset the special register to 0 again so
that we can loop and wait for the next keystroke. 
Extensions:
Division on negative numbers.
Here is the source code.