• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1;------------------------------------------------------------------------------
2;
3; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4; 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;   SetMem32.nasm
15;
16; Abstract:
17;
18;   SetMem32 function
19;
20; Notes:
21;
22;------------------------------------------------------------------------------
23
24    DEFAULT REL
25    SECTION .text
26
27;------------------------------------------------------------------------------
28;  VOID *
29;  InternalMemSetMem32 (
30;    IN VOID   *Buffer,
31;    IN UINTN  Count,
32;    IN UINT32 Value
33;    )
34;------------------------------------------------------------------------------
35global ASM_PFX(InternalMemSetMem32)
36ASM_PFX(InternalMemSetMem32):
37    DB      0x49, 0xf, 0x6e, 0xc0         ; movd mm0, r8 (Value)
38    mov     rax, rcx                    ; rax <- Buffer
39    xchg    rcx, rdx                    ; rcx <- Count  rdx <- Buffer
40    shr     rcx, 1                      ; rcx <- # of qwords to set
41    jz      @SetDwords
42    DB      0xf, 0x70, 0xC0, 0x44         ; pshufw mm0, mm0, 44h
43.0:
44    DB      0xf, 0xe7, 0x2              ; movntq [rdx], mm0
45    lea     rdx, [rdx + 8]              ; use "lea" to avoid flag changes
46    loop    .0
47    mfence
48@SetDwords:
49    jnc     .1
50    DB      0xf, 0x7e, 0x2               ; movd [rdx], mm0
51.1:
52    ret
53
54