CprE 381 Homework #1


Reading Assignment: Chapters 2 and 3 and Appendix A


P1. Use the example instruction set to write a 16 bit multiply program. 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.

P2. (10 points) 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;