]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/X64/EfiCopyMem.asm
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / X64 / EfiCopyMem.asm
CommitLineData
3eb9473e 1;------------------------------------------------------------------------------\r
2;\r
4ea9375a
HT
3; Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
4; This program and the accompanying materials\r
3eb9473e 5; are licensed and made available under the terms and conditions of the BSD License\r
6; which accompanies this distribution. The full text of the license may be found at\r
7; http://opensource.org/licenses/bsd-license.php\r
8;\r
9; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11;\r
12; Module Name:\r
13;\r
14; CopyMem.asm\r
15;\r
16; Abstract:\r
17;\r
18; CopyMem function\r
19;\r
20; Notes:\r
21;\r
22;------------------------------------------------------------------------------\r
23\r
24 .code\r
25\r
26;------------------------------------------------------------------------------\r
27; VOID *\r
28; EFIAPI\r
29; EfiCommonLibCopyMem (\r
30; OUT VOID *Destination,\r
31; IN VOID *Source,\r
32; IN UINTN Count\r
33; );\r
34;------------------------------------------------------------------------------\r
35EfiCommonLibCopyMem PROC USES rsi rdi\r
36 cmp rdx, rcx ; if Source == Destination, do nothing\r
37 je @CopyMemDone\r
38 cmp r8, 0 ; if Count == 0, do nothing\r
39 je @CopyMemDone\r
40 mov rsi, rdx ; rsi <- Source\r
41 mov rdi, rcx ; rdi <- Destination\r
42 lea r9, [rsi + r8 - 1] ; r9 <- End of Source\r
43 cmp rsi, rdi\r
44 mov rax, rdi ; rax <- Destination as return value\r
45 jae @F\r
46 cmp r9, rdi\r
47 jae @CopyBackward ; Copy backward if overlapped\r
48@@:\r
49 mov rcx, r8\r
50 and r8, 7\r
51 shr rcx, 3 ; rcx <- # of Qwords to copy\r
52 jz @CopyBytes\r
53 DB 49h, 0fh, 7eh, 0c2h ; movd r10, mm0 (Save mm0 in r10)\r
54@@:\r
55 DB 0fh, 6fh, 06h ; movd mm0, [rsi]\r
56 DB 48h, 0fh, 7eh, 07h ; movd [rdi], mm0\r
57 add rsi, 8\r
58 add rdi, 8\r
59 loop @B\r
60 DB 49h, 0fh, 6eh, 0c2h ; movd mm0, r10 (Restore mm0)\r
61 jmp @CopyBytes\r
62@CopyBackward:\r
63 mov rsi, r9 ; rsi <- End of Source\r
64 lea rdi, [rdi + r8 - 1] ; rdi <- End of Destination\r
65 std ; set direction flag\r
66@CopyBytes:\r
67 mov rcx, r8\r
68 rep movsb ; Copy bytes backward\r
69 cld\r
70@CopyMemDone: \r
71 ret\r
72EfiCommonLibCopyMem ENDP\r
73\r
74 END\r