2 // Include common header file for this module.
6 ;------------------------------------------------------------------------------
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
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.
27 ;------------------------------------------------------------------------------
34 ;------------------------------------------------------------------------------
36 ; InternalMemCopyMem (
37 ; IN VOID *Destination,
41 ;------------------------------------------------------------------------------
42 InternalMemCopyMem PROC USES esi edi
43 mov esi, [esp + 16] ; esi <- Source
44 mov edi, [esp + 12] ; edi <- Destination
45 mov edx, [esp + 20] ; edx <- Count
46 lea eax, [esi + edx - 1] ; eax <- End of Source
49 cmp eax, edi ; Overlapped?
50 jae @CopyBackward ; Copy backward if overlapped
54 and ecx, 15 ; ecx + edi aligns on 16-byte boundary
58 sub edx, ecx ; edx <- remaining bytes to copy
63 shr ecx, 4 ; ecx <- # of DQwords to copy
66 movdqu [esp], xmm0 ; save xmm0
68 movdqu xmm0, [esi] ; esi may not be 16-bytes aligned
69 movntdq [edi], xmm0 ; edi should be 16-bytes aligned
74 movdqu xmm0, [esp] ; restore xmm0
75 add esp, 16 ; stack cleanup
78 mov esi, eax ; esi <- Last byte in Source
79 lea edi, [edi + edx - 1] ; edi <- Last byte in Destination
85 mov eax, [esp + 12] ; eax <- Destination as return value
87 InternalMemCopyMem ENDP