]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.nasm
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibMmx / Ia32 / SetMem.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 ; SetMem.nasm
9 ;
10 ; Abstract:
11 ;
12 ; SetMem function
13 ;
14 ; Notes:
15 ;
16 ;------------------------------------------------------------------------------
17
18 SECTION .text
19
20 ;------------------------------------------------------------------------------
21 ; VOID *
22 ; EFIAPI
23 ; InternalMemSetMem (
24 ; IN VOID *Buffer,
25 ; IN UINTN Count,
26 ; IN UINT8 Value
27 ; )
28 ;------------------------------------------------------------------------------
29 global ASM_PFX(InternalMemSetMem)
30 ASM_PFX(InternalMemSetMem):
31 push edi
32 mov al, [esp + 16]
33 mov ah, al
34 shrd edx, eax, 16
35 shld eax, edx, 16
36 mov ecx, [esp + 12] ; ecx <- Count
37 mov edi, [esp + 8] ; edi <- Buffer
38 mov edx, ecx
39 and edx, 7
40 shr ecx, 3 ; # of Qwords to set
41 jz @SetBytes
42 add esp, -0x10
43 movq [esp], mm0 ; save mm0
44 movq [esp + 8], mm1 ; save mm1
45 movd mm0, eax
46 movd mm1, eax
47 psllq mm0, 32
48 por mm0, mm1 ; fill mm0 with 8 Value's
49 .0:
50 movq [edi], mm0
51 add edi, 8
52 loop .0
53 movq mm0, [esp] ; restore mm0
54 movq mm1, [esp + 8] ; restore mm1
55 add esp, 0x10 ; stack cleanup
56 @SetBytes:
57 mov ecx, edx
58 rep stosb
59 mov eax, [esp + 8] ; eax <- Buffer as return value
60 pop edi
61 ret
62