]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibSse2/Ia32/CopyMem.asm
Removed CommonHeader.h generated file from the MdePkg.
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / Ia32 / CopyMem.asm
CommitLineData
e1f414b6 1//\r
2// Include common header file for this module.\r
3//\r
f734a10a 4\r
e1f414b6 5\r
6;------------------------------------------------------------------------------\r
7;\r
8; Copyright (c) 2006, Intel Corporation\r
9; All rights reserved. This program and the accompanying materials\r
10; are licensed and made available under the terms and conditions of the BSD License\r
11; which accompanies this distribution. The full text of the license may be found at\r
12; http://opensource.org/licenses/bsd-license.php\r
13;\r
14; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
15; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
16;\r
17; Module Name:\r
18;\r
19; CopyMem.asm\r
20;\r
21; Abstract:\r
22;\r
23; CopyMem function\r
24;\r
25; Notes:\r
26;\r
27;------------------------------------------------------------------------------\r
28\r
29 .686\r
30 .model flat,C\r
31 .xmm\r
32 .code\r
33\r
34;------------------------------------------------------------------------------\r
35; VOID *\r
36; InternalMemCopyMem (\r
37; IN VOID *Destination,\r
38; IN VOID *Source,\r
39; IN UINTN Count\r
40; );\r
41;------------------------------------------------------------------------------\r
42InternalMemCopyMem PROC USES esi edi\r
43 mov esi, [esp + 16] ; esi <- Source\r
44 mov edi, [esp + 12] ; edi <- Destination\r
45 mov edx, [esp + 20] ; edx <- Count\r
46 lea eax, [esi + edx - 1] ; eax <- End of Source\r
47 cmp esi, edi\r
48 jae @F\r
49 cmp eax, edi ; Overlapped?\r
50 jae @CopyBackward ; Copy backward if overlapped\r
51@@:\r
52 xor ecx, ecx\r
53 sub ecx, edi\r
54 and ecx, 15 ; ecx + edi aligns on 16-byte boundary\r
55 jz @F\r
56 cmp ecx, edx\r
57 cmova ecx, edx\r
58 sub edx, ecx ; edx <- remaining bytes to copy\r
59 rep movsb\r
60@@:\r
61 mov ecx, edx\r
62 and edx, 15\r
63 shr ecx, 4 ; ecx <- # of DQwords to copy\r
64 jz @CopyBytes\r
65 add esp, -16\r
66 movdqu [esp], xmm0 ; save xmm0\r
67@@:\r
68 movdqu xmm0, [esi] ; esi may not be 16-bytes aligned\r
69 movntdq [edi], xmm0 ; edi should be 16-bytes aligned\r
70 add esi, 16\r
71 add edi, 16\r
72 loop @B\r
73 mfence\r
74 movdqu xmm0, [esp] ; restore xmm0\r
75 add esp, 16 ; stack cleanup\r
76 jmp @CopyBytes\r
77@CopyBackward:\r
78 mov esi, eax ; esi <- Last byte in Source\r
79 lea edi, [edi + edx - 1] ; edi <- Last byte in Destination\r
80 std\r
81@CopyBytes:\r
82 mov ecx, edx\r
83 rep movsb\r
84 cld\r
85 mov eax, [esp + 12] ; eax <- Destination as return value\r
86 ret\r
87InternalMemCopyMem ENDP\r
88\r
89 END\r