New answers tagged

8

7 instructions slt $t3, $t0, $t1 slt $t4, $t2, $t1 slt $t5, $t2, $t0 Compare all three pairs of values. xor $t3, $t3, $t4 movn $t0, $t1, $t3 $t1 is the median if it is greater than exactly one of the other values. xor $t5, $t5, $t4 movn $t0, $t2, $t5 $t2 is the median if it is less than exactly one of the other values. (Otherwise, $t0 is already the ...


6

8 instructions slt $t4, $t2, $t1 movn $t3, $t1, $t4 movn $t1, $t2, $t4 movn $t2, $t3, $t4 Rearrange $t1 and $t2 so that $t1 ≤ $t2. slt $t3, $t2, $t0 slt $t4, $t0, $t1 movn $t0, $t2, $t3 movn $t0, $t1, $t4 If $t0 falls between $t1 and $t2, it is already the median. If it's outside that range, the one it lies beyond is the median.


Top 50 recent answers are included