]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibSse2/X64/CopyMem.S
Update copyright for files modified in this year
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / 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#------------------------------------------------------------------------------\r
29# VOID *\r
30# EFIAPI\r
31# InternalMemCopyMem (\r
32# IN VOID *Destination,\r
33# IN VOID *Source,\r
34# IN UINTN Count\r
35# )\r
36#------------------------------------------------------------------------------\r
37.intel_syntax noprefix\r
38.globl ASM_PFX(InternalMemCopyMem)\r
39ASM_PFX(InternalMemCopyMem):\r
40 push rsi\r
41 push rdi\r
42 mov rsi, rdx # rsi <- Source\r
43 mov rdi, rcx # rdi <- Destination\r
44 lea r9, [rsi + r8 - 1] # r9 <- Last byte of Source\r
45 cmp rsi, rdi \r
46 mov rax, rdi # rax <- Destination as return value\r
47 jae L0 # Copy forward if Source > Destination\r
48 cmp r9, rdi # Overlapped?\r
49 jae L_CopyBackward # Copy backward if overlapped\r
50L0: \r
51 xor rcx, rcx \r
52 sub rcx, rdi # rcx <- -rdi\r
53 and rcx, 15 # rcx + rsi should be 16 bytes aligned\r
54 jz L1 # skip if rcx == 0\r
55 cmp rcx, r8\r
56 cmova rcx, r8\r
57 sub r8, rcx\r
58 rep movsb\r
59L1:\r
60 mov rcx, r8\r
61 and r8, 15\r
62 shr rcx, 4 # rcx <- # of DQwords to copy\r
63 jz L_CopyBytes\r
64 movdqa [rsp + 0x18], xmm0 # save xmm0 on stack\r
65L2:\r
66 movdqu xmm0, [rsi] # rsi may not be 16-byte aligned\r
67 movntdq [rdi], xmm0 # rdi should be 16-byte aligned\r
68 add rsi, 16\r
69 add rdi, 16\r
70 loop L2\r
71 mfence\r
72 movdqa xmm0, [rsp + 0x18] # restore xmm0\r
73 jmp L_CopyBytes # copy remaining bytes\r
74L_CopyBackward:\r
75 mov rsi, r9 # rsi <- Last byte of Source\r
76 lea rdi, [rdi + r8 - 1] # rdi <- Last byte of Destination\r
77 std\r
78L_CopyBytes:\r
79 mov rcx, r8\r
80 rep movsb\r
81 cld\r
82 pop rdi\r
83 pop rsi\r
84 ret\r