No assumptions are necessary. It tests if two bit patterns are identical.
When you use a branch instruction to implement an if-statement, the instructions that are executed when the condition is false immediately follow the branch instruction. This is the opposite of high-level languages, where an if-statement is followed by the statments that correspond to "true". Watch out for this problem when you are coding. Careful documentation helps.
Here is a program fragment that is to add the value in
register $t0
to register $t2
(if $t0
is even) and to $t1
(if $t0
is odd):
lw $t0,val # $t0 has the value andi $t8,$t0,1 # one's place is zero or one ____ $t8,odd # if even addu $t2,$t2,$t0 # add to even sum b endif odd: # else addu $t1,$t1,$t0 # add to odd sum endif:
The unconditional branch instruction is used at the bottom of the true branch of the if-else.
(In this chapter, the SPIM simulator has been set so that delayed branches are OFF and delayed loading is OFF, so no-ops are not included in this program fragment.)
Fill in the blank by choosing the correct branch instruction (refer to the table).