]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/CompilerStub/X64/memcpySSE2.asm
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / CompilerStub / X64 / memcpySSE2.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; memcpy function\r
19;\r
20; Notes:\r
21;\r
22;------------------------------------------------------------------------------\r
23\r
24 .code\r
25\r
26;------------------------------------------------------------------------------\r
27; VOID *\r
28; memcpy (\r
29; OUT VOID *DestinationBuffer,\r
30; IN CONST VOID *SourceBuffer,\r
31; IN UINTN Length\r
32; );\r
33;------------------------------------------------------------------------------\r
34memcpy PROC USES rsi rdi\r
35 mov rax, rcx ; rax <- Destination as return value\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 <- Last byte of Source\r
43 cmp rsi, rdi\r
44 jae @F ; Copy forward if Source > Destination\r
45 cmp r9, rdi ; Overlapped?\r
46 jae @CopyBackward ; Copy backward if overlapped\r
47@@:\r
48 xor rcx, rcx\r
49 sub rcx, rdi ; rcx <- -rdi\r
50 and rcx, 15 ; rcx + rsi should be 16 bytes aligned\r
51 jz @F ; skip if rcx == 0\r
52 cmp rcx, r8\r
53 cmova rcx, r8\r
54 sub r8, rcx\r
55 rep movsb\r
56@@:\r
57 mov rcx, r8\r
58 and r8, 15\r
59 shr rcx, 4 ; rcx <- # of DQwords to copy\r
60 jz @CopyBytes\r
61@@:\r
62 movdqu xmm0, [rsi] ; rsi may not be 16-byte aligned\r
63 movdqa [rdi], xmm0 ; rdi should be 16-byte aligned\r
64 add rsi, 16\r
65 add rdi, 16\r
66 loop @B\r
67 jmp @CopyBytes ; copy remaining bytes\r
68@CopyBackward:\r
69 mov rsi, r9 ; rsi <- Last byte of Source\r
70 lea rdi, [rdi + r8 - 1] ; rdi <- Last byte of Destination\r
71 std\r
72@CopyBytes:\r
73 mov rcx, r8\r
74 rep movsb\r
75 cld\r
76@CopyMemDone: \r
77 ret\r
78memcpy ENDP\r
79\r
80 END\r