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.
Hiroo Hayashi System LSI Architecture Dept.
Computer on Silicon Development Center