xref: /minix3/common/lib/libc/arch/m68k/string/strcmp.S (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc/*	$NetBSD: strcmp.S,v 1.7 2013/09/07 19:06:29 chs Exp $	*/
2b6cbf720SGianluca Guida
3b6cbf720SGianluca Guida/*-
4b6cbf720SGianluca Guida * Copyright (c) 1997 The NetBSD Foundation, Inc.
5b6cbf720SGianluca Guida * All rights reserved.
6b6cbf720SGianluca Guida *
7b6cbf720SGianluca Guida * This code is derived from software contributed to The NetBSD Foundation
8b6cbf720SGianluca Guida * by Hiroshi Horimoto <horimoto@cs-aoi.cs.sist.ac.jp> and
9b6cbf720SGianluca Guida * by J.T. Conklin <jtc@NetBSD.org>.
10b6cbf720SGianluca Guida *
11b6cbf720SGianluca Guida * Redistribution and use in source and binary forms, with or without
12b6cbf720SGianluca Guida * modification, are permitted provided that the following conditions
13b6cbf720SGianluca Guida * are met:
14b6cbf720SGianluca Guida * 1. Redistributions of source code must retain the above copyright
15b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer.
16b6cbf720SGianluca Guida * 2. Redistributions in binary form must reproduce the above copyright
17b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer in the
18b6cbf720SGianluca Guida *    documentation and/or other materials provided with the distribution.
19b6cbf720SGianluca Guida *
20b6cbf720SGianluca Guida * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21b6cbf720SGianluca Guida * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22b6cbf720SGianluca Guida * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23b6cbf720SGianluca Guida * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24b6cbf720SGianluca Guida * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25b6cbf720SGianluca Guida * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26b6cbf720SGianluca Guida * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27b6cbf720SGianluca Guida * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28b6cbf720SGianluca Guida * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29b6cbf720SGianluca Guida * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30b6cbf720SGianluca Guida * POSSIBILITY OF SUCH DAMAGE.
31b6cbf720SGianluca Guida */
32b6cbf720SGianluca Guida
33b6cbf720SGianluca Guida#include <machine/asm.h>
34b6cbf720SGianluca Guida
35b6cbf720SGianluca Guida#if defined(LIBC_SCCS) && !defined(lint)
36*84d9c625SLionel Sambuc	RCSID("$NetBSD: strcmp.S,v 1.7 2013/09/07 19:06:29 chs Exp $")
37b6cbf720SGianluca Guida#endif /* LIBC_SCCS and not lint */
38b6cbf720SGianluca Guida
39*84d9c625SLionel Sambuc#ifdef __mcoldfire__
40*84d9c625SLionel Sambuc#define GETC(a,b)	mvsb	a,b
41*84d9c625SLionel Sambuc#define	SUBC(a,b)	mvsb	a,%d0; subl %d0,b
42*84d9c625SLionel Sambuc#else
43*84d9c625SLionel Sambuc#define GETC(a,b)	movb	a,b
44*84d9c625SLionel Sambuc#define	SUBC(a,b)	subb	a,b
45*84d9c625SLionel Sambuc#endif
46*84d9c625SLionel Sambuc
47b6cbf720SGianluca GuidaENTRY(strcmp)
48*84d9c625SLionel Sambuc	movl	4(%sp),%a0
49*84d9c625SLionel Sambuc	movl	8(%sp),%a1
50*84d9c625SLionel Sambuc.L1:				/* unrolled by 4 for 680[23]0's */
51*84d9c625SLionel Sambuc	GETC((%a0)+,%d1)
52*84d9c625SLionel Sambuc	jeq	.L2
53*84d9c625SLionel Sambuc	SUBC((%a1)+,%d1)
54*84d9c625SLionel Sambuc	jne	.L3
55b6cbf720SGianluca Guida
56*84d9c625SLionel Sambuc	GETC((%a0)+,%d1)
57*84d9c625SLionel Sambuc	jeq	.L2
58*84d9c625SLionel Sambuc	SUBC((%a1)+,%d1)
59*84d9c625SLionel Sambuc	jne	.L3
60b6cbf720SGianluca Guida
61*84d9c625SLionel Sambuc	GETC((%a0)+,%d1)
62*84d9c625SLionel Sambuc	jeq	.L2
63*84d9c625SLionel Sambuc	SUBC((%a1)+,%d1)
64*84d9c625SLionel Sambuc	jne	.L3
65b6cbf720SGianluca Guida
66*84d9c625SLionel Sambuc	GETC((%a0)+,%d1)
67*84d9c625SLionel Sambuc	jeq	.L2
68*84d9c625SLionel Sambuc	SUBC((%a1)+,%d1)
69*84d9c625SLionel Sambuc	jeq	.L1
70b6cbf720SGianluca Guida
71*84d9c625SLionel Sambuc.L3:
72*84d9c625SLionel Sambuc#ifdef __mcoldfire__
73*84d9c625SLionel Sambuc	movl	%d1,%d0
74*84d9c625SLionel Sambuc#else
75*84d9c625SLionel Sambuc	scs	%d0
76b6cbf720SGianluca Guida	EXTBL(%d0)
77b6cbf720SGianluca Guida	movb	%d1,%d0
78*84d9c625SLionel Sambuc#endif
79b6cbf720SGianluca Guida	rts
80b6cbf720SGianluca Guida
81*84d9c625SLionel Sambuc.L2:	movq	#0,%d0
82*84d9c625SLionel Sambuc	movb	(%a1),%d0
83b6cbf720SGianluca Guida	negl	%d0
84b6cbf720SGianluca Guida	rts
85*84d9c625SLionel SambucEND(strcmp)
86