Hi,
I'm using the function below to test two 64-bit words for bit equality, returning zero only if they are equal. While it SEEMS to work fine for integers and characters, it drops the ball when it comes to reals (floats), finding 1.0 and -1.0 to be equal, where it XORs the two words that (bit) agree in everything but the sign bit, yielding a result of -0.0, which unfortunately says they're equal. Since the function may be given not only pairs of integers, characters, or reals to compare, but also combinations of these types (integer to real, real to character, etc.), I probably don't want to get too far from what I have. After the XORing, if the sign bit of the result is 1 then the signs had to be different, implying inequality. Then again, I could test sign bits higher up in the function, skipping the XOR altogether if they're different. Then there's always good old subtraction, but when the input parameters can be just about anything 64-bit, how to know whether to do an integer or float subtract? Suggestions welcome.
Michael
======================
global equal_
section .text ;return 0 only if two (64-bit) parameters are equal
equal_:
push ebp
mov ebp, esp
mov eax, [ebp+8] ;eax <- addr of 1st param
mov ecx, [ebp+12] ;ecx <- addr of 2nd param
pop ebp
mov edx, [eax+4] ;edx <- hi dword of 1st param
mov eax, [eax] ;eax <- lo dword of 1st param
xor eax, [ecx] ;xor 1st and 2nd params
xor edx, [ecx+4]
push edx
push eax
fld qword [esp]
add esp, 8
ret