Renamed remotely

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6016 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2008-09-27 05:27:49 +00:00
parent 01a59a8a54
commit 01f4360447
10 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; CopyMem.asm
;
; Abstract:
;
; memcpy function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID *
; memcpy (
; OUT VOID *DestinationBuffer,
; IN CONST VOID *SourceBuffer,
; IN UINTN Length
; );
;------------------------------------------------------------------------------
memcpy PROC USES rsi rdi
mov rax, rcx ; rax <- Destination as return value
cmp rdx, rcx ; if Source == Destination, do nothing
je @CopyMemDone
cmp r8, 0 ; if Count == 0, do nothing
je @CopyMemDone
mov rsi, rdx ; rsi <- Source
mov rdi, rcx ; rdi <- Destination
lea r9, [rsi + r8 - 1] ; r9 <- End of Source
cmp rsi, rdi
jae @F
cmp r9, rdi
jae @CopyBackward ; Copy backward if overlapped
@@:
mov rcx, r8
and r8, 7
shr rcx, 3 ; rcx <- # of Qwords to copy
jz @CopyBytes
DB 49h, 0fh, 7eh, 0c2h ; movd r10, mm0 (Save mm0 in r10)
@@:
DB 0fh, 6fh, 06h ; movd mm0, [rsi]
DB 48h, 0fh, 7eh, 07h ; movd [rdi], mm0
add rsi, 8
add rdi, 8
loop @B
DB 49h, 0fh, 6eh, 0c2h ; movd mm0, r10 (Restore mm0)
jmp @CopyBytes
@CopyBackward:
mov rsi, r9 ; rsi <- End of Source
lea rdi, [rdi + r8 - 1] ; rdi <- End of Destination
std ; set direction flag
@CopyBytes:
mov rcx, r8
rep movsb ; Copy bytes backward
cld
@CopyMemDone:
ret
memcpy ENDP
END

View File

