linux-mips
[Top] [All Lists]

div overflow

To: linux-mips@oss.sgi.com, linux-mips@vger.rutgers.edu, linux-mips@fnet.fr
Subject: div overflow
From: Hiroo HAYASHI <hiroo.hayashi@toshiba.co.jp>
Date: Tue, 11 Jul 2000 21:58:47 +0900
Sender: owner-linux-mips@oss.sgi.com
In MIPS architecture, is the result of 0x80000000/-1 undefined?

The operands of DIV instruction 32bit signed int.

         0x7fff_ffff =  2,147,483,647 (INT_MAX)
         0x8000_0000 = -2,147,483,648 (INT_MIN)

limits.h defines them as;

> /* Minimum and maximum values a `signed int' can hold.  */
> #  define INT_MIN       (- INT_MAX - 1)
> #  define INT_MAX       2147483647

0x8000_0000 / 0xffff_ffff = -2,147,483,648 / -1 = 2,147,483,648 > INT_MAX

But the description of the DIV instruction of MIPS RISC Architecture
(Kane and Heinrich) says;

        No overflow exception occurs under any circumstances, and the
        result of this operation is undefined when the divisor is zero.

According to 'See MIPS Run', P.186, MIPS assembler expands a div
instruction to an instruction sequence in which these condition are
checked.  Do all MIPS assemblers do this?

Any information is welcome.

Thank you.
-------------
Hiroo Hayashi   System LSI Architecture Dept.
                Computer on Silicon Development Center
                TOSHIBA Corporation


<Prev in Thread] Current Thread [Next in Thread>