Last active
August 29, 2015 14:00
-
-
Save iamgreaser/11203240 to your computer and use it in GitHub Desktop.
tiny self-CRC code in x86 asm (50 bytes, DOES NOT PRINT)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; UNTESTED. | |
code_start: | |
bits 32 | |
crc32_self: | |
push esi | |
mov esi, code_start | |
mov ecx, code_end - code_start | |
xor edx, edx | |
dec edx | |
.lp_byte: | |
lodsb | |
xor dl, al | |
.lp_bit: | |
shr edx, 1 | |
jnc .done_bit | |
xor edx, 0xEDB88320 | |
.done_bit: | |
add ch, 0x20 | |
jnc .lp_bit | |
loop .lp_byte | |
mov eax, edx | |
not eax | |
pop esi | |
ret | |
code_end: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment