forked from ShokoAnime/ShokoServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrc32x64.asm
41 lines (29 loc) · 1.11 KB
/
crc32x64.asm
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
.code
crcCalc PROC PUBLIC USES rax rbx rcx rdx rdi rsi pdwCrc32:PTR DWORD, ptrCrc32Table:PTR DWORD,bufferAsm:PTR BYTE,dwBytesReadAsm:DWORD
;mov rax, pdwCrc32 ; Load the pointer to dwCrc32
mov rsi, rcx
mov ecx, [rsi] ; Dereference the pointer to load dwCrc32
;mov rdi, ptrCrc32Table ; Load the CRC32 table
;mov rsi, bufferAsm ; Load buffer
xor rbx, rbx
;mov ebx, dwBytesReadAsm ; Load dwBytesRead
lea rdi, [r8 + r9] ; Calculate the end of the buffer
crc32loop:
xor rax, rax ; Clear the eax register
mov bl, byte ptr [r8] ; Load the current source byte
mov al, cl ; Copy crc value into eax
inc r8 ; Advance the source pointer
xor al, bl ; Create the index into the CRC32 table
shr ecx, 8
mov ebx, [rdx + rax * 4] ; Get the value out of the table
xor ecx, ebx ; xor with the current byte
cmp rdi, r8 ; Have we reached the end of the buffer?
jne crc32loop
; Restore the edi and esi registers
;pop edi
;pop esi
;mov rax, pdwCrc32 ; Load the pointer to dwCrc32
mov [rsi], ecx ; Write the result
ret
crcCalc ENDP
END