flat assembler
Message board for the users of flat assembler.
Index
> Main > Calculating CRC32 - Cyclic Redundancy Check 32-bit |
Author |
|
Matrix 17 Nov 2004, 04:45
( it does nothing but calculating crc32 )
Code: ;CRC32 - Cyclic Redundancy Check 32-bit mov esi, _crc_ ;start of block mov edi, crc_end-_crc_ ;size of block call CRC32 ;check code integrity cmp eax, 0DACA92DCh ;CRC32 match? ret ; nothing serious _crc_=$ CRC32: push ebx xor ecx, ecx dec ecx mov edx, ecx NextByteCRC: xor eax, eax ;Ehrm, this is very fast xor ebx, ebx ;procedure to code CRC32 at lodsb ;runtime, no need to use big xor al, cl ;tables. mov cl, ch mov ch, dl mov dl, dh mov dh, 8 NextBitCRC: shr bx, 1 rcr ax, 1 jnc NoCRC xor ax, 08320h xor bx, 0edb8h NoCRC: dec dh jnz NextBitCRC xor ecx, eax xor edx, ebx dec edi jne NextByteCRC not edx not ecx pop ebx mov eax, edx rol eax, 16 mov ax, cx ret crc_end=$ Although the MD5, SHA1, SHA256, SHA384, and SHA512 are more accurate than the CRC32 algorithm, sometimes you do not have a choice due various reasons. This class can be used without modification anywhere other HashAlgorithm classes can. so you should try this search on gogle |
|||
17 Nov 2004, 04:45 |
|
Howesr1@yahoo.com 17 May 2011, 17:35
How about if I use the fasm crc32.
How do I seed it with the prior CRC value? Is it: crc32 edx,eax xor [crc32val],edx Does this make sense? |
|||
17 May 2011, 17:35 |
|
cod3b453 17 May 2011, 20:55
I don't fully understand the code but the initialisation vector (default 0xFFFFFFFF) looks to be the value generated at the start in ecx. If you remove those two lines (xor ecx,ecx, dec ecx) you can try calling the function with ecx set to 0xFFFFFFFF on the first call and the result in eax for subsequent calls.
|
|||
17 May 2011, 20:55 |
|
Howesr1@yahoo.com 17 May 2011, 23:25
Thank you. I have a sinpler question, but not so easy answer!
Why does my code hang right here... crc32 edx,eax Does anyone have any info on this FASM function? the manual doesn't say very much. Am I missing something????? crc32 accumulates a CRC32 value for the source operand starting with initial value provided by destination operand, and stores the result in des-tination. Unless in long mode, the destination operand should be a 32{bitgeneral purpose register, and the source operand can be a byte, word, or dou-ble word register or memory location. In long mode the destination operandcan also be a 64{bit general purpose register, and the source operand in suchcase can be a byte or quad word register or memory location. crc32 eax,dl ; accumulate CRC32 on byte value crc32 eax,word [ebx] ; accumulate CRC32 on word value crc32 rax,qword [rbx] ; accumulate CRC32 on quad word value |
|||
17 May 2011, 23:25 |
|
rugxulo 30 May 2011, 04:48
Perhaps your computer doesn't support SSE 4.2 ?
Check here for a demo (using GCC w/ intrinsics): http://drdobbs.com/high-performance-computing/229401411 |
|||
30 May 2011, 04:48 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.