[comp.arch] 88k MUL/DIV

bs@linus.UUCP (Robert D. Silverman) (02/21/90)

In article <6196@orca.wv.tek.com> andrew@frip.wv.tek.com writes:
:	"for the most part, I really like the 88K, but the $#@ MUL
:	instruction is totally brain-damaged. It's a 32x32 giving 32
:	multiply, and it DOESN'T TELL YOU if it overflows!"
:
:I kinda like this instruction.  The lion's share of Unix workstation
:multiplies seem to discard all but the low 32 bits of the result, and
:don't check for overflow.  By implementing a 32x32 -> 32 multiply
:instruction, you get two small RISCy wins:
:If you want more than 32 bits of result, or overflow detection, there
:are two relatively cheap ways to get there: multiply in
:double-precision floating point mode (no problem since every 88k has an
:FPU), or have a routine which fires off the three integer multiplies

Uh, I suggest you go back and check your arithmetic. There is no
way to multiply two 32-bit integers together using double precision
floating point multiplies. The IEEE spec specifies a 53-bit mantissa
for 64-bit double multiply. So how does one compute a 32x32 multiply
in 53 bits?

-- 
Bob Silverman
#include <std.disclaimer>
Internet: bs@linus.mitre.org; UUCP: {decvax,philabs}!linus!bs
Mitre Corporation, Bedford, MA 01730

des@elberton.inmos.co.uk (David Shepherd) (02/22/90)

In article <98185@linus.UUCP> bs@gauss.UUCP (Robert D. Silverman) writes:
>In article <6196@orca.wv.tek.com> andrew@frip.wv.tek.com writes:
>:If you want more than 32 bits of result, or overflow detection, there
>:are two relatively cheap ways to get there: multiply in
>:double-precision floating point mode (no problem since every 88k has an
>:FPU), or have a routine which fires off the three integer multiplies
>
>Uh, I suggest you go back and check your arithmetic. There is no
>way to multiply two 32-bit integers together using double precision
>floating point multiplies. The IEEE spec specifies a 53-bit mantissa
>for 64-bit double multiply. So how does one compute a 32x32 multiply
>in 53 bits?

I think the point is that you can do 32x32 multiply with overflow
detection by using douple-precision fp. If the multiply does not
overflow 32 bit integer arithmetic then 

	(int)(((double)x) * ((double)y))

always equals  x*y

If the multiply overflows 32 bit integer arithmetic then the final
conversion back to int overflows, and somehow signals the error to you.

However, I would only consider this as a debating point -- it looks
pretty tacky to have to use all the time instead of a proper 32x32
overflow checked multiply.

david shepherd
INMOS ltd

                               Pargetter lives !!