porting Crc32Dynamic from Visual Studio.net to 64bit Visual Studio 2005

Started by sidewalk_bends, August 23, 2006, 11:47:03 PM

Previous topic - Next topic

lingo

asm code can be smaller and faster: :wink

mov edx, dwBytesRead       ; Load dwBytesRead
mov eax, dwCrc32           ; Load Crc32 value
lea edx, [esi + edx]       ; Calculate the end of the buffer
mov edi, pTable            ; Load the CRC32 table
mov esi, buffer            ; Load buffer

crc32loop:

movzx ecx, byte ptr [esi]; Clear the ecx register and  Load the current source byte
xor cl, al            ; Copy crc value into ecx

shr eax, 8

xor eax, [edi + ecx * 4]   ; Get the value out of the table
add esi,1                  ; Advance the source pointer

cmp edx, esi               ; Have we reached the end of the buffer?
jne crc32loop

ret                    ;return Crc32 in eax

Regards,
Lingo