Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site petsd.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!talcott!panda!genrad!decvax!tektronix!uw-beaver!cornell!vax135!petsd!joe From: joe@petsd.UUCP (Joe Orost) Newsgroups: net.arch Subject: Re: Checking for Overflow after a Multiply Message-ID: <604@petsd.UUCP> Date: Mon, 29-Jul-85 13:05:37 EDT Article-I.D.: petsd.604 Posted: Mon Jul 29 13:05:37 1985 Date-Received: Thu, 1-Aug-85 20:56:41 EDT References: <476@mmintl.UUCP> <600008@pbear.UUCP> Reply-To: joe@petsd.UUCP (Joseph M. Orost) Organization: Perkin-Elmer DSG, Tinton Falls, N.J. Lines: 39 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: ---------- L R15,First --Load first operand in R15 M R14,Second --Multiply - Result is in R14:R15 LCS R13,1 --R13 := -1; LR R15,R15 --Test R15 BM $Label --Branch if Minus LIS R13,0 --R13 := 0; $Label CLR R14,R13 --Compare R14 and R13 BNE .overflow --Branch if not equal - overflow ST R15,Result --Store Result ---------- regards, joe -- ........ ......... Full-Name: Joseph M. Orost . . . UUCP: ihnp4!vax135!petsd!joe . ...... ... ........ ARPA: vax135!petsd!joe@BERKELEY . . Phone: (201) 758-7284 . ......... Location: 40 19'49" N / 74 04'37" W US Mail: MS 313; Perkin-Elmer; 106 Apple St Tinton Falls, NJ 07724