Re: Fastcode : function won't work with length>65535 ?
- From: "Davy Landman" <davy.landman@xxxxxxxxx>
- Date: Wed, 4 Oct 2006 18:58:58 +0200
I too was searching for the fastest CRC function and found the folowing to
be faster than your function :)
have fun!
function CalculateCRC32(var ABuffer; const BufferSize:LongWord): LongWord;
asm
push esi
push edi
push ebx
mov edi,edx
mov esi,eax
xor ebx,ebx
mov eax,$ffffffff
mov ecx,edi
shr ecx,2
jecxz @Rest
@Loop:
mov edx,[esi]
mov bl,al
xor bl,dl
shr eax,8
xor eax,dword ptr [CRC32table+ebx*4]
mov bl,al
xor bl,dh
shr eax,8
xor eax,dword ptr [CRC32table+ebx*4]
shr edx,16
mov bl,al
xor bl,dl
shr eax,8
xor eax,dword ptr [CRC32table+ebx*4]
mov bl,al
xor bl,dh
shr eax,8
xor eax,dword ptr [CRC32table+ebx*4]
add esi,4
loop @Loop
@Rest:
mov ecx,edi
and ecx,3
jecxz @End
@Loop_Rest:
mov bl,al
xor bl,[esi]
shr eax,8
inc esi
xor eax,dword ptr [CRC32table+ebx*4]
loop @Loop_Rest
@End:
xor eax,$ffffffff
pop ebx
pop edi
pop esi
end;
"Nibbler" <no@spam> wrote in message news:451b8148@xxxxxxxxxxxxxxxxxxxxxxxxx
Hello everyone,
Searching for a fast CRC function I found on google groups the Aleksandr
Sharahov optimized one :
function GetShaCRC11(OldCRC: cardinal; StPtr: pointer; StLen: integer):
cardinal;
asm
jcxz @ret
push ebx
xor ebx, ebx
@loop:
movzx ebx, byte ptr [edx]
inc edx
xor bl, al
// shl ebx, 02
shr eax, 08
xor eax, dword ptr [CRCtable+ebx*4]
dec ecx
jne @loop
pop ebx
@ret:
ret
end;
It works great and faster than the previous one I was using, but it seems
to be limited to a StLen<=$FFFF
Using a length > 65535 and an OldCRC=$FFFFFFFF (to be compatible with the
zip CRC) will result in an immediate exit.
I really don't have any asm knowledge, would you please help me to make it
work with a StLen>$FFFF ?
Thank you in advance,
Nibbler.
.
- Follow-Ups:
- Re: Fastcode : function won't work with length>65535 ?
- From: Nibbler
- Re: Fastcode : function won't work with length>65535 ?
- From: Dennis
- Re: Fastcode : function won't work with length>65535 ?
- Prev by Date: Re: stable sort in delphi needed
- Next by Date: Re: Fastcode StrToInt32 B&V 0.2.0
- Previous by thread: Re: Fastcode AnsiStringReplace B&V 1.6.2
- Next by thread: Re: Fastcode : function won't work with length>65535 ?
- Index(es):
Relevant Pages
|
|