Q1 ) We are writing a subroutine, and want to use $t0. What are the considerations? (check all that apply)
1 - We know that the routine which called us gives us permission to use this register, so we don't have to save its value before using it. |
||||||||||||||||||||||||||
2 - The routine which called us may have an important value in that register, so we should save its value before using it. |
||||||||||||||||||||||||||
3- We know that the subroutine won't touch the value in $t0, but if it does, it will save the value then restore it, so the value will be preserved for us. |
||||||||||||||||||||||||||
4 - If this is a recursive subroutine, then we should save the value of $t0. |
||||||||||||||||||||||||||
5- If we have an important value in $t0, and we are going to call another subroutine, we should save the value in $t0 before making the call, and restore the value when we get back from the subroutine. |
||||||||||||||||||||||||||
6- Perhaps we've used $t0, but we are done with the value before calling the subroutine, so in this case we don't have to save its value. Q2) What values should be saved to the stack? Select all that apply.
|
Q1)
ans: 4.If this is a recursive subroutine, then we should save the value of $t0.
5.If we have an important value in $t0, and we are going to call another subroutine, we should save the value in $t0 before making the call, and restore the value when we get back from the subroutine
Q2)
ans:
1 - The $v0 register.
6- Any of the $t registers if this routine calls a subroutine and these register have important values
7 - The $ra register (if this routine calls a subroutine)
8 -Any local values of the subroutine
Get Answers For Free
Most questions answered within 1 hours.