blob: 1bcc13f05962e3f66ecefebf0c3adedb670bb456 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $Id: strlen.S,v 1.2 2001/06/29 14:07:15 gniibe Exp $
2 *
3 * "strlen" implementation of SuperH
4 *
5 * Copyright (C) 1999 Kaz Kojima
6 *
7 */
8
9/* size_t strlen (const char *s) */
10
11#include <linux/linkage.h>
12ENTRY(strlen)
13 mov r4,r0
14 and #3,r0
15 tst r0,r0
16 bt/s 1f
17 mov #0,r2
18
19 add #-1,r0
20 shll2 r0
21 shll r0
22 braf r0
23 nop
24
25 mov.b @r4+,r1
26 tst r1,r1
27 bt 8f
28 add #1,r2
29
30 mov.b @r4+,r1
31 tst r1,r1
32 bt 8f
33 add #1,r2
34
35 mov.b @r4+,r1
36 tst r1,r1
37 bt 8f
Andrea Gelminia5c43002010-05-23 20:02:06 +000038 add #1,r2
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
401:
41 mov #0,r3
422:
43 mov.l @r4+,r1
44 cmp/str r3,r1
45 bf/s 2b
46 add #4,r2
47
48 add #-4,r2
49#ifndef __LITTLE_ENDIAN__
50 swap.b r1,r1
51 swap.w r1,r1
52 swap.b r1,r1
53#endif
54 extu.b r1,r0
55 tst r0,r0
56 bt/s 8f
57 shlr8 r1
58 add #1,r2
59 extu.b r1,r0
60 tst r0,r0
61 bt/s 8f
62 shlr8 r1
63 add #1,r2
64 extu.b r1,r0
65 tst r0,r0
66 bt 8f
67 add #1,r2
688:
69 rts
70 mov r2,r0