1/*
2Copyright (c) 2009 Nick Clifton <nickc@redhat.com>
3 */
4#include <picolibc.h>
5
6	.file	"strcmp.S"
7
8	.section .text
9
10	.global  _strcmp
11	.type	 _strcmp,@function
12_strcmp:
13#ifdef __RX_DISALLOW_STRING_INSNS__
142:	mov.b	[r1+], r4
15	mov.b	[r2+], r5
16	cmp	#0, r4
17	beq	3f
18	cmp	#0, r5
19	beq	3f
20	cmp	r4, r5
21	beq	2b
22
233:	and	#0xff, r4	; We need to perform an unsigned comparison of the bytes.
24	and	#0xff, r5
25	sub	r5, r4, r1
26	rts
27#else
28	mov	#-1, r3		; Strictly speaking this is incorrect, but I doubt if anyone will ever know.
29	scmpu			; Perform the string comparison
30	bnc	1f		; If Carry is not set skip over
31	scne.L	r1		; Set result based on Z flag
32	rts			;
331:				;
34	mov	#-1,r1		; Carry not set, result should be negative
35	rts			;
36#endif
37	.size _strcmp, . - _strcmp
38
39