-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxor_hash.s
More file actions
40 lines (28 loc) · 675 Bytes
/
Copy pathxor_hash.s
File metadata and controls
40 lines (28 loc) · 675 Bytes
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
global __xor_hash
section .text
__xor_hash:
xor rax, rax ; rax = 0
mov rcx, rsi ; rcx = len
shr rcx, 0x3 ; rcx = len / 8
test rcx, rcx
je .process_back ; if rcx == 0 - skip
.process_front_loop:
xor rax, [rdi] ; rax ^= [rdi] (64 bits)
add rdi, 0x8 ; rdi += 8
loop .process_front_loop
.process_back:
mov rcx, rsi ; rcx = len
and rcx, 0b111 ; rcx = len % 8
test rcx, rcx
je .end ; if rcx == 0 - return
add rdi, rcx
dec rdi ; rdi += rcx - 1
xor rdx, rdx ; rdx = 0
.process_back_loop:
shl rdx, 0x8 ; rdx <<= 8
or dl, [rdi] ; rdx |= *rdi
dec rdi ; --rdi
loop .process_back_loop
xor rax, rdx ; rax ^= rdx
.end:
ret