[net.arch] Checking for Overflow after a Mu

peterb@pbear.UUCP (08/01/85)

/* Written  1:05 pm  Jul 29, 1985 by petsd!joe in pbear:net.arch */
/* ---------- "Re: Checking for Overflow after a Mu" ---------- */
In article <600008@pbear.UUCP> peterb@pbear.UUCP writes:
>	It is trivial to determine overflow in a word X word = word
>operation. Just do the standard multiply producing 2*word bits and check the
>high order word for non-zero(base 1) values. If this is so, then to result
>has overflowed. This check can be built in and executed at the end of the
>multiply as the resultant lower word result is placed in the destination.
>
>	It is not that expensive, requiring a few clocks at best.

WRONG KEMOSABI!

An overflow occurs when the high-order word is not a replication of the sign
bit in the low order word.  Here is the code necessary on a Perkin-Elmer
3200 to check for overflow:

/* End of text from pbear:net.arch */

Ok, I didn't phrase it correctly. I meant that HARDWARE overflow is simple.
All that is needed is a 16 2 input XOR gates, and a 16 input OR gate.

bus one input from each XOR together and connect to the high-bit of the
low word result. The other input to the XORs are connected to each bit of
the high word result. take the output of the XORs and input them to the OR
gate. If the output of the OR gate is high, then a SIGNED overflow has
occured. If not, then the result is valid in SIGNED arithmetic.

	In Boolean, this is:

		OF = summa(i = 0 -> 15) {l[15] XOR h[i]}

	where summa is defined as an n input OR gate, l[i] = the Ith bit of
	the low result word, and h[i] = the Ith bit of the high word.

This test takes one clock cycle. (about 80 - 120 ns).

Peter Barada
{ihnp4!inmet|{harvard|cca}!ima}!pbear!peterb