2 # ConvertAsm.py: Automatically generated from CopyMem.asm
4 #------------------------------------------------------------------------------
6 # Copyright (c) 2006, 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 #------------------------------------------------------------------------------
28 #------------------------------------------------------------------------------
31 # InternalMemCopyMem (
32 # IN VOID *Destination,
36 #------------------------------------------------------------------------------
37 .intel_syntax noprefix
38 .globl ASM_PFX(InternalMemCopyMem)
39 ASM_PFX(InternalMemCopyMem):
42 mov rsi, rdx # rsi <- Source
43 mov rdi, rcx # rdi <- Destination
44 lea r9, [rsi + r8 - 1] # r9 <- Last byte of Source
46 mov rax, rdi # rax <- Destination as return value
47 jae L0 # Copy forward if Source > Destination
48 cmp r9, rdi # Overlapped?
49 jae L_CopyBackward # Copy backward if overlapped
52 sub rcx, rdi # rcx <- -rdi
53 and rcx, 15 # rcx + rsi should be 16 bytes aligned
54 jz L1 # skip if rcx == 0
62 shr rcx, 4 # rcx <- # of DQwords to copy
64 movdqa [rsp + 0x18], xmm0 # save xmm0 on stack
66 movdqu xmm0, [rsi] # rsi may not be 16-byte aligned
67 movntdq [rdi], xmm0 # rdi should be 16-byte aligned
72 movdqa xmm0, [rsp + 0x18] # restore xmm0
73 jmp L_CopyBytes # copy remaining bytes
75 mov rsi, r9 # rsi <- Last byte of Source
76 lea rdi, [rdi + r8 - 1] # rdi <- Last byte of Destination