1. Updated function headers for all assembly function

2. Optimized register usage in SetMemXX functions in all lib instances
3. Fixed a logical error in CopyMem for all lib instances


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1139 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
bxing
2006-07-28 07:28:19 +00:00
parent 27169a56e6
commit eb227e96bd
106 changed files with 1006 additions and 457 deletions

View File

@@ -23,42 +23,42 @@
.code
;------------------------------------------------------------------------------
; VOID *
; EFIAPI
; InternalMemCopyMem (
; OUT VOID *DestinationBuffer,
; IN CONST VOID *SourceBuffer,
; IN UINTN Length
; );
;------------------------------------------------------------------------------
InternalMemCopyMem PROC USES rsi rdi
mov rsi, rdx ; rsi <- Source
mov rdi, rcx ; rdi <- Destination
lea r9, [rdi + r8 - 1] ; r9 <- End of Destination
lea r9, [rsi + r8 - 1] ; r9 <- End of Source
cmp rsi, rdi
mov rax, rdi ; rax <- Destination as return value
jae @F
cmp r9, rsi
cmp r9, rdi
jae @CopyBackward ; Copy backward if overlapped
@@:
xor rcx, rcx
sub rcx, rsi
and rcx, 7 ; rcx + rsi aligns on 8-byte boundary
jz @F
cmp rcx, r8
cmova rcx, r8
sub r8, rcx ; r8 <- remaining bytes to copy
rep movsb
@@:
mov rcx, r8
and r8, 7
shr rcx, 3 ; rcx <- # of Qwords to copy
jz @CopyBytes
DB 49h, 0fh, 7eh, 0c2h ; movq r10, mm0 ; save mm0
DB 49h, 0fh, 7eh, 0c2h ; movd r10, mm0 (Save mm0 in r10)
@@:
DB 48h, 0fh, 6fh, 06h ; movq mm0, [rsi]
DB 48h, 0fh, 0e7h, 07h ; movntq [rdi], mm0
DB 0fh, 6fh, 06h ; movd mm0, [rsi]
DB 0fh, 0e7h, 07h ; movntq [rdi], mm0
add rsi, 8
add rdi, 8
loop @B
mfence
DB 49h, 0fh, 6eh, 0c2h ; movq mm0, r10 ; restore mm0
DB 49h, 0fh, 6eh, 0c2h ; movd mm0, r10 (Restore mm0)
jmp @CopyBytes
@CopyBackward:
mov rdi, r9 ; rdi <- End of Destination
lea rsi, [rsi + r8 - 1] ; rsi <- End of Source
mov rsi, r9 ; rsi <- End of Source
lea rdi, [rdi + r8 - 1] ; rdi <- End of Destination
std ; set direction flag
@CopyBytes:
mov rcx, r8