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