kolibrios-fun/programs/fs/kfar/trunk/kfar_arc/crc.inc
Evgeny Grechnikov (Diamond) 1d9fff9e92 KFar 0.4 + KFar_Arc 0.1
git-svn-id: svn://kolibrios.org@589 a494cfbc-eb01-0410-851d-a64ba20cac60
2007-07-26 12:45:49 +00:00

33 lines
623 B
PHP

init_crc_table:
xor edx, edx
mov edi, crc_table
.1:
mov ecx, 8
mov eax, edx
.2:
shr eax, 1
jnc @f
xor eax, 0xEDB88320
@@:
loop .2
stosd
inc dl
jnz .1
ret
crc:
; in: ecx=size, esi->buffer
; out: eax=crc
or eax, -1
jecxz .end
.loop:
movzx edx, al
xor dl, byte [esi]
inc esi
shr eax, 8
xor eax, [crc_table+edx*4]
loop .loop
.end:
xor eax, -1
ret