2 # ConvertAsm.py: Automatically generated from CopyMem.asm
4 #------------------------------------------------------------------------------
6 # Copyright (c) 2006 - 2008, Intel Corporation
7 # All rights reserved. This program and the accompanying materials
8 # are licensed and made available under the terms and conditions of the BSD License
9 # which accompanies this distribution. The full text of the license may be found at
10 # http://opensource.org/licenses/bsd-license.php
12 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
25 #------------------------------------------------------------------------------
27 #------------------------------------------------------------------------------
30 # InternalMemCopyMem (
31 # IN VOID *Destination,
35 #------------------------------------------------------------------------------
36 .intel_syntax noprefix
37 ASM_GLOBAL ASM_PFX(InternalMemCopyMem)
38 ASM_PFX(InternalMemCopyMem):
41 mov rsi, rdx # rsi <- Source
42 mov rdi, rcx # rdi <- Destination
43 lea r9, [rsi + r8 - 1] # r9 <- Last byte of Source
45 mov rax, rdi # rax <- Destination as return value
46 jae L0 # Copy forward if Source > Destination
47 cmp r9, rdi # Overlapped?
48 jae L_CopyBackward # Copy backward if overlapped
51 sub rcx, rdi # rcx <- -rdi
52 and rcx, 15 # rcx + rsi should be 16 bytes aligned
53 jz L1 # skip if rcx == 0
61 shr rcx, 4 # rcx <- # of DQwords to copy
63 movdqa [rsp + 0x18], xmm0 # save xmm0 on stack
65 movdqu xmm0, [rsi] # rsi may not be 16-byte aligned
66 movntdq [rdi], xmm0 # rdi should be 16-byte aligned
71 movdqa xmm0, [rsp + 0x18] # restore xmm0
72 jmp L_CopyBytes # copy remaining bytes
74 mov rsi, r9 # rsi <- Last byte of Source
75 lea rdi, [rdi + r8 - 1] # rdi <- Last byte of Destination