2.9
[glibc/nacl-glibc.git] / sysdeps / sh / memset.S
blob9a8e2efd96ce3c70df3bbe934174cbefdc6723b1
1 /* Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
4    Optimized by Toshiyasu Morita <toshiyasu.morita@hsa.hitachi.com>
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
21 #include <sysdep.h>
23 /* void *memset (t, c, len);  */
25 ENTRY(memset)
26         mov     #12,r0
27         cmp/gt  r6,r0
28         bt.s    L_byte_loop_init
29         mov     r4,r7
31         extu.b  r5,r5
32         swap.b  r5,r1
33         or      r1,r5
34         swap.w  r5,r1
35         or      r1,r5
37         mov     r4,r0
38         tst     #1,r0
39         bt      L_wordalign
41         mov.b   r5,@r4
42         add     #-1,r6  
43         add     #1,r4
44         mov     r4,r0
46         .balignw 4,0x0009
47 L_wordalign:
48         tst     #2,r0
49         bt      L_word_loop_init
51         mov.w   r5,@r4
52         add     #-2,r6
53         add     #2,r4
54         mov     r4,r0
56         .balignw 4,0x0009
57 L_word_loop_init:
58         mov     r6,r3
59         shlr2   r3
60         mov     #7,r0
61         shlr    r3
62         and     r0,r6
64         .balignw 4,0x0009
65 L_2word_loop:
66         mov.l   r5,@r4
67         dt      r3
68         mov.l   r5,@(4,r4)
69         bf.s    L_2word_loop
70         add     #8,r4
72         .balignw 4,0x0009
73 L_byte_loop_init:
74         tst     r6,r6
75         bt      L_byte_exit
77         .balignw 4,0x0009
78 L_byte_loop:
79         mov.b   r5,@r4
80         dt      r6
81         bf.s    L_byte_loop
82         add     #1,r4
84         .balignw 4,0x0009
85 L_byte_exit:
86         rts
87         mov     r7,r0
88 END(memset)
89 libc_hidden_builtin_def (memset)