Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / sh / strlen.S
blob93f7dd8f7626332e73d69a1e53f35955bc806dd7
1 /* Copyright (C) 1999, 2000, 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>
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
20 #include <endian.h>
22 /* size_t strlen (const char *s)  */
24 ENTRY(strlen)
25         mov     r4, r0
26         and     #3, r0
27         tst     r0, r0
28         bt/s    1f
29         mov     #0, r2
31         add     #-1, r0
32         shll2   r0
33         shll    r0
34         braf    r0
35         nop
37         mov.b   @r4+, r1
38         tst     r1, r1
39         bt      8f
40         add     #1, r2  
42         mov.b   @r4+, r1
43         tst     r1, r1
44         bt      8f
45         add     #1, r2  
47         mov.b   @r4+, r1
48         tst     r1, r1
49         bt      8f
50         add     #1, r2  
53         mov     #0, r3
55         mov.l   @r4+, r1
56         cmp/str r3, r1
57         bf/s    2b
58         add     #4, r2
60         add     #-4, r2
61 #if __BYTE_ORDER == __BIG_ENDIAN
62         swap.b  r1, r1
63         swap.w  r1, r1
64         swap.b  r1, r1
65 #endif
66         extu.b  r1, r0
67         tst     r0, r0
68         bt/s    8f
69         shlr8   r1
70         add     #1, r2
71         extu.b  r1, r0
72         tst     r0, r0
73         bt/s    8f
74         shlr8   r1
75         add     #1, r2
76         extu.b  r1, r0
77         tst     r0, r0
78         bt      8f
79         add     #1, r2
81         rts
82         mov     r2, r0
83 END(strlen)
84 libc_hidden_builtin_def (strlen)