Reputation: 171
So i have a sample question for an upcoming mips test and needed a clarification.
ori $t0, $0, 6
p7L0: lw $t1, 0($s0) sll $t1, $t1, 2 blt $t0, $t1, p7L1 addi $s0, $s0, 4 j p7L0
p7L1:
(a) 2
(b) 3
(c) 6
(d) None of the above.
In this example the answer comes out to 8. Yet im kind of confused how it got that. In my run through, in the command ori i get 6. It goes to the sll and it comes out with 0. Since 0 is less than 6, it branches to p7L1:
Clarification?
Upvotes: 0
Views: 254
Reputation: 212969
The sll
instruction multiplies t1 by 4, so its value each time throught the loop will be 0, 4, 8, and then the branch will be taken, because 6 < 8. Hence the answer is 8.
Upvotes: 1