synchronize asm and s file

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6204 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
eric_tian 2008-10-24 02:50:40 +00:00
parent 2fb8d3e2df
commit 2f3d6fb515
2 changed files with 52 additions and 43 deletions

View File

@ -24,7 +24,6 @@
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# VOID * # VOID *
# EFIAPI # EFIAPI
@ -33,43 +32,52 @@
# IN VOID *Source, # IN VOID *Source,
# IN UINTN Count # IN UINTN Count
# ) # )
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
.intel_syntax noprefix .intel_syntax noprefix
.globl ASM_PFX(InternalMemCopyMem) .globl ASM_PFX(InternalMemCopyMem)
ASM_PFX(InternalMemCopyMem): ASM_PFX(InternalMemCopyMem):
push rsi push rsi
push rdi push rdi
mov rsi, rdx # rsi <- Source mov rsi, rdx # rsi <- Source
mov rdi, rcx # rdi <- Destination mov rdi, rcx # rdi <- Destination
lea r9, [rsi + r8 - 1] # r9 <- End of Source lea r9, [rsi + r8 - 1] # r9 <- Last byte of Source
cmp rsi, rdi cmp rsi, rdi
mov rax, rdi # rax <- Destination as return value mov rax, rdi # rax <- Destination as return value
jae L0 jae L0 # Copy forward if Source > Destination
cmp r9, rdi cmp r9, rdi # Overlapped?
jae L_CopyBackward # Copy backward if overlapped jae @CopyBackward # Copy backward if overlapped
L0: L0:
mov rcx, r8 xor rcx, rcx
and r8, 7 sub rcx, rdi # rcx <- -rdi
shr rcx, 3 # rcx <- # of Qwords to copy and rcx, 15 # rcx + rsi should be 16 bytes aligned
jz L_CopyBytes jz L1 # skip if rcx == 0
movd r10, mm0 # (Save mm0 in r10) cmp rcx, r8
L1: cmova rcx, r8
movq mm0, [rsi] sub r8, rcx
movntq [rdi], mm0 rep movsb
add rsi, 8 L1:
add rdi, 8 mov rcx, r8
loop L1 and r8, 15
mfence shr rcx, 4 # rcx <- # of DQwords to copy
movd mm0, r10 # (Restore mm0) jz L_CopyBytes
jmp L_CopyBytes movdqa [rsp + 0x18], xmm0 # save xmm0 on stack
L_CopyBackward: L2:
mov rsi, r9 # rsi <- End of Source movdqu xmm0, [rsi] # rsi may not be 16-byte aligned
lea rdi, [rdi + r8 - 1] # rdi <- End of Destination movntdq [rdi], xmm0 # rdi should be 16-byte aligned
std # set direction flag add rsi, 16
L_CopyBytes: add rdi, 16
mov rcx, r8 loop L2
rep movsb # Copy bytes backward mfence
cld movdqa xmm0, [rsp + 0x18] # restore xmm0
pop rdi jmp L_CopyBytes # copy remaining bytes
pop rsi L_CopyBackward:
ret mov rsi, r9 # rsi <- Last byte of Source
lea rdi, [rdi + r8 - 1] # rdi <- Last byte of Destination
std
L_CopyBytes:
mov rcx, r8
rep movsb
cld
pop rdi
pop rsi
ret

View File

@ -41,9 +41,10 @@ ASM_PFX(InternalMemZeroMem):
mov rdi, rcx mov rdi, rcx
mov rcx, rdx mov rcx, rdx
shr rcx, 3 shr rcx, 3
and rdx, 7 and rdx, 7
cld
rep stosq rep stosq
mov ecx, edx mov rcx, rdx
rep stosb rep stosb
pop rax pop rax
pop rdi pop rdi