Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site allegra.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!jpl
From: jpl@allegra.UUCP (John P. Linderman)
Newsgroups: net.unix-wizards
Subject: Need help with integer overflow on 4.2
Message-ID: <2857@allegra.UUCP>
Date: Fri, 19-Oct-84 09:48:25 EDT
Article-I.D.: allegra.2857
Posted: Fri Oct 19 09:48:25 1984
Date-Received: Sun, 21-Oct-84 13:22:35 EDT
Organization: AT&T Bell Laboratories, Murray Hill
Lines: 28

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