Fix capitalization issues
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / 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 .xmm
27 .code
28
29 ;------------------------------------------------------------------------------
30 ; VOID *
31 ; _mem_CopyMem (
32 ; IN VOID *Destination,
33 ; IN VOID *Source,
34 ; IN UINTN Count
35 ; )
36 ;------------------------------------------------------------------------------
37 InternalMemCopyMem PROC USES esi edi
38 mov esi, [esp + 16] ; esi <- Source
39 mov edi, [esp + 12] ; edi <- Destination
40 mov edx, [esp + 20] ; edx <- Count
41 lea eax, [edi + edx - 1] ; eax <- End of Destination
42 cmp esi, edi
43 jae @F
44 cmp eax, esi ; Overlapped?
45 jae @CopyBackward ; Copy backward if overlapped
46 @@:
47 xor ecx, ecx
48 sub ecx, edi
49 and ecx, 15 ; ecx + edi aligns on 16-byte boundary
50 jz @F
51 cmp ecx, edx
52 cmova ecx, edx
53 sub edx, ecx ; edx <- remaining bytes to copy
54 rep movsb
55 @@:
56 mov ecx, edx
57 and edx, 15
58 shr ecx, 4 ; ecx <- # of DQwords to copy
59 jz @CopyBytes
60 add esp, -16
61 movdqu [esp], xmm0 ; save xmm0
62 @@:
63 movdqu xmm0, [esi] ; esi may not be 16-bytes aligned
64 movntdq [edi], xmm0 ; edi should be 16-bytes aligned
65 add esi, 16
66 add edi, 16
67 loop @B
68 mfence
69 movdqu xmm0, [esp] ; restore xmm0
70 add esp, 16 ; stack cleanup
71 jmp @CopyBytes
72 @CopyBackward:
73 mov edi, eax ; edi <- Last byte in Destination
74 lea esi, [esi + edx - 1] ; esi <- Last byte in Source
75 std
76 @CopyBytes:
77 mov ecx, edx
78 rep movsb
79 cld
80 mov eax, [esp + 12] ; eax <- Destination as return value
81 ret
82 InternalMemCopyMem ENDP
83
84 END