]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibMmx/X64/SetMem32.nasm
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibMmx / X64 / SetMem32.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 ; SetMem32.nasm
9 ;
10 ; Abstract:
11 ;
12 ; SetMem32 function
13 ;
14 ; Notes:
15 ;
16 ;------------------------------------------------------------------------------
17
18 DEFAULT REL
19 SECTION .text
20
21 ;------------------------------------------------------------------------------
22 ; VOID *
23 ; InternalMemSetMem32 (
24 ; IN VOID *Buffer,
25 ; IN UINTN Count,
26 ; IN UINT32 Value
27 ; )
28 ;------------------------------------------------------------------------------
29 global ASM_PFX(InternalMemSetMem32)
30 ASM_PFX(InternalMemSetMem32):
31 DB 0x49, 0xf, 0x6e, 0xc0 ; movd mm0, r8 (Value)
32 mov rax, rcx ; rax <- Buffer
33 xchg rcx, rdx ; rcx <- Count rdx <- Buffer
34 shr rcx, 1 ; rcx <- # of qwords to set
35 jz @SetDwords
36 DB 0xf, 0x70, 0xC0, 0x44 ; pshufw mm0, mm0, 44h
37 .0:
38 DB 0xf, 0xe7, 0x2 ; movntq [rdx], mm0
39 lea rdx, [rdx + 8] ; use "lea" to avoid flag changes
40 loop .0
41 mfence
42 @SetDwords:
43 jnc .1
44 DB 0xf, 0x7e, 0x2 ; movd [rdx], mm0
45 .1:
46 ret
47