1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 ; This program and the accompanying materials
5 ; are licensed and made available under the terms and conditions of the BSD License
6 ; which accompanies this distribution. The full text of the license may be found at
7 ; http://opensource.org/licenses/bsd-license.php.
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 ;------------------------------------------------------------------------------
27 ;------------------------------------------------------------------------------
30 ; InternalMemCopyMem (
31 ; IN VOID *Destination,
35 ;------------------------------------------------------------------------------
36 global ASM_PFX(InternalMemCopyMem)
37 ASM_PFX(InternalMemCopyMem):
40 mov rsi, rdx ; rsi <- Source
41 mov rdi, rcx ; rdi <- Destination
42 lea r9, [rsi + r8 - 1] ; r9 <- Last byte of Source
44 mov rax, rdi ; rax <- Destination as return value
45 jae .0 ; Copy forward if Source > Destination
46 cmp r9, rdi ; Overlapped?
47 jae @CopyBackward ; Copy backward if overlapped
50 sub rcx, rdi ; rcx <- -rdi
51 and rcx, 15 ; rcx + rsi should be 16 bytes aligned
52 jz .1 ; skip if rcx == 0
60 shr rcx, 4 ; rcx <- # of DQwords to copy
62 movdqa [rsp + 0x18], xmm0 ; save xmm0 on stack
64 movdqu xmm0, [rsi] ; rsi may not be 16-byte aligned
65 movntdq [rdi], xmm0 ; rdi should be 16-byte aligned
70 movdqa xmm0, [rsp + 0x18] ; restore xmm0
71 jmp @CopyBytes ; copy remaining bytes
73 mov rsi, r9 ; rsi <- Last byte of Source
74 lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination