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    SECTION .text
19
20;------------------------------------------------------------------------------
21;  VOID *
22;  EFIAPI
23;  InternalMemSetMem32 (
24;    IN VOID   *Buffer,
25;    IN UINTN  Count,
26;    IN UINT32 Value
27;    );
28;------------------------------------------------------------------------------
29global ASM_PFX(InternalMemSetMem32)
30ASM_PFX(InternalMemSetMem32):
31    mov     eax, [esp + 4]              ; eax <- Buffer as return value
32    mov     ecx, [esp + 8]              ; ecx <- Count
33    movd    mm0, dword [esp + 12]             ; mm0 <- Value
34    shr     ecx, 1                      ; ecx <- number of qwords to set
35    mov     edx, eax                    ; edx <- Buffer
36    jz      @SetDwords
37    movq    mm1, mm0
38    psllq   mm1, 32
39    por     mm0, mm1
40.0:
41    movq    qword [edx], mm0
42    lea     edx, [edx + 8]              ; use "lea" to avoid change in flags
43    loop    .0
44@SetDwords:
45    jnc     .1
46    movd    dword [edx], mm0
47.1:
48    ret
49
50