]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm
Import some basic libraries instances for Mde Packages.
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibRepStr / Ia32 / CopyMem.asm
1 //
2 // Include common header file for this module.
3 //
4 #include "CommonHeader.h"
5
6 ;------------------------------------------------------------------------------
7 ;
8 ; Copyright (c) 2006, Intel Corporation
9 ; All rights reserved. This program and the accompanying materials
10 ; are licensed and made available under the terms and conditions of the BSD License
11 ; which accompanies this distribution. The full text of the license may be found at
12 ; http://opensource.org/licenses/bsd-license.php
13 ;
14 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 ;
17 ; Module Name:
18 ;
19 ; CopyMem.Asm
20 ;
21 ; Abstract:
22 ;
23 ; CopyMem function
24 ;
25 ; Notes:
26 ;
27 ;------------------------------------------------------------------------------
28
29 .386
30 .model flat,C
31 .code
32
33 ;------------------------------------------------------------------------------
34 ; VOID *
35 ; InternalMemCopyMem (
36 ; IN VOID *Destination,
37 ; IN VOID *Source,
38 ; IN UINTN Count
39 ; )
40 ;------------------------------------------------------------------------------
41 InternalMemCopyMem PROC USES esi edi
42 mov esi, [esp + 16] ; esi <- Source
43 mov edi, [esp + 12] ; edi <- Destination
44 mov edx, [esp + 20] ; edx <- Count
45 lea eax, [esi + edx - 1] ; eax <- End of Source
46 cmp esi, edi
47 jae @F
48 cmp eax, edi
49 jae @CopyBackward ; Copy backward if overlapped
50 @@:
51 mov ecx, edx
52 and edx, 3
53 shr ecx, 2
54 rep movsd ; Copy as many Dwords as possible
55 jmp @CopyBytes
56 @CopyBackward:
57 mov esi, eax ; esi <- End of Source
58 lea edi, [edi + edx - 1] ; edi <- End of Destination
59 std
60 @CopyBytes:
61 mov ecx, edx
62 rep movsb ; Copy bytes backward
63 cld
64 mov eax, [esp + 12] ; eax <- Destination as return value
65 ret
66 InternalMemCopyMem ENDP
67
68 END