OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [machine/] [sh/] [strlen.S] - Blame information for rev 194

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
! Entry: arg0: string start address
2
! Exit:  result: length
3
!
4
! Copyright 2002 SuperH Ltd.
5
 
6
#include "asm.h"
7
 
8
ENTRY(strlen)
9
 
10
#if __SHMEDIA__
11
 
12
        ldlo.q r2,0,r3
13
        ptabs/l r18,tr0
14
        pta/l loop,tr1
15
        andi r2,-8,r0
16
        shlli r2,3,r1
17
        mcmpeq.b r3,r63,r3
18
        SHHI r3,r1,r4
19
        beqi/u r4,0,tr1 // loop
20
#ifdef __LITTLE_ENDIAN__
21
        movi -1,r2
22
        addi r3,-1,r4
23
        msad.ubq r3,r4,r2
24
#else
25
        shlri r3,1,r3
26
        nsb r3,r3
27
        shlri r3,3,r2
28
#endif
29
        blink tr0,r63
30
 
31
loop:
32
        ldlo.q r0,8,r3
33
        addi r0,8,r0
34
        ldlo.q r0,8,r63
35
        mcmpeq.b r3,r63,r3
36
        beqi/l r3,0,tr1 // loop
37
        sub r0,r2,r2
38
#ifdef __LITTLE_ENDIAN__
39
        addi r3,-1,r4
40
        addi r2,-1,r2
41
        msad.ubq r3,r4,r2
42
#else
43
        shlri r3,1,r3
44
        nsb r3,r3
45
        shlri r3,3,r3
46
        add r2,r3,r2
47
#endif
48
        blink tr0,r63
49
 
50
#else /* ! __SHMEDIA__, i.e. SH 1..4 / SHcompact */
51
 
52
#ifdef __SH5__
53
#define STR_INIT r2
54
#define STR_ORIG r0
55
#define STR_COPY STR_ORIG
56
#define MASK r1
57
#define TMP r3
58
#define RESULT r2
59
!        r0,r1,r3: clobbered
60
#else
61
#define STR_INIT r4
62
#define STR_ORIG STR_INIT
63
#define STR_COPY STR
64
#define MASK r1
65
#define TMP r3
66
#define RESULT r0
67
!        r1,r3: clobbered
68
#endif
69
#define STR RESULT
70
 
71
        mov #3,MASK
72
        and STR_INIT,MASK
73
        tst MASK,MASK
74
        SL(bf, L_char_loop, mov STR_INIT, STR_COPY)
75
L_word_loop:
76
        mov.l @STR+,TMP
77
        cmp/str MASK,TMP
78
        bf L_word_loop
79
        add #-4,STR
80
L_char_loop:
81
        mov.b @STR+,TMP
82
        tst TMP,TMP
83
        bf L_char_loop
84
        add #-1,STR
85
        rts
86
        sub STR_ORIG,STR
87
#endif /* ! __SHMEDIA__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.