• 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;   SetMem.nasm
15;
16; Abstract:
17;
18;   SetMem function
19;
20; Notes:
21;
22;------------------------------------------------------------------------------
23
24    DEFAULT REL
25    SECTION .text
26
27;------------------------------------------------------------------------------
28; VOID *
29; EFIAPI
30; InternalMemSetMem (
31;   OUT     VOID                      *Buffer,
32;   IN      UINTN                     Length,
33;   IN      UINT8                     Value
34;   );
35;------------------------------------------------------------------------------
36global ASM_PFX(InternalMemSetMem)
37ASM_PFX(InternalMemSetMem):
38    push    rdi
39    mov     rax, r8
40    mov     ah, al
41    DB      0x48, 0xf, 0x6e, 0xc0         ; movd mm0, rax
42    mov     r8, rcx
43    mov     rdi, r8                     ; rdi <- Buffer
44    mov     rcx, rdx
45    and     edx, 7
46    shr     rcx, 3
47    jz      @SetBytes
48    DB      0xf, 0x70, 0xC0, 0x0         ; pshufw mm0, mm0, 0h
49.0:
50    DB      0xf, 0xe7, 0x7              ; movntq [rdi], mm0
51    add     rdi, 8
52    loop    .0
53    mfence
54@SetBytes:
55    mov     ecx, edx
56    rep     stosb
57    mov     rax, r8
58    pop     rdi
59    ret
60
61