xref: /netbsd-src/common/lib/libc/arch/m68k/string/strcmp.S (revision 18ec38ea7c8331c5bc28d877de4a5b1391957c39)
1*18ec38eaSchs/*	$NetBSD: strcmp.S,v 1.7 2013/09/07 19:06:29 chs Exp $	*/
237c9f0a6Schristos
337c9f0a6Schristos/*-
437c9f0a6Schristos * Copyright (c) 1997 The NetBSD Foundation, Inc.
537c9f0a6Schristos * All rights reserved.
637c9f0a6Schristos *
737c9f0a6Schristos * This code is derived from software contributed to The NetBSD Foundation
837c9f0a6Schristos * by Hiroshi Horimoto <horimoto@cs-aoi.cs.sist.ac.jp> and
937c9f0a6Schristos * by J.T. Conklin <jtc@NetBSD.org>.
1037c9f0a6Schristos *
1137c9f0a6Schristos * Redistribution and use in source and binary forms, with or without
1237c9f0a6Schristos * modification, are permitted provided that the following conditions
1337c9f0a6Schristos * are met:
1437c9f0a6Schristos * 1. Redistributions of source code must retain the above copyright
1537c9f0a6Schristos *    notice, this list of conditions and the following disclaimer.
1637c9f0a6Schristos * 2. Redistributions in binary form must reproduce the above copyright
1737c9f0a6Schristos *    notice, this list of conditions and the following disclaimer in the
1837c9f0a6Schristos *    documentation and/or other materials provided with the distribution.
1937c9f0a6Schristos *
2037c9f0a6Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2137c9f0a6Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2237c9f0a6Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2337c9f0a6Schristos * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2437c9f0a6Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2537c9f0a6Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2637c9f0a6Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2737c9f0a6Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2837c9f0a6Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2937c9f0a6Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3037c9f0a6Schristos * POSSIBILITY OF SUCH DAMAGE.
3137c9f0a6Schristos */
3237c9f0a6Schristos
3337c9f0a6Schristos#include <machine/asm.h>
3437c9f0a6Schristos
3537c9f0a6Schristos#if defined(LIBC_SCCS) && !defined(lint)
36*18ec38eaSchs	RCSID("$NetBSD: strcmp.S,v 1.7 2013/09/07 19:06:29 chs Exp $")
3737c9f0a6Schristos#endif /* LIBC_SCCS and not lint */
3837c9f0a6Schristos
391d398a17Smatt#ifdef __mcoldfire__
401d398a17Smatt#define GETC(a,b)	mvsb	a,b
411d398a17Smatt#define	SUBC(a,b)	mvsb	a,%d0; subl %d0,b
421d398a17Smatt#else
431d398a17Smatt#define GETC(a,b)	movb	a,b
441d398a17Smatt#define	SUBC(a,b)	subb	a,b
451d398a17Smatt#endif
461d398a17Smatt
4737c9f0a6SchristosENTRY(strcmp)
4807a0a325Smatt	movl	4(%sp),%a0
4907a0a325Smatt	movl	8(%sp),%a1
50*18ec38eaSchs.L1:				/* unrolled by 4 for 680[23]0's */
511d398a17Smatt	GETC((%a0)+,%d1)
52*18ec38eaSchs	jeq	.L2
531d398a17Smatt	SUBC((%a1)+,%d1)
54*18ec38eaSchs	jne	.L3
5537c9f0a6Schristos
561d398a17Smatt	GETC((%a0)+,%d1)
57*18ec38eaSchs	jeq	.L2
581d398a17Smatt	SUBC((%a1)+,%d1)
59*18ec38eaSchs	jne	.L3
6037c9f0a6Schristos
611d398a17Smatt	GETC((%a0)+,%d1)
62*18ec38eaSchs	jeq	.L2
631d398a17Smatt	SUBC((%a1)+,%d1)
64*18ec38eaSchs	jne	.L3
6537c9f0a6Schristos
661d398a17Smatt	GETC((%a0)+,%d1)
67*18ec38eaSchs	jeq	.L2
681d398a17Smatt	SUBC((%a1)+,%d1)
69*18ec38eaSchs	jeq	.L1
7037c9f0a6Schristos
71*18ec38eaSchs.L3:
72cb2ad9b1Smatt#ifdef __mcoldfire__
731d398a17Smatt	movl	%d1,%d0
74cb2ad9b1Smatt#else
75cb2ad9b1Smatt	scs	%d0
76cb2ad9b1Smatt	EXTBL(%d0)
77cb2ad9b1Smatt	movb	%d1,%d0
78cb2ad9b1Smatt#endif
7937c9f0a6Schristos	rts
8037c9f0a6Schristos
81*18ec38eaSchs.L2:	movq	#0,%d0
8207a0a325Smatt	movb	(%a1),%d0
8337c9f0a6Schristos	negl	%d0
8437c9f0a6Schristos	rts
8565726debSmattEND(strcmp)
86