@@ -0,0 +1,59 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; memcpyRep1.asm
;
; Abstract:
;
; CopyMem function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; memcpy (
; OUT VOID *Destination,
; IN VOID *Source,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
memcpy PROC USES rsi rdi
mov rax, rcx
cmp rdx, rcx ; if Source == Destination, do nothing
je @CopyMemDone
cmp r8, 0 ; if Count == 0, do nothing
je @CopyMemDone
mov rsi, rdx ; rsi <- Source
mov rdi, rcx ; rdi <- Destination
lea r9, [rsi + r8 - 1] ; r9 <- End of Source
cmp rsi, rdi
jae @F
cmp r9, rdi
jb @F ; Copy backward if overlapped
mov rsi, r9 ; rsi <- End of Source
lea rdi, [rdi + r8 - 1] ; esi <- End of Destination
std ; set direction flag
@@:
mov rcx, r8
rep movsb ; Copy bytes backward
cld
@CopyMemDone:
ret
memcpy ENDP
END

View File

@@ -0,0 +1,65 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; memcpyRep8.asm
;
; Abstract:
;
; CopyMem function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; memcpy (
; OUT VOID *Destination,
; IN VOID *Source,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
memcpy PROC USES rsi rdi
mov rax, rcx
cmp rdx, rcx ; if Source == Destination, do nothing
je @CopyMemDone
cmp r8, 0 ; if Count == 0, do nothing
je @CopyMemDone
mov rsi, rdx ; rsi <- Source
mov rdi, rcx ; rdi <- Destination
lea r9, [rsi + r8 - 1] ; r9 <- End of Source
cmp rsi, rdi
jae @F
cmp r9, rdi
jae @CopyBackward ; Copy backward if overlapped
@@:
mov rcx, r8
and r8, 3
shr rcx, 2
rep movsd ; Copy as many Dwords as possible
jmp @CopyBytes
@CopyBackward:
mov rsi, r9 ; rsi <- End of Source
lea rdi, [rdi + r8 - 1] ; esi <- End of Destination
std ; set direction flag
@CopyBytes:
mov rcx, r8
rep movsb ; Copy bytes backward
cld
@CopyMemDone:
ret
memcpy ENDP
END

View File

@@ -0,0 +1,66 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; memcpyRep8.asm
;
; Abstract:
;
; CopyMem function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; memcpy (
; OUT VOID *Destination,
; IN VOID *Source,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
memcpy PROC USES rsi rdi
mov rax, rcx
cmp rdx, rcx ; if Source == Destination, do nothing
je @CopyMemDone
cmp r8, 0 ; if Count == 0, do nothing
je @CopyMemDone
mov rsi, rdx ; rsi <- Source
mov rdi, rcx ; rdi <- Destination
lea r9, [rsi + r8 - 1] ; r9 <- End of Source
cmp rsi, rdi
jae @F
cmp r9, rdi
jae @CopyBackward ; Copy backward if overlapped
@@:
mov rcx, r8
and r8, 7
shr rcx, 3
rep movsq ; Copy as many Qwords as possible
jmp @CopyBytes
@CopyBackward:
mov rsi, r9 ; rsi <- End of Source
lea rdi, [rdi + r8 - 1] ; esi <- End of Destination
std ; set direction flag
@CopyBytes:
mov rcx, r8
rep movsb ; Copy bytes backward
cld
@CopyMemDone:
ret
memcpy ENDP
END

View File

@@ -0,0 +1,80 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; CopyMem.asm
;
; Abstract:
;
; memcpy function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID *
; memcpy (
; OUT VOID *DestinationBuffer,
; IN CONST VOID *SourceBuffer,
; IN UINTN Length
; );
;------------------------------------------------------------------------------
memcpy PROC USES rsi rdi
mov rax, rcx ; rax <- Destination as return value
cmp rdx, rcx ; if Source == Destination, do nothing
je @CopyMemDone
cmp r8, 0 ; if Count == 0, do nothing
je @CopyMemDone
mov rsi, rdx ; rsi <- Source
mov rdi, rcx ; rdi <- Destination
lea r9, [rsi + r8 - 1] ; r9 <- Last byte of Source
cmp rsi, rdi
jae @F ; Copy forward if Source > Destination
cmp r9, rdi ; Overlapped?
jae @CopyBackward ; Copy backward if overlapped
@@:
xor rcx, rcx
sub rcx, rdi ; rcx <- -rdi
and rcx, 15 ; rcx + rsi should be 16 bytes aligned
jz @F ; skip if rcx == 0
cmp rcx, r8
cmova rcx, r8
sub r8, rcx
rep movsb
@@:
mov rcx, r8
and r8, 15
shr rcx, 4 ; rcx <- # of DQwords to copy
jz @CopyBytes
@@:
movdqu xmm0, [rsi] ; rsi may not be 16-byte aligned
movdqa [rdi], xmm0 ; rdi should be 16-byte aligned
add rsi, 16
add rdi, 16
loop @B
jmp @CopyBytes ; copy remaining bytes
@CopyBackward:
mov rsi, r9 ; rsi <- Last byte of Source
lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination
std
@CopyBytes:
mov rcx, r8
rep movsb
cld
@CopyMemDone:
ret
memcpy ENDP
END

View File

@@ -0,0 +1,62 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; SetMem.asm
;
; Abstract:
;
; memset function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID *
; memset (
; OUT VOID *Buffer, --> rcx
; IN UINT8 Value, --> rdx
; IN UINTN Length --> r8
; );
;------------------------------------------------------------------------------
memset PROC USES rdi
mov rax, rcx
cmp r8, 0 ; if Size == 0, do nothing
je @SetDone
mov rax, rdx ; rdx <-> r8
mov rdx, r8 ; rdx <- Length
mov r8, rax ; r8 <- Value
mov ah, al
DB 48h, 0fh, 6eh, 0c0h ; movd mm0, rax
mov r8, rcx
mov rdi, r8 ; rdi <- Buffer
mov rcx, rdx
and edx, 7
shr rcx, 3
jz @SetBytes
DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h
@@:
DB 48h, 0fh, 7eh, 07h ; movd [rdi], mm0
add rdi, 8
loop @B
@SetBytes:
mov ecx, edx
rep stosb
mov rax, r8
@SetDone:
ret
memset ENDP
END

View File

@@ -0,0 +1,48 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; memsetRep1.asm
;
; Abstract:
;
; SetMem function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID *
; memset (
; OUT VOID *Buffer,
; IN UINTN Size,
; IN UINT8 Value
; );
;------------------------------------------------------------------------------
memset PROC USES rdi
cmp rdx, 0 ; if Size == 0, do nothing
mov r9, rcx
je @SetDone
mov rax, r8
mov rdi, rcx
mov rcx, rdx
rep stosb
@SetDone:
mov rax, r9
ret
memset ENDP
END

View File

@@ -0,0 +1,55 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; SetMem.asm
;
; Abstract:
;
; memset function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID *
; memset (
; OUT VOID *Buffer,
; IN UINT8 Value,
; IN UINTN Count
; )
;------------------------------------------------------------------------------
memset PROC USES rdi
cmp r8, 0 ; if Size == 0, do nothing
mov r9, rcx
je @SetDone
mov al, dl
mov ah, al
shrd edx, eax, 16
shld eax, edx, 16
mov rdi, rcx
mov rcx, r8
shr rcx, 2
rep stosd
mov rcx, r8
and rcx, 3
rep stosb
@SetDone:
mov rax, r9
ret
memset ENDP
END

View File

@@ -0,0 +1,60 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; memsetRep8.asm
;
; Abstract:
;
; SetMem function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; memset (
; OUT VOID *Buffer,
; IN UINT8 Value,
; IN UINTN Length
; );
;------------------------------------------------------------------------------
memset PROC USES rdi rbx
cmp r8, 0 ; if Size == 0, do nothing
mov r9, rcx
je @SetDone
mov rax, rdx
mov bl, al
mov bh, bl
mov ax, bx
shl rax, 10h
mov ax, bx
mov ebx, eax
shl rax, 20h
mov eax, ebx
mov rdi, rcx
mov rcx, r8
shr rcx, 3
rep stosq
mov rcx, rdx
and rcx, 7
rep stosb
@SetDone:
mov rax, r9
ret
memset ENDP
END

View File

@@ -0,0 +1,74 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2007, 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:
;
; SetMem.asm
;
; Abstract:
;
; memset function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID *
; memset (
; OUT VOID *Buffer, --> rcx
; IN UINT8 Value, --> rdx
; IN UINTN Length --> r8
; );
;------------------------------------------------------------------------------
memset PROC USES rdi
mov rax, rcx
cmp r8, 0 ; if Size == 0, do nothing
je @SetDone
mov rax, rdx ; rdx <-> r8
mov rdx, r8 ; rdx <- Length
mov r8, rax ; r8 <- Value
mov rdi, rcx ; rdi <- Buffer
mov al, r8b ; al <- Value
mov r9, rdi ; r9 <- Buffer as return value
xor rcx, rcx
sub rcx, rdi
and rcx, 15 ; rcx + rdi aligns on 16-byte boundary
jz @F
cmp rcx, rdx
cmova rcx, rdx
sub rdx, rcx
rep stosb
@@:
mov rcx, rdx
and rdx, 15
shr rcx, 4
jz @SetBytes
mov ah, al ; ax <- Value repeats twice
movd xmm0, eax ; xmm0[0..16] <- Value repeats twice
pshuflw xmm0, xmm0, 0 ; xmm0[0..63] <- Value repeats 8 times
movlhps xmm0, xmm0 ; xmm0 <- Value repeats 16 times
@@:
movdqa [rdi], xmm0 ; rdi should be 16-byte aligned
add rdi, 16
loop @B
@SetBytes:
mov ecx, edx ; high 32 bits of rcx are always zero
rep stosb
mov rax, r9 ; rax <- Return value
@SetDone:
ret
memset ENDP
END