]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibMmx/X64/CopyMem.S
Update copyright for files modified in this year
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibMmx / X64 / CopyMem.S
1 #
2 # ConvertAsm.py: Automatically generated from CopyMem.asm
3 #
4 #------------------------------------------------------------------------------
5 #
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
11 #
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.
14 #
15 # Module Name:
16 #
17 # CopyMem.S
18 #
19 # Abstract:
20 #
21 # CopyMem function
22 #
23 # Notes:
24 #
25 #------------------------------------------------------------------------------
26
27
28 #------------------------------------------------------------------------------
29 # VOID *
30 # EFIAPI
31 # InternalMemCopyMem (
32 # IN VOID *Destination,
33 # IN VOID *Source,
34 # IN UINTN Count
35 # )
36 #------------------------------------------------------------------------------
37 .intel_syntax noprefix
38 .globl ASM_PFX(InternalMemCopyMem)
39 ASM_PFX(InternalMemCopyMem):
40 push rsi
41 push rdi
42 mov rsi, rdx # rsi <- Source
43 mov rdi, rcx # rdi <- Destination
44 lea r9, [rsi + r8 - 1] # r9 <- End of Source
45 cmp rsi, rdi
46 mov rax, rdi # rax <- Destination as return value
47 jae L0
48 cmp r9, rdi
49 jae L_CopyBackward # Copy backward if overlapped
50 L0:
51 mov rcx, r8
52 and r8, 7
53 shr rcx, 3 # rcx <- # of Qwords to copy
54 jz L_CopyBytes
55 movd r10, mm0 # (Save mm0 in r10)
56 L1:
57 movq mm0, [rsi]
58 movntq [rdi], mm0
59 add rsi, 8
60 add rdi, 8
61 loop L1
62 mfence
63 movd mm0, r10 # (Restore mm0)
64 jmp L_CopyBytes
65 L_CopyBackward:
66 mov rsi, r9 # rsi <- End of Source
67 lea rdi, [rdi + r8 - 1] # rdi <- End of Destination
68 std # set direction flag
69 L_CopyBytes:
70 mov rcx, r8
71 rep movsb # Copy bytes backward
72 cld
73 pop rdi
74 pop rsi
75 ret