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