Re: Fastcode CompareMem B&V 1.0



Hi Dennis,

Here are my functions.

--
regards
Aleksandr


function CompareMem_Sha_IA32_1_a(P1, P2: pointer; Length: integer):
boolean;
asm
sub edx, eax
add ecx, -8
push ebx
jl @Byte
mov ebx, [eax+edx]
cmp ebx, [eax]
jne @Ret0
add ecx, eax
add eax, 3
and eax, -4
sub ecx, eax
jl @Byte
@DwordLoop:
mov ebx, [eax+edx]
cmp ebx, [eax]
jne @Ret0
mov ebx, [eax+edx+4]
cmp ebx, [eax+4]
jne @Ret0
add eax, 8
add ecx, -8
jge @DwordLoop
@Byte:
add ecx, 8
jle @Ret1
@ByteLoop:
movzx ebx, [eax+edx]
cmp bl, [eax]
jne @Ret0
add eax, 1
add ecx, -1
jg @ByteLoop
@Ret1:
mov eax, 1
pop ebx
ret
@Ret0:
xor eax, eax
pop ebx
end;

function CompareMem_Sha_IA32_2_a(P1, P2: pointer; Length: integer):
boolean;
asm
add eax, ecx
add edx, ecx
push ebx
neg ecx
add ecx, 8
jg @Byte
mov ebx, [eax+ecx-8]
cmp ebx, [edx+ecx-8]
jne @Ret0
lea ebx, [eax+ecx]
add ecx, 4
and ebx, 3
sub ecx, ebx
jg @Byte
@DwordLoop:
mov ebx, [eax+ecx-8]
cmp ebx, [edx+ecx-8]
jne @Ret0
mov ebx, [eax+ecx-4]
cmp ebx, [edx+ecx-4]
jne @Ret0
add ecx, 8
jle @DwordLoop
@Byte:
add ecx, -8
jge @Ret1
@ByteLoop:
movzx ebx, [eax+ecx]
cmp bl, [edx+ecx]
jne @Ret0
add ecx, 1
jl @ByteLoop
@Ret1:
mov eax, 1
pop ebx
ret
@Ret0:
xor eax, eax
pop ebx
end;


.



Relevant Pages