]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.asm
1. Updated function headers for all assembly function
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibMmx / Ia32 / CopyMem.asm
CommitLineData
6e3b8c47 1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2006, 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; CopyMem function\r
19;\r
20; Notes:\r
21;\r
22;------------------------------------------------------------------------------\r
23\r
24 .686\r
25 .model flat,C\r
eb227e96 26 .mmx\r
6e3b8c47 27 .code\r
28\r
29;------------------------------------------------------------------------------\r
30; VOID *\r
eb227e96 31; EFIAPI\r
32; InternalMemCopyMem (\r
6e3b8c47 33; IN VOID *Destination,\r
34; IN VOID *Source,\r
35; IN UINTN Count\r
eb227e96 36; );\r
6e3b8c47 37;------------------------------------------------------------------------------\r
38InternalMemCopyMem PROC USES esi edi\r
39 mov esi, [esp + 16] ; esi <- Source\r
40 mov edi, [esp + 12] ; edi <- Destination\r
41 mov edx, [esp + 20] ; edx <- Count\r
eb227e96 42 lea eax, [esi + edx - 1] ; eax <- End of Source\r
6e3b8c47 43 cmp esi, edi\r
44 jae @F\r
eb227e96 45 cmp eax, edi ; Overlapped?\r
6e3b8c47 46 jae @CopyBackward ; Copy backward if overlapped\r
6e3b8c47 47@@:\r
48 mov ecx, edx\r
49 and edx, 7\r
50 shr ecx, 3 ; ecx <- # of Qwords to copy\r
51 jz @CopyBytes\r
52 push eax\r
53 push eax\r
54 movq [esp], mm0 ; save mm0\r
55@@:\r
56 movq mm0, [esi]\r
eb227e96 57 movq [edi], mm0\r
6e3b8c47 58 add esi, 8\r
59 add edi, 8\r
60 loop @B\r
6e3b8c47 61 movq mm0, [esp] ; restore mm0\r
62 pop ecx ; stack cleanup\r
63 pop ecx ; stack cleanup\r
64 jmp @CopyBytes\r
65@CopyBackward:\r
eb227e96 66 mov esi, eax ; esi <- Last byte in Source\r
67 lea edi, [edi + edx - 1] ; edi <- Last byte in Destination\r
6e3b8c47 68 std\r
69@CopyBytes:\r
70 mov ecx, edx\r
71 rep movsb\r
72 cld\r
73 mov eax, [esp + 12]\r
74 ret\r
75InternalMemCopyMem ENDP\r
76\r
77 END\r