Need help with integer overflow on 4

honey at down.FUN honey at down.FUN
Sat Oct 20 16:44:00 AEST 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



More information about the Comp.unix.wizards mailing list