2018-05-18 08:50:07 +00:00
|
|
|
.code
|
|
|
|
memcpySSE proc
|
|
|
|
; dst = rcx
|
|
|
|
; src = rdx
|
|
|
|
; len = r8
|
|
|
|
|
2018-05-22 08:58:56 +00:00
|
|
|
mov rax, rcx
|
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
test r8, r8
|
|
|
|
jz @Exit
|
2018-05-22 08:58:56 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
cmp rcx, rdx
|
|
|
|
je @Exit
|
|
|
|
|
|
|
|
sub rsp, 8 + 2*16 + 4*8
|
|
|
|
movdqa oword ptr [rsp + 4*8 + 00 ], xmm6
|
|
|
|
movdqa oword ptr [rsp + 4*8 + 16 ], xmm7
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
; void * end = dst + (length & ~0x7F);
|
2018-05-18 08:50:07 +00:00
|
|
|
; end = r10
|
|
|
|
mov r9 , r8
|
2018-05-22 08:58:56 +00:00
|
|
|
and r9 , 0FFFFFFFFFFFFFF80h
|
2018-05-19 11:40:13 +00:00
|
|
|
jz @RemainingBlocks
|
2018-05-18 08:50:07 +00:00
|
|
|
mov r10, rcx
|
|
|
|
add r10, r9
|
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@FullLoop:
|
2018-05-18 08:50:07 +00:00
|
|
|
vmovaps xmm0 , xmmword ptr [rdx + 000h]
|
|
|
|
vmovaps xmm1 , xmmword ptr [rdx + 010h]
|
|
|
|
vmovaps xmm2 , xmmword ptr [rdx + 020h]
|
|
|
|
vmovaps xmm3 , xmmword ptr [rdx + 030h]
|
|
|
|
vmovaps xmm4 , xmmword ptr [rdx + 040h]
|
|
|
|
vmovaps xmm5 , xmmword ptr [rdx + 050h]
|
|
|
|
vmovaps xmm6 , xmmword ptr [rdx + 060h]
|
|
|
|
vmovaps xmm7 , xmmword ptr [rdx + 070h]
|
|
|
|
vmovntdq xmmword ptr [rcx + 000h], xmm0
|
|
|
|
vmovntdq xmmword ptr [rcx + 010h], xmm1
|
|
|
|
vmovntdq xmmword ptr [rcx + 020h], xmm2
|
|
|
|
vmovntdq xmmword ptr [rcx + 030h], xmm3
|
|
|
|
vmovntdq xmmword ptr [rcx + 040h], xmm4
|
|
|
|
vmovntdq xmmword ptr [rcx + 050h], xmm5
|
|
|
|
vmovntdq xmmword ptr [rcx + 060h], xmm6
|
|
|
|
vmovntdq xmmword ptr [rcx + 070h], xmm7
|
2018-05-19 11:40:13 +00:00
|
|
|
add rdx, 080h
|
|
|
|
add rcx, 080h
|
2018-05-18 08:50:07 +00:00
|
|
|
cmp rcx, r10
|
2018-05-19 11:40:13 +00:00
|
|
|
jne @FullLoop
|
|
|
|
|
|
|
|
@RemainingBlocks:
|
|
|
|
; size_t rem = (length & 0x7F) >> 4);
|
|
|
|
; rem = r11
|
|
|
|
mov r11, r8
|
|
|
|
and r11, 07Fh
|
|
|
|
jz @RestoreExit
|
|
|
|
shr r11, 4
|
2018-05-22 08:58:56 +00:00
|
|
|
jz @FinalBytes
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
mov r10, 7
|
2018-05-18 08:50:07 +00:00
|
|
|
sub r10, r11
|
2018-05-19 11:40:13 +00:00
|
|
|
imul r10, 10
|
|
|
|
lea r9 , @FinalBlocks
|
2018-05-18 08:50:07 +00:00
|
|
|
add r9 , r10
|
|
|
|
jmp r9
|
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@RestoreExit:
|
2018-05-22 08:58:56 +00:00
|
|
|
movdqa xmm6 , oword ptr [rsp + 4*8 + 00]
|
|
|
|
movdqa xmm7 , oword ptr [rsp + 4*8 + 16]
|
2018-05-19 11:40:13 +00:00
|
|
|
add rsp, 8 + 2*16 + 4*8
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Exit:
|
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@FinalBlocks:
|
2018-05-18 08:50:07 +00:00
|
|
|
vmovaps xmm6 , xmmword ptr [rdx + 060h]
|
|
|
|
vmovntdq xmmword ptr [rcx + 060h], xmm6
|
|
|
|
vmovaps xmm5 , xmmword ptr [rdx + 050h]
|
|
|
|
vmovntdq xmmword ptr [rcx + 050h], xmm5
|
|
|
|
vmovaps xmm4 , xmmword ptr [rdx + 040h]
|
|
|
|
vmovntdq xmmword ptr [rcx + 040h], xmm4
|
|
|
|
vmovaps xmm3 , xmmword ptr [rdx + 030h]
|
|
|
|
vmovntdq xmmword ptr [rcx + 030h], xmm3
|
|
|
|
vmovaps xmm2 , xmmword ptr [rdx + 020h]
|
|
|
|
vmovntdq xmmword ptr [rcx + 020h], xmm2
|
|
|
|
vmovaps xmm1 , xmmword ptr [rdx + 010h]
|
|
|
|
vmovntdq xmmword ptr [rcx + 010h], xmm1
|
|
|
|
vmovaps xmm0 , xmmword ptr [rdx + 000h]
|
|
|
|
vmovntdq xmmword ptr [rcx + 000h], xmm0
|
|
|
|
|
2018-05-22 08:58:56 +00:00
|
|
|
movdqa xmm6 , oword ptr [rsp + 4*8 + 00]
|
|
|
|
movdqa xmm7 , oword ptr [rsp + 4*8 + 16]
|
|
|
|
add rsp, 8 + 2*16 + 4*8
|
|
|
|
sfence
|
|
|
|
|
|
|
|
shl r11, 4
|
|
|
|
add rdx, r11
|
|
|
|
add rcx, r11
|
2018-05-19 11:40:13 +00:00
|
|
|
|
2018-05-22 08:58:56 +00:00
|
|
|
@FinalBytes:
|
2018-05-19 11:40:13 +00:00
|
|
|
and r8, 0Fh
|
2018-05-22 08:58:56 +00:00
|
|
|
jz @Exit
|
|
|
|
imul r8, 5
|
|
|
|
lea r9, @FinalBytesTable
|
|
|
|
add r9, r8
|
|
|
|
jmp r9
|
|
|
|
|
|
|
|
@FinalBytesTable:
|
|
|
|
jmp @Copy1
|
|
|
|
jmp @Copy2
|
|
|
|
jmp @Copy3
|
|
|
|
jmp @Copy4
|
|
|
|
jmp @Copy5
|
|
|
|
jmp @Copy6
|
|
|
|
jmp @Copy7
|
|
|
|
jmp @Copy8
|
|
|
|
jmp @Copy9
|
|
|
|
jmp @Copy10
|
|
|
|
jmp @Copy11
|
|
|
|
jmp @Copy12
|
|
|
|
jmp @Copy13
|
|
|
|
jmp @Copy14
|
|
|
|
jmp @Copy15
|
|
|
|
|
|
|
|
db 128 DUP(0CCh)
|
2018-05-19 11:40:13 +00:00
|
|
|
|
|
|
|
; fall through - 1 byte
|
2018-05-22 08:58:56 +00:00
|
|
|
@Copy1:
|
2018-05-18 08:50:07 +00:00
|
|
|
mov al, byte ptr [rdx]
|
|
|
|
mov byte ptr [rcx], al
|
2018-05-22 08:58:56 +00:00
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Copy2:
|
2018-05-18 08:50:07 +00:00
|
|
|
mov r10w, word ptr [rdx]
|
|
|
|
mov word ptr [rcx], r10w
|
2018-05-22 08:58:56 +00:00
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Copy3:
|
2018-05-18 08:50:07 +00:00
|
|
|
mov r10w, word ptr [rdx]
|
|
|
|
mov word ptr [rcx], r10w
|
2018-05-22 08:58:56 +00:00
|
|
|
mov r11b, byte ptr [rdx + 02h]
|
|
|
|
mov byte ptr [rcx + 02h], r11b
|
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Copy4:
|
|
|
|
mov r9d, dword ptr [rdx]
|
2018-05-18 08:50:07 +00:00
|
|
|
mov dword ptr [rcx], r9d
|
2018-05-22 08:58:56 +00:00
|
|
|
ret
|
2018-05-19 11:40:13 +00:00
|
|
|
|
|
|
|
@Copy5:
|
|
|
|
mov r9d, dword ptr [rdx ]
|
2018-05-22 08:58:56 +00:00
|
|
|
mov r11b , byte ptr [rdx + 04h]
|
2018-05-19 11:40:13 +00:00
|
|
|
mov dword ptr [rcx ], r9d
|
2018-05-22 08:58:56 +00:00
|
|
|
mov byte ptr [rcx + 04h], r11b
|
|
|
|
ret
|
2018-05-19 11:40:13 +00:00
|
|
|
|
|
|
|
@Copy6:
|
|
|
|
mov r9d , dword ptr [rdx ]
|
|
|
|
mov r10w, word ptr [rdx + 04h]
|
|
|
|
mov dword ptr [rcx ], r9d
|
|
|
|
mov word ptr [rcx + 04h], r10w
|
2018-05-22 08:58:56 +00:00
|
|
|
ret
|
2018-05-19 11:40:13 +00:00
|
|
|
|
|
|
|
@Copy7:
|
|
|
|
mov r9d , dword ptr [rdx ]
|
|
|
|
mov r10w, word ptr [rdx + 04h]
|
2018-05-22 08:58:56 +00:00
|
|
|
mov r11b, byte ptr [rdx + 06h]
|
2018-05-19 11:40:13 +00:00
|
|
|
mov dword ptr [rcx ], r9d
|
|
|
|
mov word ptr [rcx + 04h], r10w
|
2018-05-22 08:58:56 +00:00
|
|
|
mov byte ptr [rcx + 06h], r11b
|
|
|
|
ret
|
2018-05-19 11:40:13 +00:00
|
|
|
|
|
|
|
@Copy8:
|
2018-05-18 08:50:07 +00:00
|
|
|
mov r8, qword ptr [rdx]
|
|
|
|
mov qword ptr [rcx], r8
|
2018-05-22 08:58:56 +00:00
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Copy9:
|
2018-05-22 08:58:56 +00:00
|
|
|
mov r8 , qword ptr [rdx ]
|
|
|
|
mov r11b, byte ptr [rdx + 08h]
|
2018-05-19 11:40:13 +00:00
|
|
|
mov qword ptr [rcx ], r8
|
2018-05-22 08:58:56 +00:00
|
|
|
mov byte ptr [rcx + 08h], r11b
|
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Copy10:
|
|
|
|
mov r8 , qword ptr [rdx ]
|
|
|
|
mov r10w, word ptr [rdx + 08h]
|
|
|
|
mov qword ptr [rcx ], r8
|
|
|
|
mov word ptr [rcx + 08h], r10w
|
2018-05-22 08:58:56 +00:00
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Copy11:
|
|
|
|
mov r8 , qword ptr [rdx ]
|
|
|
|
mov r10w, word ptr [rdx + 08h]
|
2018-05-22 08:58:56 +00:00
|
|
|
mov r11b, byte ptr [rdx + 0Ah]
|
2018-05-19 11:40:13 +00:00
|
|
|
mov qword ptr [rcx ], r8
|
|
|
|
mov word ptr [rcx + 08h], r10w
|
2018-05-22 08:58:56 +00:00
|
|
|
mov byte ptr [rcx + 0Ah], r11b
|
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Copy12:
|
|
|
|
mov r8 , qword ptr [rdx ]
|
|
|
|
mov r9d, dword ptr [rdx + 08h]
|
|
|
|
mov qword ptr [rcx ], r8
|
2018-05-18 08:50:07 +00:00
|
|
|
mov dword ptr [rcx + 08h], r9d
|
2018-05-22 08:58:56 +00:00
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Copy13:
|
2018-05-22 08:58:56 +00:00
|
|
|
mov r8 , qword ptr [rdx ]
|
|
|
|
mov r9d , dword ptr [rdx + 08h]
|
|
|
|
mov r11b, byte ptr [rdx + 0Ch]
|
2018-05-19 11:40:13 +00:00
|
|
|
mov qword ptr [rcx ], r8
|
2018-05-18 08:50:07 +00:00
|
|
|
mov dword ptr [rcx + 08h], r9d
|
2018-05-22 08:58:56 +00:00
|
|
|
mov byte ptr [rcx + 0Ch], r11b
|
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
2018-05-19 11:40:13 +00:00
|
|
|
@Copy14:
|
2018-05-18 08:50:07 +00:00
|
|
|
mov r8 , qword ptr [rdx ]
|
|
|
|
mov r9d , dword ptr [rdx + 08h]
|
|
|
|
mov r10w, word ptr [rdx + 0Ch]
|
|
|
|
mov qword ptr [rcx ], r8
|
|
|
|
mov dword ptr [rcx + 08h], r9d
|
|
|
|
mov word ptr [rcx + 0Ch], r10w
|
2018-05-22 08:58:56 +00:00
|
|
|
ret
|
2018-05-19 11:40:13 +00:00
|
|
|
|
|
|
|
; copy 15
|
|
|
|
@Copy15:
|
|
|
|
mov r8 , qword ptr [rdx + 00h]
|
|
|
|
mov r9d , dword ptr [rdx + 08h]
|
|
|
|
mov r10w, word ptr [rdx + 0Ch]
|
2018-05-22 08:58:56 +00:00
|
|
|
mov r11b, byte ptr [rdx + 0Eh]
|
2018-05-19 11:40:13 +00:00
|
|
|
mov qword ptr [rcx + 00h], r8
|
|
|
|
mov dword ptr [rcx + 08h], r9d
|
|
|
|
mov word ptr [rcx + 0Ch], r10w
|
2018-05-22 08:58:56 +00:00
|
|
|
mov byte ptr [rcx + 0Eh], r11b
|
|
|
|
ret
|
2018-05-18 08:50:07 +00:00
|
|
|
|
|
|
|
memcpySSE endp
|
|
|
|
end
|