blob: af91fe2b72a66e571ed3c7f08fca44b68f4a4565 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $Id: memset.S,v 1.1 2000/04/14 16:49:01 mjd Exp $
2 *
3 * "memset" implementation of SuperH
4 *
5 * Copyright (C) 1999 Niibe Yutaka
6 *
7 */
8
9/*
10 * void *memset(void *s, int c, size_t n);
11 */
12
13#include <linux/linkage.h>
14
15ENTRY(memset)
16 tst r6,r6
17 bt/s 5f ! if n=0, do nothing
18 add r6,r4
19 mov #12,r0
20 cmp/gt r6,r0
21 bt/s 4f ! if it's too small, set a byte at once
22 mov r4,r0
23 and #3,r0
24 cmp/eq #0,r0
25 bt/s 2f ! It's aligned
26 sub r0,r6
271:
28 dt r0
29 bf/s 1b
30 mov.b r5,@-r4
312: ! make VVVV
Toshinobu Sugiokae7be8532006-09-27 14:13:14 +090032 extu.b r5,r5
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 swap.b r5,r0 ! V0
34 or r0,r5 ! VV
35 swap.w r5,r0 ! VV00
36 or r0,r5 ! VVVV
37 !
38 mov r6,r0
39 shlr2 r0
40 shlr r0 ! r0 = r6 >> 3
413:
42 dt r0
43 mov.l r5,@-r4 ! set 8-byte at once
44 bf/s 3b
45 mov.l r5,@-r4
46 !
47 mov #7,r0
48 and r0,r6
49 tst r6,r6
50 bt 5f
51 ! fill bytes
524:
53 dt r6
54 bf/s 4b
55 mov.b r5,@-r4
565:
57 rts
58 mov r4,r0