]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibSse2/X64/CopyMem.S
Update the copyright notice format
[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
c33c6476
HT
6# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
7# This program and the accompanying materials\r
b1ff428c 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
132f41f0 37ASM_GLOBAL ASM_PFX(InternalMemCopyMem)\r
b1ff428c 38ASM_PFX(InternalMemCopyMem):\r
1fef058f 39 pushq %rsi\r
40 pushq %rdi\r
41 movq %rdx, %rsi # rsi <- Source\r
42 movq %rcx, %rdi # rdi <- Destination\r
43 leaq -1(%rsi, %r8,), %r9 # r9 <- Last byte of Source\r
44 cmpq %rdi, %rsi\r
45 movq %rdi, %rax # rax <- Destination as return value\r
b1ff428c 46 jae L0 # Copy forward if Source > Destination\r
1fef058f 47 cmpq %rdi, %r9 # Overlapped?\r
b1ff428c 48 jae L_CopyBackward # Copy backward if overlapped\r
49L0: \r
1fef058f 50 xorq %rcx, %rcx \r
51 subq %rdi, %rcx # rcx <- -rdi\r
52 andq $15, %rcx # rcx + rsi should be 16 bytes aligned\r
b1ff428c 53 jz L1 # skip if rcx == 0\r
1fef058f 54 cmpq %r8, %rcx\r
55 cmova %r8, %rcx\r
56 subq %rcx, %r8\r
b1ff428c 57 rep movsb\r
58L1:\r
1fef058f 59 movq %r8, %rcx\r
60 andq $15, %r8\r
61 shrq $4, %rcx # rcx <- # of DQwords to copy\r
b1ff428c 62 jz L_CopyBytes\r
1fef058f 63 movdqa %xmm0, 0x18(%rsp) # save xmm0 on stack\r
b1ff428c 64L2:\r
1fef058f 65 movdqu (%rsi), %xmm0 # rsi may not be 16-byte aligned\r
66 movntdq %xmm0, (%rdi) # rdi should be 16-byte aligned\r
67 addq $16, %rsi\r
68 addq $16, %rdi\r
b1ff428c 69 loop L2\r
70 mfence\r
1fef058f 71 movdqa 0x18(%rsp), %xmm0 # restore xmm0\r
b1ff428c 72 jmp L_CopyBytes # copy remaining bytes\r
73L_CopyBackward:\r
1fef058f 74 movq %r9, %rsi # rsi <- Last byte of Source\r
75 leaq -1(%rdi, %r8,), %rdi # rdi <- Last byte of Destination\r
b1ff428c 76 std\r
77L_CopyBytes:\r
1fef058f 78 movq %r8, %rcx\r
b1ff428c 79 rep movsb\r
80 cld\r
1fef058f 81 popq %rdi\r
82 popq %rsi\r
b1ff428c 83 ret\r