intel在sse4.2指令集中加入了crc32算法,只要一条指令就能代替crc32算法 指令简介: 指令格式:crc32 reg16/reg32/reg64/mem16/mem32/mem64,reg16/reg32/reg64 示例代码: sse4_crc32 proc;buffer in rcx, size in rdx sub rsp, 28h mov rax, 0FFFFFFFFh ; rax = -1 crc32_loop: mov dl , [ rcx ] crc32 rax, dl inc rcx edc rdx cmp rdx, 0 jne crc32_loop add rsp, 28h ret sse4_crc32 endp SSE4_CRC32 proc; buffer in rcx, size in rdx sub rsp, 28h mov rax, 0FFFFFFFFh; rax = -1 @R0: cmp rdx, 8 jb @R1 mov rbx, [ rcx ] crc32 rax, rbx add rcx, 8 sub rdx, 8 jmp @R0 @R1: cmp rdx, 4 jb @R2 mov ebx, [ rcx ] crc32 rax, ebx add rcx, 4 sub rdx, 4 jmp @R1 @R2: cmp rdx, 0 je @End mov bl, [ rcx ] crc32 rax, bl inc rcx dec rdx jmp @R2 @End: add rsp, 28h SSE4_CRC32 endp