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