1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
16 ;------------------------------------------------------------------------------
20 ;------------------------------------------------------------------------------
22 ; InternalMemCopyMem (
23 ; IN VOID *Destination,
27 ;------------------------------------------------------------------------------
28 global ASM_PFX(InternalMemCopyMem)
29 ASM_PFX(InternalMemCopyMem):
32 mov esi, [esp + 16] ; esi <- Source
33 mov edi, [esp + 12] ; edi <- Destination
34 mov edx, [esp + 20] ; edx <- Count
35 lea eax, [esi + edx - 1] ; eax <- End of Source
38 cmp eax, edi ; Overlapped?
39 jae @CopyBackward ; Copy backward if overlapped
43 and ecx, 15 ; ecx + edi aligns on 16-byte boundary
47 sub edx, ecx ; edx <- remaining bytes to copy
52 shr ecx, 4 ; ecx <- # of DQwords to copy
55 movdqu [esp], xmm0 ; save xmm0
57 movdqu xmm0, [esi] ; esi may not be 16-bytes aligned
58 movntdq [edi], xmm0 ; edi should be 16-bytes aligned
63 movdqu xmm0, [esp] ; restore xmm0
64 add esp, 16 ; stack cleanup
67 mov esi, eax ; esi <- Last byte in Source
68 lea edi, [edi + edx - 1] ; edi <- Last byte in Destination
74 mov eax, [esp + 12] ; eax <- Destination as return value