]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.S
Import some basic libraries instances for Mde Packages.
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / Ia32 / SetMem.S
1 //
2 // Include common header file for this module.
3 //
4 #include "CommonHeader.h"
5
6 #------------------------------------------------------------------------------
7 #
8 # Copyright (c) 2006, Intel Corporation
9 # All rights reserved. This program and the accompanying materials
10 # are licensed and made available under the terms and conditions of the BSD License
11 # which accompanies this distribution. The full text of the license may be found at
12 # http://opensource.org/licenses/bsd-license.php
13 #
14 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #
17 # Module Name:
18 #
19 # SetMem.asm
20 #
21 # Abstract:
22 #
23 # SetMem function
24 #
25 # Notes:
26 #
27 #------------------------------------------------------------------------------
28
29 .686:
30 #.MODEL flat,C
31 .xmm:
32 .code:
33
34 #------------------------------------------------------------------------------
35 # VOID *
36 # _mem_SetMem (
37 # IN VOID *Buffer,
38 # IN UINTN Count,
39 # IN UINT8 Value
40 # );
41 #------------------------------------------------------------------------------
42 .globl _InternalMemSetMem
43 _InternalMemSetMem:
44 push %edi
45 movl 12(%esp), %edx # edx <- Count
46 movl 8(%esp), %edi # edi <- Buffer
47 movb 16(%esp), %al # al <- Value
48 xorl %ecx, %ecx
49 subl %edi, %ecx
50 andl $15, %ecx # ecx + edi aligns on 16-byte boundary
51 jz L0
52 cmpl %edx, %ecx
53 cmova %edx, %ecx
54 subl %ecx, %edx
55 rep
56 stosb
57 L0:
58 movl %edx, %ecx
59 andl $15, %edx
60 shrl $4, %ecx # ecx <- # of DQwords to set
61 jz L_SetBytes
62 movb %al, %ah # ax <- Value | (Value << 8)
63 addl $-16, %esp
64 movdqu %xmm0, (%esp)
65 movd %eax, %xmm0
66 pshuflw $0, %xmm0, %xmm0
67 movlhps %xmm0, %xmm0
68 L1:
69 movntdq %xmm0, (%edi)
70 addl $16, %edi
71 loop L1
72 mfence
73 movdqu (%esp), %xmm0
74 addl $16, %esp # stack cleanup
75 L_SetBytes:
76 movl %edx, %ecx
77 rep
78 stosb
79 movl 8(%esp), %eax # eax <- Buffer as return value
80 pop %edi
81 ret