1/*
2Copyright (c) 2009 Nick Clifton <nickc@redhat.com>
3 */
4	.file	"strlen.S"
5
6	.section .text
7
8	.global  _strlen
9	.type	 _strlen,@function
10_strlen:
11#ifdef __RX_DISALLOW_STRING_INSNS__
12	mov	r1, r4
13
141:	mov.b	[r1+], r5
15	cmp	#0, r5
16	bne	1b
17
18	sub	#1, r1
19	sub	r4, r1
20	rts
21#else
22	add	#0, r1, r4	; Save a copy of the string start address and set the condition flags.
23	beq     null_string	; Test for a NULL pointer.
24	mov	#-1, r3		; Set a limit on the number of bytes examined.
25	mov	#0,  r2		; Stop searching when we find a NUL byte.
26	suntil.b     		; Search until *r1 == r2
27	sub	#1, r1		; suntil.b leaves r1 pointing to the byte beyond the match.
28null_string:
29	sub	r4, r1		; Compute the length.
30	rts
31#endif
32	.size _strlen, . - _strlen
33