Question

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

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top