|
inline void CRC32Compute(PDWORD pdwCRC, PVOID pvData, DWORD dwSize)
{
__asm
{
xor eax, eax // eax = trash register
mov ebx, [pdwCRC] // ebx = crc value memory address
push ebx // backup crc value memory address
mov ebx, [ebx] // get crc value from memory
mov ecx, [dwSize] // ecx = byte counter
mov edx, [pvData] // edx = data pointer
j1: mov al, [edx] // grab next data byte
xor al, bl // xor data byte with crc byte
shr ebx, 8 // move out 1 byte of crc
xor ebx, [dwCRCTable + eax * 4] // xor crc with value in table
inc edx // increase data pointer
dec ecx // decrease byte counter
jnz j1 // if more bytes do it again
pop eax // get crc value memory address
mov [eax], ebx // put crc value in memory
}
} |
|