Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!tektronix!orca!tekecs!frip!andrew
From: andrew@frip.gwd.tek.com (Andrew Klossner)
Newsgroups: comp.arch
Subject: Why I want an integer overflow mode bit
Message-ID: <9416@tekecs.TEK.COM>
Date: Wed, 25-Nov-87 15:12:23 EST
Article-I.D.: tekecs.9416
Posted: Wed Nov 25 15:12:23 1987
Date-Received: Sun, 29-Nov-87 12:44:01 EST
References: <1656@geac.UUCP> <863@winchester.UUCP>
Sender: nobody@tekecs.TEK.COM
Organization: Tektronix, Wilsonville, Oregon
Lines: 45


	"As for the mode bit, we thought about it and discarded it as
	ugly.  The same effect can be had ..."

An example of a program that doesn't readily compile to your architecture:

	pgm: procedure options(main);

		add: procedure(a, b, c);
			dcl (a, b, c) fixed bin(31);
			c = a+b;
			end;

		declare (a, b, c) fixed bin(31);
		a = 2147483647;
		b = 2147483647;

		on overflow snap begin;
			put list("Overflow, aborting");
			stop;
			end;

		/* This statement should invoke the overflow handler. */
		call add(a,b,c);

		on overflow;	/* Disable overflow exception. */

		/* This statement should not invoke any overflow handler. */
		call add(a,b,c);

		end;

The idea is that, in translating a language with dynamic mapping of
exceptions to exception handlers like PL/I and BASIC, the same routine
(in this case "add") may need to do both exception-causing arithmetic
and exception-free arithmetic depending on the program's history (in
this case, the most recently executed "on overflow" statement.)

Here, the natural way to implement "on overflow;" (the
turn-off-overflows instruction) is to turn on or off the mode bit.
Without a mode bit, you have to build a trap handler which does nothing
but return, and you take a performance hit.

  -=- Andrew Klossner   (decvax!tektronix!tekecs!andrew)       [UUCP]
                        (andrew%tekecs.tek.com@relay.cs.net)   [ARPA]