7zCrcT8U_x86.asm 1.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101

SECTION .text

%macro CRC1b 0
    movzx EDX, BYTE [ESI]
    inc ESI
    movzx EBX, AL
    xor EDX, EBX 
    shr EAX, 8
    xor EAX, [EBP + EDX * 4]
    dec EDI
%endmacro

data_size equ (28)
crc_table equ (data_size + 4)

align 16
global CrcUpdateT8:function
global _CrcUpdateT8:function
CrcUpdateT8:
_CrcUpdateT8:
    push EBX
    push ESI
    push EDI
    push EBP

    mov	EAX, [ESP + 20]        ; CRC
    mov	ESI, [ESP + 24]        ; buf
    mov	EDI, [ESP + data_size] ; size
    mov EBP, [ESP + crc_table] ; tables

    test EDI, EDI
    jz sl_end
  sl:
    test ESI, 7
    jz sl_end
    CRC1b
    jnz sl
  sl_end:

    cmp EDI, 16
    jb NEAR crc_end
    mov [ESP + data_size], EDI
    sub EDI, 8
    and EDI, ~ 7
    sub [ESP + data_size], EDI

    add EDI, ESI
    xor EAX, [ESI]
    mov EBX, [ESI + 4]
    movzx ECX, BL
    align 16
  main_loop:
    mov EDX, [EBP + ECX*4 + 0C00h]
    movzx ECX, BH
    xor EDX, [EBP + ECX*4 + 0800h]
    shr EBX, 16
    movzx ECX, BL
    xor EDX, [EBP + ECX*4 + 0400h]
    xor EDX, [ESI + 8]
    movzx ECX, AL
    movzx EBX, BH
    xor EDX, [EBP + EBX*4 + 0000h]

    mov EBX, [ESI + 12]

    xor EDX, [EBP + ECX*4 + 01C00h]
    movzx ECX, AH
    add ESI, 8
    shr EAX, 16
    xor EDX, [EBP + ECX*4 + 01800h]
    movzx ECX, AL
    xor EDX, [EBP + ECX*4 + 01400h]
    movzx ECX, AH
    mov EAX, [EBP + ECX*4 + 01000h]
    movzx ECX, BL
    xor EAX,EDX

    cmp ESI, EDI
    jne	main_loop
    xor	EAX, [ESI]

    mov EDI, [ESP + data_size]

  crc_end:

    test EDI, EDI
    jz fl_end
  fl:
    CRC1b
    jnz fl
  fl_end:

    pop EBP
    pop EDI
    pop ESI
    pop EBX
    ret ; 8


end