]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptPei/Ia32/CopyMem.S
Gcc cleanup for baselib & basememorylib in mdepkg/library/
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptPei / Ia32 / CopyMem.S
CommitLineData
7b3b4b29 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
85c25283 24.globl ASM_PFX(InternalMemCopyMem)
7b3b4b29 25
26#------------------------------------------------------------------------------
27# VOID *
28# EFIAPI
29# InternalMemCopyMem (
30# IN VOID *Destination,
31# IN VOID *Source,
32# IN UINTN Count
33# );
34#------------------------------------------------------------------------------
85c25283 35ASM_PFX(InternalMemCopyMem):
7b3b4b29 36 push %esi
37 push %edi
38 movl 16(%esp), %esi # esi <- Source
39 movl 12(%esp), %edi # edi <- Destination
40 movl 20(%esp), %edx # edx <- Count
85c25283 41 cmpl %esi, %edi
42 je L_CopyDone
5053cf7f 43 cmpl $0, %edx
85c25283 44 je L_CopyDone
7b3b4b29 45 leal -1(%esi, %edx), %eax # eax <- End of Source
85c25283 46 cmpl %edi, %esi
47 jae L_CopyBytes
48 cmpl %edi, %eax
49 jb L_CopyBytes # Copy backward if overlapped
50 movl %eax, %esi # esi <- End of Source
7b3b4b29 51 leal -1(%edi, %edx), %edi # edi <- End of Destination
85c25283 52 std
53L_CopyBytes:
54 movl %edx, %ecx
7b3b4b29 55 rep
56 movsb # Copy bytes backward
57 cld
85c25283 58L_CopyDone:
7b3b4b29 59 movl 12(%esp), %eax # eax <- Destination as return value
60 pop %edi
61 pop %esi
62 ret