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 | |
eb227e96 |
24 | .686: |
6e3b8c47 |
25 | #.MODEL flat,C |
eb227e96 |
26 | .xmm: |
27 | .code: |
6e3b8c47 |
28 | |
29 | #------------------------------------------------------------------------------ |
30 | # VOID * |
31 | # _mem_SetMem ( |
32 | # IN VOID *Buffer, |
33 | # IN UINTN Count, |
34 | # IN UINT8 Value |
eb227e96 |
35 | # ); |
6e3b8c47 |
36 | #------------------------------------------------------------------------------ |
b7089db1 |
37 | .globl _InternalMemSetMem |
6e3b8c47 |
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 |
eb227e96 |
52 | L0: |
6e3b8c47 |
53 | movl %edx, %ecx |
54 | andl $15, %edx |
55 | shrl $4, %ecx # ecx <- # of DQwords to set |
b7089db1 |
56 | jz L_SetBytes |
6e3b8c47 |
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 |
eb227e96 |
63 | L1: |
6e3b8c47 |
64 | movntdq %xmm0, (%edi) |
65 | addl $16, %edi |
66 | loop L1 |
67 | mfence |
68 | movdqu (%esp), %xmm0 |
69 | addl $16, %esp # stack cleanup |
b7089db1 |
70 | L_SetBytes: |
6e3b8c47 |
71 | movl %edx, %ecx |
72 | rep |
73 | stosb |
74 | movl 8(%esp), %eax # eax <- Buffer as return value |
75 | pop %edi |
76 | ret |