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. :)
hai
--------------------------------------------------------------------------
Hai Huang
Arizona State University Phone: (480) 449-9490 (H)
Computer Science & Engineering Department
Tempe, AZ 85287 email: hai@asu.edu
--------------------------------------------------------------------------
|