]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibMmx/Ia32/CopyMem.asm
1. Updated function headers for all assembly function
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibMmx / Ia32 / CopyMem.asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2006, Intel Corporation
4 ; All rights reserved. This program and the accompanying materials
5 ; are licensed and made available under the terms and conditions of the BSD License
6 ; which accompanies this distribution. The full text of the license may be found at
7 ; http://opensource.org/licenses/bsd-license.php
8 ;
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 ;
12 ; Module Name:
13 ;
14 ; CopyMem.asm
15 ;
16 ; Abstract:
17 ;
18 ; CopyMem function
19 ;
20 ; Notes:
21 ;
22 ;------------------------------------------------------------------------------
23
24 .686
25 .model flat,C
26 .mmx
27 .code
28
29 ;------------------------------------------------------------------------------
30 ; VOID *
31 ; EFIAPI
32 ; InternalMemCopyMem (
33 ; IN VOID *Destination,
34 ; IN VOID *Source,
35 ; IN UINTN Count
36 ; );
37 ;------------------------------------------------------------------------------
38 InternalMemCopyMem PROC USES esi edi
39 mov esi, [esp + 16] ; esi <- Source
40 mov edi, [esp + 12] ; edi <- Destination
41 mov edx, [esp + 20] ; edx <- Count
42 lea eax, [esi + edx - 1] ; eax <- End of Source
43 cmp esi, edi
44 jae @F
45 cmp eax, edi ; Overlapped?
46 jae @CopyBackward ; Copy backward if overlapped
47 @@:
48 mov ecx, edx
49 and edx, 7
50 shr ecx, 3 ; ecx <- # of Qwords to copy
51 jz @CopyBytes
52 push eax
53 push eax
54 movq [esp], mm0 ; save mm0
55 @@:
56 movq mm0, [esi]
57 movq [edi], mm0
58 add esi, 8
59 add edi, 8
60 loop @B
61 movq mm0, [esp] ; restore mm0
62 pop ecx ; stack cleanup
63 pop ecx ; stack cleanup
64 jmp @CopyBytes
65 @CopyBackward:
66 mov esi, eax ; esi <- Last byte in Source
67 lea edi, [edi + edx - 1] ; edi <- Last byte in Destination
68 std
69 @CopyBytes:
70 mov ecx, edx
71 rep movsb
72 cld
73 mov eax, [esp + 12]
74 ret
75 InternalMemCopyMem ENDP
76
77 END