Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: nyu notesfiles V1.1 4/1/84; site down.FUN
Path: utzoo!watmath!clyde!burl!ulysses!princeton!down!honey
From: honey@down.FUN
Newsgroups: net.unix-wizards
Subject: Re: Need help with integer overflow on 4
Message-ID: <2200003@down.FUN>
Date: Sat, 20-Oct-84 02:44:00 EDT
Article-I.D.: down.2200003
Posted: Sat Oct 20 02:44:00 1984
Date-Received: Sun, 21-Oct-84 14:18:02 EDT
References: <2857@allegra.UUCP>
Organization: The Official Fun Machine of Princeton University EECS
Lines: 39
Nf-ID: #R:allegra:-285700:down:2200003:000:722
Nf-From: down!honey    Oct 20 02:44:00 1984

the integer overflow bit is saved and restored over calls/ret, so you
can't set it by calling a subroutine.  if that were all there was to
it, you could simply drop an asm("bispsw $0x20") at the top of main(),
but nothing is that simple on a vax.

the integer overflow bit is cleared upon subroutine entry unless bit 14
is set in the register mask, so you still lose integer overflow trap in
subroutines.  getting at the register mask is a bitch.

dirty trick time ...

overflowon(f)
{
	asm(" bisl2 $0x4000, *4(ap)");
}

overflowoff(f)
{
	asm(" bicl2 $0x4000, *4(ap)");
}

f()
{
	register x = 0xfffffff;
	
	x *= x;
}

main()
{
	register	x;

	f();
	overflowon(f);
	f();
}

works for me!  (compile with -N.)  this is why i love the vax.
	peter