1/* memset.S */
2
3#include <asm/linkage.h>
4
5#if defined(CONFIG_CPU_H8300H)
6	.h8300h
7#endif
8#if defined(CONFIG_CPU_H8S)
9	.h8300s
10#endif
11	.text
12
13.global	memset
14.global	clear_user
15
16;;void *memset(*ptr, int c, size_t count)
17;; ptr = er0
18;; c   = er1(r1l)
19;; count = er2
20memset:
21	btst	#0,r0l
22	beq	2f
23
24	;; odd address
251:
26	mov.b	r1l,@er0
27	adds	#1,er0
28	dec.l	#1,er2
29	beq	6f
30
31	;; even address
322:
33	mov.l	er2,er3
34	cmp.l	#4,er2
35	blo	4f
36	;; count>=4 -> count/4
37#if defined(CONFIG_CPU_H8300H)
38	shlr.l	er2
39	shlr.l	er2
40#endif
41#if defined(CONFIG_CPU_H8S)
42	shlr.l	#2,er2
43#endif
44	;; byte -> long
45	mov.b	r1l,r1h
46	mov.w	r1,e1
473:
48	mov.l	er1,@er0
49	adds	#4,er0
50	dec.l	#1,er2
51	bne	3b
524:
53	;; count % 4
54	and.b	#3,r3l
55	beq	6f
565:
57	mov.b	r1l,@er0
58	adds	#1,er0
59	dec.b	r3l
60	bne	5b
616:
62	rts
63
64clear_user:
65	mov.l	er1, er2
66	sub.l	er1, er1
67	bra	memset
68
69	.end
70