Assign the register numbers for all the variables. You are encouraged to refer the MIPS assembly registers. (2) Select appropriate assembly instructions for arithmetic operations and if/else statements. (3) Once you have the assembly instructions for arithmetic operations and if/else statement, pair up these instructions with beq/bne and j instructions. If the condition has equality comparison, you may need to slt instruction. Using slt instruction, you can set a temporary value (t) to 1 and branch to the next instruction with beq/bne instruction. (4) Finally, add the comments for each instruction line to clarify. Assume the integer variables g and h are in registers $s2 and $s3, respectively. if (g > h) g = g + h; else g = g – h; if (g >= h) g = g + 1; else h = h – 1; if (g <= h) g = 0; else h = 0;
Assign the register numbers for all the variables. You are encouraged to refer the MIPS assembly registers. (2) Select appropriate assembly instructions for arithmetic operations and if/else statements. (3) Once you have the assembly instructions for arithmetic operations and if/else statement, pair up these instructions with beq/bne and j instructions. If the condition has equality comparison, you may need to slt instruction. Using slt instruction, you can set a temporary value (t) to 1 and branch to the next instruction with beq/bne instruction. (4) Finally, add the comments for each instruction line to clarify.
Assume the integer variables g and h are in registers $s2 and $s3, respectively.
- if (g > h)
g = g + h;
else
g = g – h;
- if (g >= h)
g = g + 1;
else
h = h – 1; - if (g <= h)
g = 0;
else
h = 0;
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Assume the integer variables g and h are in registers $s2 and $s3, respectively.