]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memcpy.asm
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / CompilerStub / Ia32 / memcpy.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 .686\r
25 .model flat,C\r
26 .mmx\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 mov ecx, edx\r
52 and edx, 7\r
53 shr ecx, 3 ; ecx <- # of Qwords to copy\r
54 jz @CopyBytes\r
55 push eax\r
56 push eax\r
57 movq [esp], mm0 ; save mm0\r
58@@:\r
59 movq mm0, [esi]\r
60 movq [edi], mm0\r
61 add esi, 8\r
62 add edi, 8\r
63 loop @B\r
64 movq mm0, [esp] ; restore mm0\r
65 pop ecx ; stack cleanup\r
66 pop ecx ; stack cleanup\r
67 jmp @CopyBytes\r
68@CopyBackward:\r
69 mov esi, eax ; esi <- Last byte in Source\r
70 lea edi, [edi + edx - 1] ; edi <- Last byte in Destination\r
71 std\r
72@CopyBytes:\r
73 mov ecx, edx\r
74 rep movsb\r
75 cld\r
76@CopyMemDone: \r
77 mov eax, [esp + 12]\r
78 ret\r
79memcpy ENDP\r
80\r
81 END\r