Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) why is there only a less than inequality operator in standard MIPS? 2) What w

ID: 672126 • Letter: 1

Question

1) why is there only a less than inequality operator in standard MIPS?

2) What would be the C Programming equivalent name for what we call an immediate in MIPS?

3) Why is there no subi (subtract immediate) in MIPS?

4) Write MIPS code for the following C lines of code. Assume that the value of a,b,i are in registers $s0, $s1, $t0, respectively: a. for (i=0;i= 5) { b=b–5; }

5) Name 3 MIPS instructions that would be classified as R-type instructions.

6) Name 3 MIPS instructions that would be classified as I-type instructions.

7) Dissasemble the following machine instruction into a MIPS instruction: 00100010110101011111111111001110

8) Convert the following MIPS instructions into binary machine instruction: a. add $0,$0,$0 b. addi $0,$0,35

Explanation / Answer

3) Answer:
The MIPS has no ``subtractimmediate'' instruction, and [[SUB]] has
a different type than the others, so we emit it directly.
<<cases of instructions to be emitted>>=
| ADD stuff => arith (ADD,add,addi) stuff
| AND stuff => arith (AND,and',andi) stuff
| OR stuff => arith (OR,or,ori) stuff
| XOR stuff => arith (XOR,xor,xori) stuff
| SUB (Reg op1, Reg op2, Reg result) =>gen1(emit(sub(result,op1,op2)))
| DIV (Reg op1, Reg op2) => gen1(emit(div(op1,op2)))
| MULT(Reg op1, Reg op2) => gen1(emit(mult(op1,op2)))
| MFLO(Reg result) => gen1(emit(mflo(result)))
| MFHI(Reg result) => gen1(emit(mfhi(result)))
@ Floating point arithmetic is pretty easy because we always do itin
registers.