Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!zodiac!joyce!sri-unix!quintus!ok From: ok@quintus Newsgroups: comp.arch Subject: MC88000 multiply question Keywords: answer, thanks Message-ID: <207@quintus.UUCP> Date: 29 Jul 88 04:12:47 GMT Sender: news@quintus.UUCP Reply-To: ok@quintus () Organization: Quintus Computer Systems, Inc. Lines: 22 The best answer I have received to my question came from Marv Rubinstein, who pointed out that To determine whether x*y would overflow: a = abs(x) b = abs(y) if (a != 0 && MAXINT/a < b) report overflow will do the job, and one can then use the multiply instruction provided. In the best RISC tradition, if one of the operands is a constant, the division can be done by the compiler, reducing to if (y < -lower || y > upper) report_overflow. Since quite a few integer multiplications are by constants (Does anyone have measurements on this? There should be some for MESA.) this is a reasonable tradeoff, provided you assume that the common case should be to deliver incorrect results without warning. At least one Pascal compiler I use generates code which will report an overflow if you do var x: 0..127; ... x := 100; x := x*x; but will not report the overflow in var x: integer; ... x := 1000000000; x := x*x; What a botch. {The SunOS 3.2 pascal compiler catches both. Thanks, SMI.} Richard (A bear of very little brain) O'Keefe.