]>
Commit | Line | Data |
---|---|---|
7ffe2de6 UD |
1 | /* memset/bzero -- set memory area to CH/0 |
2 | Highly optimized version for ix86, x>=6. | |
3f02f778 | 3 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
7ffe2de6 | 4 | This file is part of the GNU C Library. |
6923133b | 5 | Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999. |
7ffe2de6 UD |
6 | |
7 | The GNU C Library is free software; you can redistribute it and/or | |
8 | modify it under the terms of the GNU Library General Public License as | |
9 | published by the Free Software Foundation; either version 2 of the | |
10 | License, or (at your option) any later version. | |
11 | ||
12 | The GNU C Library is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Library General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Library General Public | |
18 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
19 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include <sysdep.h> | |
23 | #include "asm-syntax.h" | |
3f02f778 | 24 | #include "bp-asm.h" |
7ffe2de6 | 25 | |
3f02f778 GM |
26 | /* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ |
27 | #define BZERO_P (defined memset) | |
7ffe2de6 | 28 | |
3f02f778 GM |
29 | #define PARMS LINKAGE+4 /* space for 1 saved reg */ |
30 | #if BZERO_P | |
31 | # define DEST PARMS | |
32 | # define LEN DEST+PTR_SIZE | |
33 | #else | |
34 | # define RTN PARMS | |
35 | # define DEST RTN+RTN_SIZE | |
36 | # define CHR DEST+PTR_SIZE | |
37 | # define LEN CHR+4 | |
38 | #endif | |
7ffe2de6 UD |
39 | |
40 | .text | |
41 | ENTRY (memset) | |
3f02f778 GM |
42 | ENTER |
43 | ||
7ffe2de6 UD |
44 | cld |
45 | pushl %edi | |
3f02f778 GM |
46 | movl DEST(%esp), %edx |
47 | movl LEN(%esp), %ecx | |
48 | #if BZERO_P | |
49 | xorl %eax, %eax /* fill with 0 */ | |
7ffe2de6 | 50 | #else |
3f02f778 | 51 | movzbl CHR(%esp), %eax |
7ffe2de6 UD |
52 | #endif |
53 | jecxz 1f | |
54 | movl %edx, %edi | |
55 | andl $3, %edx | |
56 | jz 2f | |
57 | jnp 3f | |
58 | stosb | |
59 | decl %ecx | |
60 | jz 1f | |
61 | 3: stosb | |
62 | decl %ecx | |
63 | jz 1f | |
64 | xorl $3, %edx | |
65 | jz 2f | |
66 | stosb | |
67 | decl %ecx | |
68 | 2: movl %ecx, %edx | |
69 | shrl $2, %ecx | |
70 | andl $3, %edx | |
3f02f778 | 71 | #if !BZERO_P |
7ffe2de6 UD |
72 | imul $0x01010101, %eax |
73 | #endif | |
74 | rep | |
75 | stosl | |
76 | movl %edx, %ecx | |
77 | rep | |
78 | stosb | |
79 | ||
6923133b | 80 | 1: |
3f02f778 GM |
81 | #if !BZERO_P |
82 | movl DEST(%esp), %eax | |
6923133b | 83 | #endif |
7ffe2de6 | 84 | popl %edi |
3f02f778 GM |
85 | |
86 | LEAVE | |
87 | #if BZERO_P | |
7ffe2de6 | 88 | ret |
3f02f778 GM |
89 | #else |
90 | RET_PTR | |
91 | #endif | |
7ffe2de6 | 92 | END (memset) |