📄 crc_asm.asm
字号:
; crc_asm.asm -- crc32 checksum in assembly;; This file is part of the UCL data compression library.;; Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer; Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer; Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer; Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer; Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer; Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer; Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer;; The UCL library is free software; you can redistribute it and/or; modify it under the terms of the GNU General Public License as; published by the Free Software Foundation; either version 2 of; the License, or (at your option) any later version.;; The UCL library is distributed in the hope that it will be useful,; but WITHOUT ANY WARRANTY; without even the implied warranty of; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License; along with the UCL library; see the file COPYING.; If not, write to the Free Software Foundation, Inc.,; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.;; Markus F.X.J. Oberhumer; <markus@oberhumer.com>;%include "conf.ash" .text%macro CRC_CORE 0 %if 0 mov bl, al %else movzx ebx, al %endif shr eax, 8 xor eax, [edi + 4*ebx]%endmacro%macro CRC 0 xor al, [esi] inc esi CRC_CORE%endmacro; /***********************************************************************; // nrv_crc32_asm(unsigned crc, const void *buf, unsigned len, const unsigned *tab); ************************************************************************/UCL_PUBLIC nrv_crc32_asm push_cregs xor eax, eax%if 0 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 16unrolled_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 bytesremainder: and ecx, byte 7 jz donesmall_loop: CRC dec ecx jnz small_loopdone: not eaxreturn: pop_cregs retUCL_PUBLIC_END nrv_crc32_asm; vi:ts=8:et
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -