CprE 381 Homework #1


Reading Assignment: Chapters 2 and 3 and Appendix A, Patterson and Hennessey


P1. You need to write a software implementation of emulating MIPS instruction set on MIPS machine. Suppose an instruction is already read in register R1. You need to branch to addr_i (i=00 to 63) for instruction whose op_code is i for execution. Write a routine to branch according to op_code. Notice that op_code in MIPS instruction encoding is in bits 31-26.

P2. Use the MIPS instruction set to write a 32 bit multiply program using basic instructions.. Assume that the two operands are in registers R4 and R5. The 32 bit results should be in registers R6 and R7. You can use register R8 and R9 for any temporary results.

P3. There are six relative conditions between the values of two registers. Assuming that variable i correspond to register $19 and variable j corresponds to $20, show the MIPS code for the condition corresponding to the following C codes. Notice that MIPS instruction set does not provide all types of branch instructions.

(a) if (i == j) go to L1;
(b) if (i != j) go to L1;
(c) if (i < j) go to L1
(d) if (i <= j) go to L1
(e) if (i > j) go to L1;
(f) if (i >= j) go to L1;