]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpySSE2.asm
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / CompilerStub / Ia32 / memcpySSE2.asm
CommitLineData
3eb9473e 1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2007, Intel Corporation\r
4; All rights reserved. This program and the accompanying materials\r
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 .686\r
25 .model flat,C\r
26 .xmm\r
27 .code\r
28\r
29;------------------------------------------------------------------------------\r
30; VOID *\r
31; memcpy (\r
32; IN VOID *Destination,\r
33; IN VOID *Source,\r
34; IN UINTN Count\r
35; );\r
36;------------------------------------------------------------------------------\r
37memcpy PROC USES esi edi\r
38 mov esi, [esp + 16] ; esi <- Source\r
39 mov edi, [esp + 12] ; edi <- Destination\r
40 mov edx, [esp + 20] ; edx <- Count\r
41 lea eax, [esi + edx - 1] ; eax <- End of Source\r
42 cmp esi, edi\r
43 je @CopyMemDone\r
44 cmp edx, 0\r
45 je @CopyMemDone\r
46 cmp esi, edi\r
47 jae @F\r
48 cmp eax, edi ; Overlapped?\r
49 jae @CopyBackward ; Copy backward if overlapped\r
50@@:\r
51 xor ecx, ecx\r
52 sub ecx, edi\r
53 and ecx, 15 ; ecx + edi aligns on 16-byte boundary\r
54 jz @F\r
55 cmp ecx, edx\r
56 cmova ecx, edx\r
57 sub edx, ecx ; edx <- remaining bytes to copy\r
58 rep movsb\r
59@@:\r
60 mov ecx, edx\r
61 and edx, 15\r
62 shr ecx, 4 ; ecx <- # of DQwords to copy\r
63 jz @CopyBytes\r
64 add esp, -16\r
65@@:\r
66 movdqu xmm0, [esi] ; esi may not be 16-bytes aligned\r
67 movdqa [edi], xmm0 ; edi should be 16-bytes aligned\r
68 add esi, 16\r
69 add edi, 16\r
70 loop @B\r
71 add esp, 16 ; stack cleanup\r
72 jmp @CopyBytes\r
73@CopyBackward:\r
74 mov esi, eax ; esi <- Last byte in Source\r
75 lea edi, [edi + edx - 1] ; edi <- Last byte in Destination\r
76 std\r
77@CopyBytes:\r
78 mov ecx, edx\r
79 rep movsb\r
80 cld\r
81@CopyMemDone: \r
82 mov eax, [esp + 12]\r
83 ret\r
84memcpy ENDP\r
85\r
86 END\r