]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibSse2/X64/ZeroMem.nasm
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / X64 / ZeroMem.nasm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
5 ;
6 ; Module Name:
7 ;
8 ; ZeroMem.nasm
9 ;
10 ; Abstract:
11 ;
12 ; ZeroMem function
13 ;
14 ; Notes:
15 ;
16 ;------------------------------------------------------------------------------
17
18 DEFAULT REL
19 SECTION .text
20
21 ;------------------------------------------------------------------------------
22 ; VOID *
23 ; InternalMemZeroMem (
24 ; IN VOID *Buffer,
25 ; IN UINTN Count
26 ; )
27 ;------------------------------------------------------------------------------
28 global ASM_PFX(InternalMemZeroMem)
29 ASM_PFX(InternalMemZeroMem):
30 push rdi
31 mov rdi, rcx
32 xor rcx, rcx
33 xor eax, eax
34 sub rcx, rdi
35 and rcx, 15
36 mov r8, rdi
37 jz .0
38 cmp rcx, rdx
39 cmova rcx, rdx
40 sub rdx, rcx
41 rep stosb
42 .0:
43 mov rcx, rdx
44 and edx, 15
45 shr rcx, 4
46 jz @ZeroBytes
47 pxor xmm0, xmm0
48 .1:
49 movntdq [rdi], xmm0 ; rdi should be 16-byte aligned
50 add rdi, 16
51 loop .1
52 mfence
53 @ZeroBytes:
54 mov ecx, edx
55 rep stosb
56 mov rax, r8
57 pop rdi
58 ret
59