Skip to content

Instantly share code, notes, and snippets.

@iamgreaser
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamgreaser/11203240 to your computer and use it in GitHub Desktop.
Save iamgreaser/11203240 to your computer and use it in GitHub Desktop.
tiny self-CRC code in x86 asm (50 bytes, DOES NOT PRINT)
; 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