6. Consider the following MIPS machine code. bne $0, $0, 2 addi $t0, $0, 5 addi
ID: 3897568 • Letter: 6
Question
6. Consider the following MIPS machine code.
bne $0, $0, 2
addi $t0, $0, 5
addi $t1, $0, 10
What will be in $t0 and $t1 after the above program is executed?
a. $t0 = 5, $t1 is unknown because 3rd statement will not be executed
b. $t1 = 10, $t0 is unknown because 2nd statement will not be executed
c. $t0 = 5, $t1 = 10
d. $t0 = 0, $t1 = 0
BONUS (5 points)
7.
addi $t0, $0, 3
add $s0, $0, 0
doLoop:
addi $t0, $t0, -1
add $s0, $s0, $t0
bne $t0, $0, doLoop
addi $t0, $0, 3
add $s0, $0, 0
addi $t0, $t0, -1
add $s0, $s0, $t0
bne $t0, $0, -2
Consider the following code: What will be in $s0 after the program is executed?
OR
a. 1
b. 3
c. 6
d. Program will not terminate- it will loop forever.
addi $t0, $0, 3
add $s0, $0, 0
doLoop:
addi $t0, $t0, -1
add $s0, $s0, $t0
bne $t0, $0, doLoop
Explanation / Answer
6. Option c: $t0 = 5, $t1 = 10
Explanation:
since $0 =$0; the branch will not take place
in the 2nd statement t0 will get 5 and in the 3rd statement t1 will become 10
7. Option c: 3
$s0 is incremented 3 times.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.