2007-10-07 01:23:13 +02:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006, Intel Corporation
|
|
|
|
# All rights reserved. This program and the accompanying materials
|
|
|
|
# are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
# which accompanies this distribution. The full text of the license may be found at
|
|
|
|
# http://opensource.org/licenses/bsd-license.php
|
|
|
|
#
|
|
|
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
#
|
|
|
|
# Module Name:
|
|
|
|
#
|
2008-10-30 02:23:36 +01:00
|
|
|
# CopyMem.S
|
2007-10-07 01:23:13 +02:00
|
|
|
#
|
|
|
|
# Abstract:
|
|
|
|
#
|
|
|
|
# CopyMem function
|
|
|
|
#
|
|
|
|
# Notes:
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
2008-07-31 08:23:32 +02:00
|
|
|
.globl ASM_PFX(InternalMemCopyMem)
|
2007-10-07 01:23:13 +02:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# VOID *
|
|
|
|
# EFIAPI
|
|
|
|
# InternalMemCopyMem (
|
|
|
|
# IN VOID *Destination,
|
|
|
|
# IN VOID *Source,
|
|
|
|
# IN UINTN Count
|
|
|
|
# );
|
|
|
|
#------------------------------------------------------------------------------
|
2008-07-31 08:23:32 +02:00
|
|
|
ASM_PFX(InternalMemCopyMem):
|
2007-10-07 01:23:13 +02:00
|
|
|
push %esi
|
|
|
|
push %edi
|
|
|
|
movl 16(%esp), %esi # esi <- Source
|
|
|
|
movl 12(%esp), %edi # edi <- Destination
|
|
|
|
movl 20(%esp), %edx # edx <- Count
|
2008-07-31 08:23:32 +02:00
|
|
|
cmpl %esi, %edi
|
|
|
|
je L_CopyDone
|
2007-11-08 04:40:50 +01:00
|
|
|
cmpl $0, %edx
|
2008-07-31 08:23:32 +02:00
|
|
|
je L_CopyDone
|
2007-10-07 01:23:13 +02:00
|
|
|
leal -1(%esi, %edx), %eax # eax <- End of Source
|
2008-07-31 08:23:32 +02:00
|
|
|
cmpl %edi, %esi
|
|
|
|
jae L_CopyBytes
|
|
|
|
cmpl %edi, %eax
|
|
|
|
jb L_CopyBytes # Copy backward if overlapped
|
|
|
|
movl %eax, %esi # esi <- End of Source
|
2007-10-07 01:23:13 +02:00
|
|
|
leal -1(%edi, %edx), %edi # edi <- End of Destination
|
2008-07-31 08:23:32 +02:00
|
|
|
std
|
|
|
|
L_CopyBytes:
|
|
|
|
movl %edx, %ecx
|
2007-10-07 01:23:13 +02:00
|
|
|
rep
|
|
|
|
movsb # Copy bytes backward
|
|
|
|
cld
|
2008-07-31 08:23:32 +02:00
|
|
|
L_CopyDone:
|
2007-10-07 01:23:13 +02:00
|
|
|
movl 12(%esp), %eax # eax <- Destination as return value
|
|
|
|
pop %edi
|
|
|
|
pop %esi
|
|
|
|
ret
|