]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptPei/Ia32/CopyMem.nasm
ArmPkg/ArmDisassemblerLib: fix check for MSR instruction
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptPei / Ia32 / CopyMem.nasm
CommitLineData
94774b82
JJ
1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
4; 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 SECTION .text\r
25\r
26;------------------------------------------------------------------------------\r
27; VOID *\r
28; InternalMemCopyMem (\r
29; IN VOID *Destination,\r
30; IN VOID *Source,\r
31; IN UINTN Count\r
32; )\r
33;------------------------------------------------------------------------------\r
34global ASM_PFX(InternalMemCopyMem)\r
35ASM_PFX(InternalMemCopyMem):\r
36 push esi\r
37 push 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 cmp esi, edi\r
42 je @CopyDone\r
43 cmp edx, 0\r
44 je @CopyDone\r
45 lea eax, [esi + edx - 1] ; eax <- End of Source\r
46 cmp esi, edi\r
47 jae @CopyBytes\r
48 cmp eax, edi\r
49 jb @CopyBytes ; Copy backward if overlapped\r
50 mov esi, eax ; esi <- End of Source\r
51 lea edi, [edi + edx - 1] ; edi <- End of Destination\r
52 std\r
53@CopyBytes:\r
54 mov ecx, edx\r
55 rep movsb ; Copy bytes backward\r
56 cld\r
57@CopyDone:\r
58 mov eax, [esp + 12] ; eax <- Destination as return value\r
59 pop edi\r
60 pop esi\r
61 ret\r
62\r