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