]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptPei/Ia32/CopyMem.asm
ArmPkg/ArmDisassemblerLib: fix check for MSR instruction
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptPei / Ia32 / CopyMem.asm
CommitLineData
7b3b4b29 1;------------------------------------------------------------------------------\r
2;\r
84b5877f
HT
3; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
4; This program and the accompanying materials\r
7b3b4b29 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
2fc59a00 7; http://opensource.org/licenses/bsd-license.php.\r
7b3b4b29 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 .386\r
25 .model flat,C\r
26 .code\r
27\r
28;------------------------------------------------------------------------------\r
29; VOID *\r
30; InternalMemCopyMem (\r
31; IN VOID *Destination,\r
32; IN VOID *Source,\r
33; IN UINTN Count\r
34; )\r
35;------------------------------------------------------------------------------\r
36InternalMemCopyMem PROC USES esi edi\r
37 mov esi, [esp+16] ; esi <- Source\r
38 mov edi, [esp+12] ; edi <- Destination\r
39 mov edx, [esp+20] ; edx <- Count\r
40 cmp esi, edi\r
41 je @CopyDone\r
42 cmp edx, 0\r
43 je @CopyDone\r
44 lea eax, [esi + edx - 1] ; eax <- End of Source\r
45 cmp esi, edi\r
46 jae @CopyBytes\r
47 cmp eax, edi\r
48 jb @CopyBytes ; Copy backward if overlapped\r
49 mov esi, eax ; esi <- End of Source\r
50 lea edi, [edi + edx - 1] ; edi <- End of Destination\r
51 std\r
52@CopyBytes:\r
53 mov ecx, edx\r
54 rep movsb ; Copy bytes backward\r
55 cld\r
56@CopyDone:\r
57 mov eax, [esp + 12] ; eax <- Destination as return value\r
58 ret\r
59InternalMemCopyMem ENDP\r
60\r
61 END\r