1/*
2Copyright (c) 1990 The Regents of the University of California.
3All rights reserved.
4
5Redistribution and use in source and binary forms are permitted
6provided that the above copyright notice and this paragraph are
7duplicated in all such forms and that any documentation,
8and/or other materials related to such
9distribution and use acknowledge that the software was developed
10by the University of California, Berkeley.  The name of the
11University may not be used to endorse or promote products derived
12from this software without specific prior written permission.
13THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 */
17#include "setarch.h"
18
19#include "defines.h"
20
21#if defined (__H8300SX__)
22	.global _strcmp
23_strcmp:
24	mov.l	er0,er2
25loop:
26	mov.b	@er2+,r0l
27	beq	eos
28	sub.b	@er1+,r0l
29	beq	loop
30	exts.l	#2,er0
31	rts
32eos:
33	sub.b	@er1,r0l
34	exts.l	#2,er0
35	rts
36#else
37	.section .text
38	.align 2
39	.global _strcmp
40_strcmp:
41	MOVP	A0P,A2P
42	MOVP	A1P,A3P
43.L5:
44	mov.b	@A2P+,A1L
45	beq	.L3
46	mov.b	@A3P+,A0L
47	cmp.b	A0L,A1L
48	beq	.L5
49#ifdef __NORMAL_MODE__
50	sub	#1,A3P
51#else
52	subs	#1,A3P
53#endif
54.L3:
55	mov.b	@(-1,A2P),A0L
56	mov.b	@A3P,A1L
57	sub.b	A1L,A0L
58	; We have to sign extend the result to 32bits just in case
59	; we are using 32bit integers.
60#ifdef __H8300H__
61	exts.w	r0
62	exts.l	er0
63#else
64#ifdef __H8300S__
65	exts.w	r0
66	exts.l	er0
67#else
68	bld	#7,r0l
69	subx	r0h,r0h
70	subx	r1l,r1l
71	subx	r1h,r1h
72#endif
73#endif
74	rts
75	.end
76#endif
77