]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibSse2/Ia32/SetMem.asm
Removed CommonHeader.h generated file from the MdePkg.
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / Ia32 / SetMem.asm
CommitLineData
e1f414b6 1//\r
2// Include common header file for this module.\r
3//\r
f734a10a 4\r
e1f414b6 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; EFIAPI\r
37; InternalMemSetMem (\r
38; IN VOID *Buffer,\r
39; IN UINTN Count,\r
40; IN UINT8 Value\r
41; );\r
42;------------------------------------------------------------------------------\r
43InternalMemSetMem PROC USES edi\r
44 mov edx, [esp + 12] ; edx <- Count\r
45 mov edi, [esp + 8] ; edi <- Buffer\r
46 mov al, [esp + 16] ; al <- Value\r
47 xor ecx, ecx\r
48 sub ecx, edi\r
49 and ecx, 15 ; ecx + edi aligns on 16-byte boundary\r
50 jz @F\r
51 cmp ecx, edx\r
52 cmova ecx, edx\r
53 sub edx, ecx\r
54 rep stosb\r
55@@:\r
56 mov ecx, edx\r
57 and edx, 15\r
58 shr ecx, 4 ; ecx <- # of DQwords to set\r
59 jz @SetBytes\r
60 mov ah, al ; ax <- Value | (Value << 8)\r
61 add esp, -16\r
62 movdqu [esp], xmm0 ; save xmm0\r
63 movd xmm0, eax\r
64 pshuflw xmm0, xmm0, 0 ; xmm0[0..63] <- Value repeats 8 times\r
65 movlhps xmm0, xmm0 ; xmm0 <- Value repeats 16 times\r
66@@:\r
67 movntdq [edi], xmm0 ; edi should be 16-byte aligned\r
68 add edi, 16\r
69 loop @B\r
70 mfence\r
71 movdqu xmm0, [esp] ; restore xmm0\r
72 add esp, 16 ; stack cleanup\r
73@SetBytes:\r
74 mov ecx, edx\r
75 rep stosb\r
76 mov eax, [esp + 8] ; eax <- Buffer as return value\r
77 ret\r
78InternalMemSetMem ENDP\r
79\r
80 END\r