aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/sh/memset.S
blob: f2120a85154e1b8ec6896d65a4f273db81926625 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
   This file is part of the GNU C Library.
   Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

#include <sysdep.h>

/* void *memset (t, c, len)  */

ENTRY(memset)
	tst	r6, r6
	bt/s	end
	mov	r4, r3
	mov	#3, r0
	cmp/hs	r6, r0
	bt/s	2f
	and	r4, r0
	tst	r0, r0
	bt/s	1f
	add	r0, r6
	add	#-1, r0
	shll2	r0
	braf	r0
	add	#-4, r6

	mov.b	r5, @r4
	add	#1, r4
	mov.b	r5, @r4
	add	#1, r4
	mov.b	r5, @r4
	add	#1, r4
1:
	extu.b	r5, r0
	shll8	r5
	or	r5, r0
	extu.w	r0, r0
	mov	r0, r5
	swap.w	r5, r5
	or	r0, r5
	
2:
	add	#-4, r6
	cmp/pz	r6
	bf	afew
	mov.l	r5, @r4
	bra	2b
	add	#4, r4

afew:
	mov	#-1, r0
	sub	r6, r0
	shll2	r0
	braf	r0
	nop

	mov.b	r5, @r4
	add	#1, r4
	mov.b	r5, @r4
	add	#1, r4
	mov.b	r5, @r4
	add	#1, r4
end:
	rts
	mov	r3, r0
END(memset)