Hello all...
Have look at this problem..

I need to determine.. that out of Number1 ( 64 bit ) and Number2 ( 64 bit ) which is greater... both can be zero.

if Number1 > Number2 do this..
do that..
My approach...

mov eax, number1 ( MSB 32 bits )
mov ebx, number1 ( LSB 32 bits )

mov ecx, number2 ( MSB 32 bits )
mov edx, number2 ( LSB 32 bits )

sub ebx, edx
sbb eax, ecx
jc Number1LessThanNumber2

If i my way is right then even then I am getting bull*hit result..

Posted on 2003-02-17 08:07:25 by processingspeed

In case of a big number library (e.g. 2048 bits) you may not really need to compute the whole subtraction to perform the compare.
In this case, first compare the most significant longword, and then (only if necessary) all the other less significant longword(s):

mov eax, number1 ( MSB 32 bits )
cmp eax, number2 ( MSB 32 bits )
jc Number1LessThanNumber2
jne skip ; you may also use "ja skip"
mov eax, number1 ( LSB 32 bits )
cmp eax, number2 ( LSB 32 bits )
jc Number1LessThanNumber2

You should put it in a loop and optimize accordingly.. because the above code although "readable" (didactic) ain't very branch-performance friendly.
The key concept here is that when comparing multiple words sometimes you may know for sure the result even just comparing the first words.. so the further compares aren't really necessary.
It's like in shortcircuit boolean evaluation.. if you have:

IF a==true AND b==true AND c==TRUE THEN..

No need to perform b and c comparations in case a was FALSE. You can already be sure that the whole expression will evaluate to FALSE.
Posted on 2003-02-17 10:53:37 by Maverick