views:

22

answers:

1

Given two input registers in MIPS: $t0, $t1

How would you figure out which one is bigger without using branches?

+2  A: 

You can use the SLT/SLTU instruction (Set Less Than [Unsigned]):

SLT $t2,$t0,$t1

or

SLTU $t2,$t0,$t1

If $t0 is less than $t1 then $t2 will be 1, otherwise $t2 will be 0.

gusbro
thanks that makes sense
Sam