From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,95a7ce6b0163274c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-08 14:25:42 PST Path: newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: implementing software unsigned divide Date: 08 May 2001 17:20:15 -0400 Organization: NASA Goddard Space Flight Center Message-ID: References: <3AF80FA7.49816047@averstar.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 989357747 9341 128.183.220.71 (8 May 2001 21:35:47 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 8 May 2001 21:35:47 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 Xref: newsfeed.google.com comp.lang.ada:7340 Date: 2001-05-08T21:35:47+00:00 List-Id: Tucker Taft 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