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-09 11:00:30 PST Path: newsfeed.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!inmet!not-for-mail From: Tucker Taft Newsgroups: comp.lang.ada Subject: Re: implementing software unsigned divide Date: Wed, 09 May 2001 14:00:29 -0400 Organization: AverStar (formerly Intermetrics) Burlington, MA USA Message-ID: <3AF985BD.BC0E1C12@averstar.com> References: <3AF80FA7.49816047@averstar.com> NNTP-Posting-Host: nebula.burl.averstar.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: inmet2.burl.averstar.com 989431230 8394 141.199.8.77 (9 May 2001 18:00:30 GMT) X-Complaints-To: usenet@inmet2.burl.averstar.com NNTP-Posting-Date: 9 May 2001 18:00:30 GMT X-Mailer: Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: newsfeed.google.com comp.lang.ada:7389 Date: 2001-05-09T18:00:30+00:00 List-Id: Does your chip happen to have 32-bits/16-bits => 16-bit quotient and 16-bit remainder? For that case, clearly you just zero out the high order part rather than sign-extending to handle an unsigned dividend. If it has 32/32 => 32, of course you can handle 16-bit unsigned trivially. A more general solution, I believe, is to (logical) shift both the dividend and divisor right 1 bit, do the divide, and then adjust the quotient up or down by 1 to get the remainder to be >= 0 and less than the divisor. (Obviously you need to first check for the special case when the divisor is <= 1!) -- -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)