The link you sent calls for a user name and password Gary- >From: Byron A Jeff >Reply-To: pic microcontroller discussion list >To: PICLIST@MITVMA.MIT.EDU >Subject: Re: [Pic]: 32 by 32 division >Date: Wed, 27 Mar 2002 13:22:28 -0500 > >On Wed, Mar 27, 2002 at 10:04:04AM -0500, Gary silva wrote: > > Can some one help me i'm looking for code to do 32 by 32 bit division. > >No code but I have a couple of process descriptions in the archives here: > >http://www.infosite.com/~jkeyzer/piclist/2000/Jul/1363.html >http://www.infosite.com/~jkeyzer/piclist/2000/Mar/2510.html > >BTW it doesn't matter how many bits are in the divisor and dividend, the >process is the same. You can save a very small bit of time by shifting up >8 bits at a time by copying whole bytes as long as the divisor is 0 in the >top byte of the dividend that has a bit set. For example say we needed >to divide 1000000 by 240. The operands look like this in binary: > >00000000 00001111 01000010 01000000 >00000000 00000000 00000000 11110000 > >Since the 3rd byte of the dividend has 1's in it and the divisor doesn't >we can shift the divisor by 8 just by copying bytes > >00000000 00001111 01000010 01000000 >00000000 00000000 11110000 00000000 > >Same situation, so do it again: > >00000000 00001111 01000010 01000000 >00000000 11110000 00000000 00000000 > >Of course the quotient mask shifts by the same amount... > >Note that the divisor is larger than the divident. But that's OK because >the >compare will simply slot zeros in the corresponding bits of the quotient. > >All you need for dividing is subtraction, compare (which is just another >form of subtraction), and shift. And it'll never take more than 2N shifts >and >2N subtract/compares for operand width N to do the divide. > >Note that it only works for positive operands. If one or the other is >negative, then you must remember the sign and make both positive before >dividing. You then restore the sign afterwards. > >Also you can check out the piclist.com divide page here: > >http://www.piclist.com/techref/microchip/math/div/index.htm > >Take one of the routines there and extend it to 32 bits. > >BAJ > > > > Thanks > > Gary- > > > > > > _________________________________________________________________ > > MSN Photos is the easiest way to share and print your photos: > > http://photos.msn.com/support/worldwide.aspx > > > > -- > > http://www.piclist.com hint: To leave the PICList > > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > >-- >http://www.piclist.com hint: To leave the PICList >mailto:piclist-unsubscribe-request@mitvma.mit.edu > > _________________________________________________________________ Join the world s largest e-mail service with MSN Hotmail. http://www.hotmail.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu