blob: 6c6424cf87335f83d6762df3ee339e01dfdff91a [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* Set a block of memory to some byte value.
2 For SPARC v7.
3 Copyright (C) 1996, 1999, 2003 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by David S. Miller <davem@caip.rutgers.edu> and
6 Jakub Jelinek <jj@ultra.linux.cz>.
7
8 The GNU C Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with the GNU C Library; if not, write to the Free
20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 02111-1307 USA. */
22
23#include <features.h>
24
25 /* Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
26#define ZERO_BIG_BLOCK(base, offset, source) \
27 std source, [base + offset + 0x00]; \
28 std source, [base + offset + 0x08]; \
29 std source, [base + offset + 0x10]; \
30 std source, [base + offset + 0x18]; \
31 std source, [base + offset + 0x20]; \
32 std source, [base + offset + 0x28]; \
33 std source, [base + offset + 0x30]; \
34 std source, [base + offset + 0x38];
35
36#define ZERO_LAST_BLOCKS(base, offset, source) \
37 std source, [base - offset - 0x38]; \
38 std source, [base - offset - 0x30]; \
39 std source, [base - offset - 0x28]; \
40 std source, [base - offset - 0x20]; \
41 std source, [base - offset - 0x18]; \
42 std source, [base - offset - 0x10]; \
43 std source, [base - offset - 0x08]; \
44 std source, [base - offset - 0x00];
45
46 .text
47 .align 4
48#ifdef __UCLIBC_SUSV3_LEGACY__
49ENTRY(bzero)
50 b 1f
51 mov %g0, %g3
52#endif
53
543: cmp %o2, 3
55 be 2f
56 stb %g3, [%o0]
57
58 cmp %o2, 2
59 be 2f
60 stb %g3, [%o0 + 0x01]
61
62 stb %g3, [%o0 + 0x02]
632: sub %o2, 4, %o2
64 add %o1, %o2, %o1
65 b 4f
66 sub %o0, %o2, %o0
67#ifdef __UCLIBC_SUSV3_LEGACY__
68END(bzero)
69#endif
70
71ENTRY(memset)
72 and %o1, 0xff, %g3
73 sll %g3, 8, %g2
74 or %g3, %g2, %g3
75 sll %g3, 16, %g2
76 or %g3, %g2, %g3
77 orcc %o2, %g0, %o1
781: cmp %o1, 7
79 bleu 7f
80 mov %o0, %g1
81
82 andcc %o0, 3, %o2
83 bne 3b
844: andcc %o0, 4, %g0
85
86 be 2f
87 mov %g3, %g2
88
89 st %g3, [%o0]
90 sub %o1, 4, %o1
91 add %o0, 4, %o0
922: andcc %o1, 0xffffff80, %o3
93 be 9f
94 andcc %o1, 0x78, %o2
954: ZERO_BIG_BLOCK (%o0, 0x00, %g2)
96 subcc %o3, 128, %o3
97 ZERO_BIG_BLOCK (%o0, 0x40, %g2)
98 bne 4b
99 add %o0, 128, %o0
100
101 orcc %o2, %g0, %g0
1029: be 6f
103 andcc %o1, 7, %o1
104
105 mov %o7, %g4
106101: call 100f
107 srl %o2, 1, %o3
108 mov %g4, %o7
109 jmpl %o4 + (20f + 64 - 101b), %g0
110 add %o0, %o2, %o0
111
112100: retl
113 sub %o7, %o3, %o4
114
11520: ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
116 ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
117
1186: be 8f
119 andcc %o1, 4, %g0
120 be 1f
121 andcc %o1, 2, %g0
122 st %g3, [%o0]
123 add %o0, 4, %o0
1241: be 1f
125 andcc %o1, 1, %g0
126 sth %g3, [%o0]
127 add %o0, 2, %o0
1281: bne,a 8f
129 stb %g3, [%o0]
1308: retl
131 mov %g1, %o0
1327: orcc %o1, 0, %g0
133 be 0f
134 subcc %o1, 1, %o1
135 stb %g3, [%o0]
136 be 0f
137 subcc %o1, 1, %o1
138 stb %g3, [%o0 + 1]
139 be 0f
140 subcc %o1, 1, %o1
141 stb %g3, [%o0 + 2]
142 be 0f
143 subcc %o1, 1, %o1
144 stb %g3, [%o0 + 3]
145 be 0f
146 subcc %o1, 1, %o1
147 stb %g3, [%o0 + 4]
148 be 0f
149 subcc %o1, 1, %o1
150 stb %g3, [%o0 + 5]
151 be 0f
152 subcc %o1, 1, %o1
153 stb %g3, [%o0 + 6]
1540: retl
155 nop
156END(memset)
157libc_hidden_def(memset)