linux-mips-fnet
[Top] [All Lists]

Re: help

To: Hai Huang <hai@mathpost.la.asu.edu>
Subject: Re: help
From: Ralf Baechle <ralf@uni-koblenz.de>
Date: Thu, 5 Oct 2000 04:35:46 +0200
Cc: linux-mips@fnet.fr
In-reply-to: <Pine.LNX.4.20.0010041846510.30174-100000@mathpost.la.asu.edu>; from hai@mathpost.la.asu.edu on Wed, Oct 04, 2000 at 06:54:14PM -0700
References: <Pine.LNX.4.20.0010041846510.30174-100000@mathpost.la.asu.edu>
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

<Prev in Thread] Current Thread [Next in Thread>
  • help, Hai Huang
    • Re: help, Ralf Baechle <=