]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S
Import some basic libraries instances for Mde Packages.
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibRepStr / Ia32 / CopyMem.S
1 //
2 // Include common header file for this module.
3 //
4 #include "CommonHeader.h"
5
6 #------------------------------------------------------------------------------
7 #
8 # Copyright (c) 2006, Intel Corporation
9 # All rights reserved. This program and the accompanying materials
10 # are licensed and made available under the terms and conditions of the BSD License
11 # which accompanies this distribution. The full text of the license may be found at
12 # http://opensource.org/licenses/bsd-license.php
13 #
14 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #
17 # Module Name:
18 #
19 # CopyMem.Asm
20 #
21 # Abstract:
22 #
23 # CopyMem function
24 #
25 # Notes:
26 #
27 #------------------------------------------------------------------------------
28
29 .globl _InternalMemCopyMem
30
31 #------------------------------------------------------------------------------
32 # VOID *
33 # EFIAPI
34 # InternalMemCopyMem (
35 # IN VOID *Destination,
36 # IN VOID *Source,
37 # IN UINTN Count
38 # );
39 #------------------------------------------------------------------------------
40 _InternalMemCopyMem:
41 push %esi
42 push %edi
43 movl 16(%esp), %esi # esi <- Source
44 movl 12(%esp), %edi # edi <- Destination
45 movl 20(%esp), %edx # edx <- Count
46 leal -1(%esi, %edx), %eax # eax <- End of Source
47 cmpl %edi, %esi
48 jae L0
49 cmpl %edi, %eax
50 jae L_CopyBackward # Copy backward if overlapped
51 L0:
52 movl %edx, %ecx
53 andl $3, %edx
54 shrl $2, %ecx
55 rep
56 movsl # Copy as many Dwords as possible
57 jmp L_CopyBytes
58 L_CopyBackward:
59 movl %eax, %esi # esi <- End of Source
60 leal -1(%edi, %edx), %edi # edi <- End of Destination
61 std
62 L_CopyBytes:
63 movl %edx, %ecx
64 rep
65 movsb # Copy bytes backward
66 cld
67 movl 12(%esp), %eax # eax <- Destination as return value
68 pop %edi
69 pop %esi
70 ret