🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #1660

divrem- what's the problem?

#1660
From: Allen J. Baum
Date: Wed, 26 Jul 1989 17:57
35 lines
1299 bytes
[]
Forgive me if this was discussed earlier, but here is my summary of the
divrem issue:

1. Its easy to get both results in hardware, simultaneously. (for integers,
   at least)
2. Languages don't support returning both arguments.
3. Hardware doesn't support it very well (MIPs excepted possibly)

It seems to me that the MIPs approach, or a modification thereof, solves the
problem quite nicely. If my program has:
 q= a/b;
 r= a mod b;

then the compiler will produce
 div a,b
 mov hi,q
 div a,b
 mov lo,r
which should be common-subexpression-eliminated to:
 div a,b
 mov hi,q
 mov lo,r

A slight modification, where the divide is a true 3 operand operation, and
the remainder is kept in a special register, would yield:
 div a,b,q
 mov lo,r

Now, did I miss this in the discussion? The language doesn't have to handle
it, if the optimizer does.

--
		  baum@apple.com		(408)974-3385
{decwrl,hplabs}!amdahl!apple!baum
Technical Details
Message-ID: <33488@apple.Apple.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!apple!baum

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!apple!baum
From: baum@Apple.COM (Allen J. Baum)
Newsgroups: comp.arch
Subject: divrem- what's the problem?
Message-ID: <33488@apple.Apple.COM>
Date: 26 Jul 89 17:57:11 GMT
Reply-To: baum@apple.UUCP (Allen Baum)
Organization: Apple Computer, Inc.
Lines: 35