]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/sh/strlen.S
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / sh / strlen.S
CommitLineData
04277e02 1/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
3846ef75
UD
2 This file is part of the GNU C Library.
3 Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
3846ef75
UD
9
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
41bdb6e2 13 Lesser General Public License for more details.
3846ef75 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
3846ef75
UD
18
19#include <sysdep.h>
3846ef75
UD
20
21/* size_t strlen (const char *s) */
22
23ENTRY(strlen)
24 mov r4, r0
25 and #3, r0
26 tst r0, r0
27 bt/s 1f
28 mov #0, r2
29
30 add #-1, r0
31 shll2 r0
32 shll r0
33 braf r0
34 nop
35
36 mov.b @r4+, r1
37 tst r1, r1
38 bt 8f
9c84384c 39 add #1, r2
3846ef75
UD
40
41 mov.b @r4+, r1
42 tst r1, r1
43 bt 8f
9c84384c 44 add #1, r2
3846ef75
UD
45
46 mov.b @r4+, r1
47 tst r1, r1
48 bt 8f
9c84384c 49 add #1, r2
3846ef75
UD
50
511:
52 mov #0, r3
532:
54 mov.l @r4+, r1
55 cmp/str r3, r1
56 bf/s 2b
57 add #4, r2
58
59 add #-4, r2
3ce2865f 60#ifdef __BIG_ENDIAN__
3846ef75
UD
61 swap.b r1, r1
62 swap.w r1, r1
63 swap.b r1, r1
64#endif
65 extu.b r1, r0
66 tst r0, r0
67 bt/s 8f
68 shlr8 r1
69 add #1, r2
70 extu.b r1, r0
71 tst r0, r0
72 bt/s 8f
73 shlr8 r1
74 add #1, r2
75 extu.b r1, r0
76 tst r0, r0
77 bt 8f
78 add #1, r2
798:
80 rts
81 mov r2, r0
82END(strlen)
85dd1003 83libc_hidden_builtin_def (strlen)