5. The following MIPS subroutine computes an interesting function. Address Label
ID: 3747240 • Letter: 5
Question
5. The following MIPS subroutine computes an interesting function. Address Label Instruction 1000start: addi $2 1004 1008 1012 3, $0, 1 al mvste en myster exit andi 1020 1024 1028 5, $2, 1 5, $0, s 4, $4, $3 sr 1036 1040 bne S2150, Toop 31 Consider the execution of the fragment of code beginning at start and ending at end. Assume all registers and data memory locations are cleared prior to the execution of the code sequence. List the results of these registers after the code fragment completes a. i. $2 ii. $3 iv. $5 b. Determine the number of instructions executed for this code fragment (includ ing the call of mystery). Count all instructions executed beginning at start and ending at end, inclusive. (Show your work) c. Briefly describe the function computed by the subroutine mystery.Explanation / Answer
Part a
1. $2 = $0 + 85;
2. $3 = $0 +1;
3. $4 = $0 + $0;
4. $5 register value is clear as it is never reached.
Instructions executed are
Part b
addi $2, $0, 85
addi $3, $0, 1
jal mystery
add $4, $0, $0
j exit
Total 5 instructions are executed
Part c
The function computed by the subroutine mystery is
add $4, $0, $0
which means to add the values in the registers $0 and $0 and then assign the resulted value to register $4, i.e., $4 = $0 + $0;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.