Re: Help with integer division overflow issue
Jason Thorpe <[email protected]> Thu, 11 Jan 2024 18:39:41 -0800
| Newsgroups | gmane.os.netbsd.ports.m68k |
|---|---|
| Message-ID | <[email protected]> |
> On Jan 9, 2024, at 7:22 AM, Jason Thorpe <[email protected]> wrote: > >> On Jan 9, 2024, at 7:14 AM, Izumi Tsutsui <[email protected]> wrote: >> >> milan-% cc -o test test.c >> milan-% ./test >> milan-% >> --- >> >> I.e. at least looks no exception. > > Yes, same with TME emulating a Sun3/160. Ok, can you try this one? #include <limits.h> #include <stdlib.h> #include <stdio.h> int divisor = -1; int main(int argc, char *argv[]) { int val = INT_MIN; int ccr = 0; __asm __volatile("divsl divisor,%1" : "=r" (val) : "0" (val)); __asm __volatile("move %%ccr,%0" : "=r" (ccr)); printf("val = %d (0x%08x)\n", val, val); printf("ccr = 0x%02x\n", ccr); return 0; } On TME, the result is: sun3-160$ ./a.out val = -2147483648 (0x80000000) ccr = 0x02 sun3-160$ The V flag is set…but I’m a little surprised that the N flag is not set! Thanks! -- thorpej