Question: Help needed in MIPS ! Thanx 1. Translate the following C statement into MIPS assembly code. Assume that f, i, and h are stored in

Help needed in MIPS ! Thanx

Help needed in MIPS ! Thanx 1. Translate the following C statement

1. Translate the following C statement into MIPS assembly code. Assume that f, i, and h are stored in registers $50, $s1, and $s2 respectively. Your assembly code should not modify any of the saved registers other than $50, but may do whatever you wish with the temporary registers. Use as few instructions as possible (and only add, sub, addi, lw, and sw). f = i + (h 2); 2. Translate the following C statement into MIPS assembly code. Assume that f and g are stored in registers $54 and $55 respectively. Your assembly code should not modify any of the saved registers other than $54, but may do whatever you wish with the temporary registers. Use as few instructions as possible (and only add, sub, addi, lw, and sw). f = -g - f; 3. Translate the following C statement into MIPS assembly code. Assume that i and j are stored in registers $s2 and $s3 respectively, and that the base addresses of A and B are stored in registers $s6 and $s7 respectively. Your assembly code should not modify any of the saved registers, but may do whatever you wish with the temporary registers. Use as few instructions as possible (and only add, sub, addi, lw, and sw). Hint: there is a tricky, non-obvious part to this. At some point, you will end up with the value of i-j in a register (call it $t0). But you cannot do lw $t1, $t0 ($56), because the second operand must be just a number. Instead, you need to get into a register $56 + 4 * $t0, then use an offset of O. We haven't talked about multiplication, but remember that it is just repeated addition! B[8] = A[i-j]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!