Re: Assembly Language - Mathematics WITHOUT maths coprocessor



On Sat, 08 Oct 2005 03:06:35 GMT, "Richard Cooper"
<spamandviruses@xxxxxx> wrote:
>On Fri, 07 Oct 2005 15:01:47 -0400, knowledgehungry
><chavanmaheshs@xxxxxxxxxxx> wrote:
>> Can anybody tell me how to perform
>> division without getting divide overflow and WITHOUT using maths
>> co-processor using assembly language ?

for *integer* big numbers operations for me the reference is the book
"Handbook of Applied Cryptography by A. Menezes, P. van Oorschot and
S. Vanstone" for "float" big numbers i would like to know a reference
too ...

>Well, the easy way would be the divide instruction. But short of that,
>you just have to do long division.
>
>Say you want to divide 13482 by 234.
>
>In binary, these are 11010010101010 and 11101010. So it's done like this:
>
> ________________
> 11101010 ) 11010010101010
>
>Then we go here:
>
> __________1_____
> 11101010 ) 11010010101010
> -11101010
> --------------
> 1011101101010
>
>And then we go here:
>
> __________11____
> 11101010 ) 11010010101010
> -11101010
> --------------
> 1011101101010
> -11101010
> -------------
> 100011001010
>
>Then we go here:
>
> __________111___
> 11101010 ) 11010010101010
> -11101010
> --------------
> 1011101101010
> -11101010
> -------------
> 100011001010
> -11101010
> ------------
> 101111010
>
>Then we go like this:
>
> __________11100_
> 11101010 ) 11010010101010
> -11101010
> --------------
> 1011101101010
> -11101010
> -------------
> 100011001010
> -11101010
> ------------
> 101111010
>
>Then we do like this:
>
> __________111001
> 11101010 ) 11010010101010
> -11101010
> --------------
> 1011101101010
> -11101010
> -------------
> 100011001010
> -11101010
> ------------
> 101111010
> -11101010
> ---------
> 10010000
>
>And then we do this:
>
> __________111001 R 10010000
> 11101010 ) 11010010101010
> -11101010
> --------------
> 1011101101010
> -11101010
> -------------
> 100011001010
> -11101010
> ------------
> 101111010
> -11101010
> ---------
> 10010000
>
>And so 13482 divided by 234 is 57 remainder 144. (And how surprised am I
>that I didn't screw that up somewhere...)

use the word of cpu for perform a division for me is better.
i think the division in the book "Handbook of Applied Cryptography"
with the base 2^32 is 100x faster than its binary base form
.


Loading