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
@ -41,34 +40,43 @@ ASM_PFX(InternalMemCopyMem):
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
cmova rcx, r8
sub r8, rcx
rep movsb
L1: L1:
movq mm0, [rsi] mov rcx, r8
movntq [rdi], mm0 and r8, 15
add rsi, 8 shr rcx, 4 # rcx <- # of DQwords to copy
add rdi, 8 jz L_CopyBytes
loop L1 movdqa [rsp + 0x18], xmm0 # save xmm0 on stack
L2:
movdqu xmm0, [rsi] # rsi may not be 16-byte aligned
movntdq [rdi], xmm0 # rdi should be 16-byte aligned
add rsi, 16
add rdi, 16
loop L2
mfence mfence
movd mm0, r10 # (Restore mm0) movdqa xmm0, [rsp + 0x18] # restore xmm0
jmp L_CopyBytes jmp L_CopyBytes # copy remaining bytes
L_CopyBackward: L_CopyBackward:
mov rsi, r9 # rsi <- End of Source mov rsi, r9 # rsi <- Last byte of Source
lea rdi, [rdi + r8 - 1] # rdi <- End of Destination lea rdi, [rdi + r8 - 1] # rdi <- Last byte of Destination
std # set direction flag std
L_CopyBytes: L_CopyBytes:
mov rcx, r8 mov rcx, r8
rep movsb # Copy bytes backward rep movsb
cld cld
pop rdi pop rdi
pop rsi pop rsi

View File

@ -42,8 +42,9 @@ ASM_PFX(InternalMemZeroMem):
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