Conditional: if-else | ||||||||||||
if-else | ||||||||||||
if ( i == j ) | $s1 | i | ||||||||||
i++ ; | $s2 | j | ||||||||||
else | ||||||||||||
j-- ; | ||||||||||||
j += i ; | ||||||||||||
As before, if the condition is false, we want to jump. | ||||||||||||
bne $s1, $s2, ELSE # branch if !( i == j ) | ||||||||||||
addi $s1, $s1, 1 # i++ | ||||||||||||
ELSE: addi $s2, $s2, -1 # else j-- | ||||||||||||
add $s2, $s2, $s1 # j += i | ||||||||||||
What's wrong with this picture? | ||||||||||||