]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptDxe/X64/CopyMem.S
Update copyright for files modified in this year
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptDxe / X64 / CopyMem.S
CommitLineData
b1ff428c 1#\r
2# ConvertAsm.py: Automatically generated from CopyMem.asm\r
3#\r
4#------------------------------------------------------------------------------\r
5#\r
373ade0e 6# Copyright (c) 2006 - 2008, Intel Corporation\r
b1ff428c 7# All rights reserved. This program and the accompanying materials\r
8# are licensed and made available under the terms and conditions of the BSD License\r
9# which accompanies this distribution. The full text of the license may be found at\r
10# http://opensource.org/licenses/bsd-license.php\r
11#\r
12# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14#\r
15# Module Name:\r
16#\r
17# CopyMem.S\r
18#\r
19# Abstract:\r
20#\r
21# CopyMem function\r
22#\r
23# Notes:\r
24#\r
25#------------------------------------------------------------------------------\r
26\r
27#------------------------------------------------------------------------------\r
28# VOID *\r
29# EFIAPI\r
30# InternalMemCopyMem (\r
31# IN VOID *Destination,\r
32# IN VOID *Source,\r
33# IN UINTN Count\r
34# )\r
2f3d6fb5 35#------------------------------------------------------------------------------\r
36.intel_syntax noprefix\r
37.globl ASM_PFX(InternalMemCopyMem)\r
38ASM_PFX(InternalMemCopyMem):\r
39 push rsi\r
40 push rdi\r
41 mov rsi, rdx # rsi <- Source\r
42 mov rdi, rcx # rdi <- Destination\r
43 lea r9, [rsi + r8 - 1] # r9 <- Last byte of Source\r
44 cmp rsi, rdi\r
45 mov rax, rdi # rax <- Destination as return value\r
46 jae L0 # Copy forward if Source > Destination\r
47 cmp r9, rdi # Overlapped?\r
48 jae @CopyBackward # Copy backward if overlapped\r
49L0:\r
50 xor rcx, rcx\r
51 sub rcx, rdi # rcx <- -rdi\r
52 and rcx, 15 # rcx + rsi should be 16 bytes aligned\r
53 jz L1 # skip if rcx == 0\r
54 cmp rcx, r8\r
55 cmova rcx, r8\r
56 sub r8, rcx\r
57 rep movsb\r
58L1:\r
59 mov rcx, r8\r
60 and r8, 15\r
61 shr rcx, 4 # rcx <- # of DQwords to copy\r
62 jz L_CopyBytes\r
63 movdqa [rsp + 0x18], xmm0 # save xmm0 on stack\r
64L2:\r
65 movdqu xmm0, [rsi] # rsi may not be 16-byte aligned\r
66 movntdq [rdi], xmm0 # rdi should be 16-byte aligned\r
67 add rsi, 16\r
68 add rdi, 16\r
69 loop L2\r
70 mfence\r
71 movdqa xmm0, [rsp + 0x18] # restore xmm0\r
72 jmp L_CopyBytes # copy remaining bytes\r
73L_CopyBackward:\r
74 mov rsi, r9 # rsi <- Last byte of Source\r
75 lea rdi, [rdi + r8 - 1] # rdi <- Last byte of Destination\r
76 std\r
77L_CopyBytes:\r
78 mov rcx, r8\r
79 rep movsb\r
80 cld\r
81 pop rdi\r
82 pop rsi\r
83 ret\r