]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm
Removed CommonHeader.h generated file from the MdePkg.
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibRepStr / 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 .386\r
30 .model flat,C\r
31 .code\r
32\r
33;------------------------------------------------------------------------------\r
34; VOID *\r
35; InternalMemCopyMem (\r
36; IN VOID *Destination,\r
37; IN VOID *Source,\r
38; IN UINTN Count\r
39; )\r
40;------------------------------------------------------------------------------\r
41InternalMemCopyMem PROC USES esi edi\r
42 mov esi, [esp + 16] ; esi <- Source\r
43 mov edi, [esp + 12] ; edi <- Destination\r
44 mov edx, [esp + 20] ; edx <- Count\r
45 lea eax, [esi + edx - 1] ; eax <- End of Source\r
46 cmp esi, edi\r
47 jae @F\r
48 cmp eax, edi\r
49 jae @CopyBackward ; Copy backward if overlapped\r
50@@:\r
51 mov ecx, edx\r
52 and edx, 3\r
53 shr ecx, 2\r
54 rep movsd ; Copy as many Dwords as possible\r
55 jmp @CopyBytes\r
56@CopyBackward:\r
57 mov esi, eax ; esi <- End of Source\r
58 lea edi, [edi + edx - 1] ; edi <- End of Destination\r
59 std\r
60@CopyBytes:\r
61 mov ecx, edx\r
62 rep movsb ; Copy bytes backward\r
63 cld\r
64 mov eax, [esp + 12] ; eax <- Destination as return value\r
65 ret\r
66InternalMemCopyMem ENDP\r
67\r
68 END\r