Question: The following MIPS assembly code contains a mistake that violates the MIPS convention in terms of using stack for storing/protecting registers. What is the mistake

  1. The following MIPS assembly code contains a mistake that violates the MIPS convention in terms of using stack for storing/protecting registers.

  • What is the mistake and how should it be fixed? Correct the corresponding lines in the code.
  • For the corrected code, sketch the stack frame contents at the time when the instruction move $s1, $a1 is being executed.

f: addi $sp, $sp, 12

sw $ra, 8($sp)

sw $s1, 4($sp)

sw $s0, 0($sp)

move $s0, $a0

move $s1, $a1 # Stack frame?

jal g

add $v0, $v0, $s0

lw $ra, 8($sp)

lw $s1, 4($sp)

lw $s0, 0($sp)

addi $sp, $sp, -12

jr $ra

g: mul $v0, $s0, $s1

jr $ra

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!