%include "conf.ash"
.text
%define USE_MOVZX
%macro CRC_CORE 0
%ifdef USE_MOVZX
movzx ebx, al
%else
mov bl, al
%endif
shr eax, 8
xor eax, [edi + 4*ebx]
%endmacro
%macro CRC 0
xor al, [esi]
inc esi
CRC_CORE
%endmacro
; /***********************************************************************
; // ucl_crc32_asm(unsigned crc, const void *buf, unsigned len, const unsigned *tab)
; ************************************************************************/
UCL_PUBLIC ucl_crc32_asm
push_cregs
xor eax, eax
%ifndef USE_MOVZX
xor ebx, ebx
%endif
mov esi, [esp + cregs_size + 8] ; esi = buf
mov ecx, [esp + cregs_size + 12] ; ecx = len
mov edi, [esp + cregs_size + 16] ; edi = crc32_table
test esi, esi
jz return
mov eax, [esp + cregs_size + 4] ; eax = crc
not eax
%if 1
test ecx, ecx
jz done
; the first 0..3 bytes (until esi is dword aligned)
align_loop:
test esi, 3
jz .break
CRC
dec ecx
jnz align_loop
.break:
%endif
; the unrolled loop - 8 bytes per loop
mov edx, ecx
shr edx, 3
jz remainder
align_code 16
unrolled_loop:
%rep 2
xor eax, [esi]
add esi, byte 4
CRC_CORE
CRC_CORE
CRC_CORE
CRC_CORE
%endrep
dec edx
jnz unrolled_loop
; the remaining 0..7 bytes
remainder:
and ecx, byte 7
jz done
small_loop:
CRC
dec ecx
jnz small_loop
done:
not eax
return:
pop_cregs
ret
UCL_PUBLIC_END ucl_crc32_asm
; vi:ts=8:et
// masm 可编译的代码
; Markus F.X.J. Oberhumer
; <markus@oberhumer.com>
; 2f3K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4N6%4N6#2)9J5k6h3!0T1k6i4u0Z5N6h3#2W2M7W2)9J5k6h3y4G2L8g2)9J5c8X3!0H3k6h3&6K6L8%4g2J5j5$3g2Q4x3V1k6#2j5$3I4Q4x3V1j5`.
;
; /***** DO NOT EDIT - GENERATED AUTOMATICALLY *****/
include asminit.def
public _ucl_crc32_asm
_ucl_crc32_asm:
db 85,87,86,83,81,82,49,192,139,116,36,32,139,76,36,36
db 139,124,36,40,133,246,15,132,159,0,0,0,139,68,36,28
db 247,208,133,201,15,132,143,0,0,0,247,198,3,0,0,0
db 116,15,50,6,70,15,182,216,193,232,8,51,4,159,73,117
db 233,137,202,193,234,3,116,93,144,141,180,38,0,0,0,0
db 51,6,131,198,4,15,182,216,193,232,8,51,4,159,15,182
db 216,193,232,8,51,4,159,15,182,216,193,232,8,51,4,159
db 15,182,216,193,232,8,51,4,159,51,6,131,198,4,15,182
db 216,193,232,8,51,4,159,15,182,216,193,232,8,51,4,159
db 15,182,216,193,232,8,51,4,159,15,182,216,193,232,8,51
db 4,159,74,117,171,131,225,7,116,15,50,6,70,15,182,216
db 193,232,8,51,4,159,73,117,241,247,208,90,89,91,94,95
db 93,195,144,144,144,144,144,144,144,144,144,144,144,144,144,144
end