2008-11-03 10:25:10 +01:00
|
|
|
#
|
|
|
|
# ConvertAsm.py: Automatically generated from CopyMem.asm
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
#
|
2018-06-27 15:11:33 +02:00
|
|
|
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
2010-04-23 18:13:53 +02:00
|
|
|
# This program and the accompanying materials
|
2008-11-03 10:25:10 +01:00
|
|
|
# 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
|
2010-06-25 23:56:02 +02:00
|
|
|
# http://opensource.org/licenses/bsd-license.php.
|
2008-11-03 10:25:10 +01:00
|
|
|
#
|
|
|
|
# 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:
|
|
|
|
#
|
|
|
|
# CopyMem.S
|
|
|
|
#
|
|
|
|
# Abstract:
|
|
|
|
#
|
|
|
|
# CopyMem function
|
|
|
|
#
|
|
|
|
# Notes:
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# VOID *
|
|
|
|
# EFIAPI
|
|
|
|
# InternalMemCopyMem (
|
|
|
|
# IN VOID *Destination,
|
|
|
|
# IN VOID *Source,
|
|
|
|
# IN UINTN Count
|
|
|
|
# )
|
2008-10-24 04:50:40 +02:00
|
|
|
#------------------------------------------------------------------------------
|
2009-05-20 12:22:09 +02:00
|
|
|
ASM_GLOBAL ASM_PFX(InternalMemCopyMem)
|
2008-10-24 04:50:40 +02:00
|
|
|
ASM_PFX(InternalMemCopyMem):
|
2009-08-11 17:32:16 +02:00
|
|
|
pushq %rsi
|
|
|
|
pushq %rdi
|
|
|
|
movq %rdx, %rsi # rsi <- Source
|
|
|
|
movq %rcx, %rdi # rdi <- Destination
|
2018-06-27 15:11:33 +02:00
|
|
|
leaq -1(%rsi,%r8,), %r9 # r9 <- Last byte of Source
|
2009-08-11 17:32:16 +02:00
|
|
|
cmpq %rdi, %rsi
|
|
|
|
movq %rdi, %rax # rax <- Destination as return value
|
2008-10-24 04:50:40 +02:00
|
|
|
jae L0 # Copy forward if Source > Destination
|
2009-08-11 17:32:16 +02:00
|
|
|
cmpq %rdi, %r9 # Overlapped?
|
|
|
|
jae L_CopyBackward # Copy backward if overlapped
|
2008-10-24 04:50:40 +02:00
|
|
|
L0:
|
2009-08-11 17:32:16 +02:00
|
|
|
xorq %rcx, %rcx
|
|
|
|
subq %rdi, %rcx # rcx <- -rdi
|
|
|
|
andq $15, %rcx # rcx + rsi should be 16 bytes aligned
|
2008-10-24 04:50:40 +02:00
|
|
|
jz L1 # skip if rcx == 0
|
2009-08-11 17:32:16 +02:00
|
|
|
cmpq %r8, %rcx
|
|
|
|
cmova %r8, %rcx
|
|
|
|
subq %rcx, %r8
|
2008-10-24 04:50:40 +02:00
|
|
|
rep movsb
|
|
|
|
L1:
|
2009-08-11 17:32:16 +02:00
|
|
|
movq %r8, %rcx
|
|
|
|
andq $15, %r8
|
|
|
|
shrq $4, %rcx # rcx <- # of DQwords to copy
|
2008-10-24 04:50:40 +02:00
|
|
|
jz L_CopyBytes
|
2009-08-11 17:32:16 +02:00
|
|
|
movdqu %xmm0, 0x18(%rsp) # save xmm0 on stack
|
2008-10-24 04:50:40 +02:00
|
|
|
L2:
|
2009-08-11 17:32:16 +02:00
|
|
|
movdqu (%rsi), %xmm0 # rsi may not be 16-byte aligned
|
|
|
|
movntdq %xmm0, (%rdi) # rdi should be 16-byte aligned
|
|
|
|
addq $16, %rsi
|
|
|
|
addq $16, %rdi
|
2008-10-24 04:50:40 +02:00
|
|
|
loop L2
|
|
|
|
mfence
|
2009-08-11 17:32:16 +02:00
|
|
|
movdqa 0x18(%rsp), %xmm0 # restore xmm0
|
2008-10-24 04:50:40 +02:00
|
|
|
jmp L_CopyBytes # copy remaining bytes
|
|
|
|
L_CopyBackward:
|
2009-08-11 17:32:16 +02:00
|
|
|
movq %r9, %rsi # rsi <- Last byte of Source
|
|
|
|
leaq -1(%rdi, %r8,), %rdi # rdi <- Last byte of Destination
|
2008-10-24 04:50:40 +02:00
|
|
|
std
|
|
|
|
L_CopyBytes:
|
2009-08-11 17:32:16 +02:00
|
|
|
movq %r8, %rcx
|
2008-10-24 04:50:40 +02:00
|
|
|
rep movsb
|
|
|
|
cld
|
2009-08-11 17:32:16 +02:00
|
|
|
popq %rdi
|
|
|
|
popq %rsi
|
2008-10-24 04:50:40 +02:00
|
|
|
ret
|