Need help with integer overflow on 4.2

John P. Linderman jpl at allegra.UUCP
Fri Oct 19 23:48:25 AEST 1984


For reasons beyond the scope of this item, I want to be able to detect
integer overflow in a program running on a VAX under 4.2 BSD.  With a
little help, I concocted the following program to get me access to the
processor status word.

#define	KEEPOUT 0xffffff00

int
setspl(trap)
    register int trap;
{
    if (trap & KEEPOUT) return (-1);
    else {
	asm("	bispsw	r11");
    }
    return (0);
}

I have some reason to believe that the code is setting the bits as desired,
because if I call it with 0x10, I get a trace trap (and a core dump) very
quickly.  But if I call it with 0x20 to enable integer overflow, I can
abuse integers forever* (and even set the V bit on directly using the routine
above) without getting the SIGFPE I want.  I'm already well beyond my limits
in hardware tinkering.  Anybody know how to enable and catch integer overflow?

* like "for (i=j=35; --i; j += j+i);"

John P. Linderman  Department of Exceptional Software  allegra!jpl



More information about the Comp.unix.wizards mailing list