From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: implementing software unsigned divide
Date: 08 May 2001 17:20:15 -0400
Date: 2001-05-08T21:35:47+00:00 [thread overview]
Message-ID: <uu22v5yi8.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 3AF80FA7.49816047@averstar.com
Tucker Taft <stt@averstar.com> writes:
> Stephen Leake wrote:
> >
> > I'm porting GNAT to a 16 bit microprocessor that does not provide a
> > hardware instruction for unsigned divide (it has multiply and signed
> > divide, both 16 and 32 bit). Can anyone provide a reference to a book
> > that discusses how to do this, and/or an algorithm that does it? I've
> > looked in Knuth, and did an initial web search, and haven't found
> > anything.
>
> This is generally pretty straightforward using the
> signed hardware instructions, and some appropriate
> amount of fixups before and/or after the actual divide.
> I suggest you try some specific examples by hand where one or
> both of the values have the high bit on. It is pretty
> easy to figure out what sort of fixup, if any, is
> necessary.
I thought of that, but the first example I came up with seemed
insoluble (lets assume 16 bit):
signed -1 / 2 => 0, but unsigned 16#FFFF# / 2 => 16#7FFF#
Maybe if I use the remainder, I can do something. I'll look at it
some more.
I'll also try the library, see if they have a "microprocessor design"
section or some such.
> I have done this myself in the past, but unfortunately I didn't
> write down the algorithms in a place that I can locate at the
> moment.
>
> >
> > --
> > -- Stephe
>
> --
> -Tucker Taft stt@avercom.net http://www.averstar.com/~stt/
> Chief Technology Officer, AverCom Corporation (A Titan Company)
> Burlington, MA USA (AverCom was formerly the Commercial Division of AverStar:
> http://www.averstar.com/services/ebusiness_applications.html)
--
-- Stephe
next prev parent reply other threads:[~2001-05-08 21:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-07 21:42 implementing software unsigned divide Stephen Leake
2001-05-08 6:04 ` Jacob Sparre Andersen
2001-05-08 7:44 ` Tarjei T. Jensen
2001-05-08 13:18 ` Ted Dennison
2001-05-08 15:24 ` Tucker Taft
2001-05-08 21:20 ` Stephen Leake [this message]
2001-05-09 18:00 ` Tucker Taft
2001-05-10 15:54 ` Stephen Leake
2001-05-13 23:17 ` Kenneth Almquist
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox