1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
16 ;------------------------------------------------------------------------------
21 ;------------------------------------------------------------------------------
24 ; InternalMemCopyMem (
25 ; OUT VOID *DestinationBuffer,
26 ; IN CONST VOID *SourceBuffer,
29 ;------------------------------------------------------------------------------
30 global ASM_PFX(InternalMemCopyMem)
31 ASM_PFX(InternalMemCopyMem):
34 mov rsi, rdx ; rsi <- Source
35 mov rdi, rcx ; rdi <- Destination
36 lea r9, [rsi + r8 - 1] ; r9 <- End of Source
38 mov rax, rdi ; rax <- Destination as return value
41 jae @CopyBackward ; Copy backward if overlapped
45 shr rcx, 3 ; rcx <- # of Qwords to copy
47 DB 0x49, 0xf, 0x7e, 0xc2 ; movd r10, mm0 (Save mm0 in r10)
49 DB 0xf, 0x6f, 0x6 ; movd mm0, [rsi]
50 DB 0xf, 0xe7, 0x7 ; movntq [rdi], mm0
55 DB 0x49, 0xf, 0x6e, 0xc2 ; movd mm0, r10 (Restore mm0)
58 mov rsi, r9 ; rsi <- End of Source
59 lea rdi, [rdi + r8 - 1] ; rdi <- End of Destination
60 std ; set direction flag
63 rep movsb ; Copy bytes backward