On Wed, Oct 04, 2000 at 06:54:14PM -0700, Hai Huang wrote:
> hi, MIPS gurus. :) i encounter a problem on MIPS in my computer
> architecture course. it requires to use 3 MIPS instructions to implement
> absolute value.
>
> abs $t2, $t3
>
> $t3 is a number, if $t3<0, then $t2 is $t3's 2's complement, otherwise,
> $t2=$t3. i can do it in four instructions.
>
> add $t2, zero, $t3
> slt $at, $t3, zero
> beq $at, zero, OUT
> sub $t2, zero, $t2
> OUT:
>
> but i don't know how to use three. this problem borthers me for several
> days. could you help me? thanks a lot. :)
subu $t2, $zero, $t3
bltz $t3, 1f
move $t2, $t3
1:
Send my your master's degree ;-)
Ralf
|