News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

64-bits arithmetic

Started by CObject, July 13, 2005, 09:47:45 AM

Previous topic - Next topic

CObject

Hi all !

What do you think :
which's the best way to compare 2 LARGE_INTEGERs ?

Without using MMX or FPU !

farrier

It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

Eóin

Assuming one is in eax:edx and the other in ebx:ecx (Just for simplicity, easily changed) try the following

cmp edx,ecx
jne @F
cmp eax,ebx
@@:

For unsigned 64bit number the state of the flags should now tell you which is bigger/smaller or if both equal.

CObject

#3
I sovle my problem  :8)
The following best fits for my needs


.386
.model flat,stdcall

LARGE struct
lo dd ?
hi dd ?
LARGE ends

;#######################  CONST DATA  ###########################
.const

;#######################  INITDATA  #############################
.data
largeValue1 LARGE<09C370555h,0000004Dh> ; 333 333 333 333
largeValue2 LARGE<0BD7A038Eh,00000033h> ; 222 222 222 222

;######################  UNINIT DATA  ###########################
.data?

;#########################  CODE  ###############################
.code
start:
main    proc

        ; largeValue1
        mov eax,largeValue1.lo
        mov ebx,largeValue1.hi

        ; largeValue2
        mov ecx,largeValue2.lo
        mov edx,largeValue2.hi

        ; largeValue1 - largeValue2
        sub eax,ecx
        sbb ebx,edx

        ; compare
        shl ebx,1
        jc nega
        or eax,ebx  ;cmp eax,0
        jnz pos
        PrintText "largeValue1 == largeValue2"
        jmp quit
pos:    PrintText "largeValue1 > largeValue2"
        jmp quit
nega:   PrintText "largeValue1 < largeValue2"

quit:   mov eax,0
        ret
main    endp

;###################  Functions definition  #####################

        end start

Eóin