source: trunk/libs/newlib/src/newlib/libc/machine/rx/strlen.S @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 668 bytes
Line 
1        .file   "strlen.S"
2
3        .section .text
4       
5        .global  _strlen
6        .type    _strlen,@function
7_strlen:
8#ifdef __RX_DISALLOW_STRING_INSNS__
9        mov     r1, r4
10
111:      mov.b   [r1+], r5
12        cmp     #0, r5
13        bne     1b
14
15        sub     #1, r1
16        sub     r4, r1
17        rts
18#else
19        add     #0, r1, r4      ; Save a copy of the string start address and set the condition flags.
20        beq     null_string     ; Test for a NULL pointer.
21        mov     #-1, r3         ; Set a limit on the number of bytes examined.
22        mov     #0,  r2         ; Stop searching when we find a NUL byte.
23        suntil.b                ; Search until *r1 == r2
24        sub     #1, r1          ; suntil.b leaves r1 pointing to the byte beyond the match.
25null_string:
26        sub     r4, r1          ; Compute the length.
27        rts
28#endif
29        .size _strlen, . - _strlen
Note: See TracBrowser for help on using the repository browser.