Module Name:    src
Committed By:   matt
Date:           Thu Jul 18 22:42:51 UTC 2013

Modified Files:
        src/common/lib/libc/arch/m68k/gen: bswap16.S bswap32.S bswap64.S
        src/common/lib/libc/arch/m68k/string: bcmp.S bcopy.S bzero.S ffs.S
            memcmp.S memset.S strcmp.S strncmp.S strncpy.S

Log Message:
Adjust for Coldfire


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/m68k/gen/bswap16.S \
    src/common/lib/libc/arch/m68k/gen/bswap32.S
cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/m68k/gen/bswap64.S
cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/arch/m68k/string/bcmp.S \
    src/common/lib/libc/arch/m68k/string/bcopy.S \
    src/common/lib/libc/arch/m68k/string/bzero.S \
    src/common/lib/libc/arch/m68k/string/ffs.S \
    src/common/lib/libc/arch/m68k/string/memset.S \
    src/common/lib/libc/arch/m68k/string/strcmp.S \
    src/common/lib/libc/arch/m68k/string/strncmp.S
cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/m68k/string/memcmp.S \
    src/common/lib/libc/arch/m68k/string/strncpy.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/m68k/gen/bswap16.S
diff -u src/common/lib/libc/arch/m68k/gen/bswap16.S:1.4 src/common/lib/libc/arch/m68k/gen/bswap16.S:1.5
--- src/common/lib/libc/arch/m68k/gen/bswap16.S:1.4	Tue Jul 16 23:24:18 2013
+++ src/common/lib/libc/arch/m68k/gen/bswap16.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bswap16.S,v 1.4 2013/07/16 23:24:18 matt Exp $	*/
+/*	$NetBSD: bswap16.S,v 1.5 2013/07/18 22:42:50 matt Exp $	*/
 
 /*
  * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
@@ -35,7 +35,20 @@
 #endif /* defined(_KERNEL) || defined(_STANDALONE) */
 
 _ENTRY(BSWAP16)
+#ifdef __mcfisac__
+	mvzw	6(%sp),%d0
+	swap	%d0
+	byterev	%d0
+#elif defined(__mcoldfire__)
+	mvzw	6(%sp),%d0
+	movl	%d0,%d1
+	mvzb	%d0,%d0
+	lsll	#8,%d0
+	lsrl	#8,%d1
+	orl	%d1,%d0
+#else
 	movl	4(%sp),%d0
 	rolw	#8,%d0
+#endif
 	rts
 END(BSWAP16)
Index: src/common/lib/libc/arch/m68k/gen/bswap32.S
diff -u src/common/lib/libc/arch/m68k/gen/bswap32.S:1.4 src/common/lib/libc/arch/m68k/gen/bswap32.S:1.5
--- src/common/lib/libc/arch/m68k/gen/bswap32.S:1.4	Tue Jul 16 23:24:18 2013
+++ src/common/lib/libc/arch/m68k/gen/bswap32.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bswap32.S,v 1.4 2013/07/16 23:24:18 matt Exp $	*/
+/*	$NetBSD: bswap32.S,v 1.5 2013/07/18 22:42:50 matt Exp $	*/
 
 /*
  * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
@@ -36,8 +36,20 @@
 
 _ENTRY(BSWAP32)
 	movl	4(%sp),%d0
+#ifdef __mcfisac__
+	byterev	%d0
+#elif defined(__mcoldfire__)
+	movl	%d0,%d1
+	lsrl	#8,%d0		| ABCD -> 0ABC
+	andl	#0x00ff00ff,%d0	| 0ABC -> 0A0C
+	andl	#0x00ff00ff,%d1	| ABCD -> 0B0D
+	lsll	#8,%d1		| 0B0D -> B0D0
+	orl	%d1,%d0		| 0A0C | B0D0 -> BADC
+	swap	%d0		| BADC -> DCBA
+#else
+ 	rolw	#8,%d0
+ 	swap	%d0
 	rolw	#8,%d0
-	swap	%d0
-	rolw	#8,%d0
+#endif
 	rts
 END(BSWAP32)

Index: src/common/lib/libc/arch/m68k/gen/bswap64.S
diff -u src/common/lib/libc/arch/m68k/gen/bswap64.S:1.3 src/common/lib/libc/arch/m68k/gen/bswap64.S:1.4
--- src/common/lib/libc/arch/m68k/gen/bswap64.S:1.3	Tue Jul 16 23:24:18 2013
+++ src/common/lib/libc/arch/m68k/gen/bswap64.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bswap64.S,v 1.3 2013/07/16 23:24:18 matt Exp $	*/
+/*	$NetBSD: bswap64.S,v 1.4 2013/07/18 22:42:50 matt Exp $	*/
 
 /*
  * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
@@ -31,11 +31,34 @@
 ENTRY(bswap64)
 	movl	4(%sp),%d1
 	movl	8(%sp),%d0
+#ifdef __mcfisac__
+	byterev	%d0
+	byterev	%d1
+#elif defined(__mcoldfire__)
+	movl	%d3,-(%sp)
+	movl	%d2,-(%sp)
+	movl	#0x00ff00ff, %d3
+	movl	%d0,%d2
+	andl	%d3,%d2
+	lsll	#8,%d2
+	lsrl	#8,%d0
+	andl	%d3,%d0
+	orl	%d2,%d0
+	movl	%d1,%d2
+	andl	%d3,%d2
+	lsll	#8,%d2
+	lsrl	#8,%d1
+	andl	%d3,%d1
+	orl	%d2,%d1
+	movl	(%sp)+,%d2
+	movl	(%sp)+,%d3
+#else
 	rolw	#8,%d1
 	rolw	#8,%d0
 	swap	%d1
 	swap	%d0
 	rolw	#8,%d0
 	rolw	#8,%d1
+#endif
 	rts
 END(bswap64)

Index: src/common/lib/libc/arch/m68k/string/bcmp.S
diff -u src/common/lib/libc/arch/m68k/string/bcmp.S:1.4 src/common/lib/libc/arch/m68k/string/bcmp.S:1.5
--- src/common/lib/libc/arch/m68k/string/bcmp.S:1.4	Tue Jul 16 23:24:19 2013
+++ src/common/lib/libc/arch/m68k/string/bcmp.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcmp.S,v 1.4 2013/07/16 23:24:19 matt Exp $	*/
+/*	$NetBSD: bcmp.S,v 1.5 2013/07/18 22:42:50 matt Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -68,14 +68,27 @@
 #if 0
 	RCSID("from: @(#)bcmp.s 5.1 (Berkeley) 5/12/90")
 #else
-	RCSID("$NetBSD: bcmp.S,v 1.4 2013/07/16 23:24:19 matt Exp $")
+	RCSID("$NetBSD: bcmp.S,v 1.5 2013/07/18 22:42:50 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#ifdef __mcoldfire__
+#define	CMPMB(a,b)	movb b,%d2; cmpb a,%d2
+#define	CMPMW(a,b)	movw b,%d2; cmpw a,%d2
+#define	CMPML(a,b)	movl b,%d2; cmpl a,%d2
+#else
+#define	CMPMB(a,b)	cmpmb a,b
+#define	CMPMW(a,b)	cmpmw a,b
+#define	CMPML(a,b)	cmpml a,b
+#endif
+
 ENTRY(bcmp)
 	movl	4(%sp),%a0		| string 1
 	movl	8(%sp),%a1		| string 2
 	movl	12(%sp),%d1		| length
+#ifdef __mcoldfire__
+	movl	%d2,-(%sp)		| save temp
+#endif
 
 	/*
 	 * It isn't worth the overhead of aligning to {long}word boundries
@@ -100,14 +113,14 @@ ENTRY(bcmp)
 	movl	%a0,%d0
 	btst	#0,%d0
 	jeq	Lbcalgndw
-	cmpmb	(%a0)+,(%a1)+
+	CMPMB((%a0)+,(%a1)+)
 	jne	Lbcnoteq
 	subql	#1,%d1
 Lbcalgndw:
 	/* long word align */
 	btst	#1,%d0
 	jeq	Lbcalgndl
-	cmpmw	(%a0)+,(%a1)+
+	CMPMW((%a0)+,(%a1)+)
 	jne	Lbcnoteq
 	subql	#2,%d1
 Lbcalgndl:
@@ -118,24 +131,26 @@ Lbcalgndl:
 	andl	#31,%d1			|	len %= 32
 	subql	#1,%d0			|	set up for dbf
 Lbc32loop:
-	cmpml	(%a0)+,(%a1)+		|	compare 8 longwords
+	CMPML((%a0)+,(%a1)+)		|	compare 1 of 8 longwords
 	jne	Lbcnoteq		|	not equal, return non-zero
-	cmpml	(%a0)+,(%a1)+
+	CMPML((%a0)+,(%a1)+)		|	compare 2 of 8 longwords
 	jne	Lbcnoteq
-	cmpml	(%a0)+,(%a1)+
+	CMPML((%a0)+,(%a1)+)		|	compare 3 of 8 longwords
 	jne	Lbcnoteq
-	cmpml	(%a0)+,(%a1)+
+	CMPML((%a0)+,(%a1)+)		|	compare 4 of 8 longwords
 	jne	Lbcnoteq
-	cmpml	(%a0)+,(%a1)+
+	CMPML((%a0)+,(%a1)+)		|	compare 5 of 8 longwords
 	jne	Lbcnoteq
-	cmpml	(%a0)+,(%a1)+
+	CMPML((%a0)+,(%a1)+)		|	compare 6 of 8 longwords
 	jne	Lbcnoteq
-	cmpml	(%a0)+,(%a1)+
+	CMPML((%a0)+,(%a1)+)		|	compare 7 of 8 longwords
 	jne	Lbcnoteq
-	cmpml	(%a0)+,(%a1)+
+	CMPML((%a0)+,(%a1)+)		|	compare 8 of 8 longwords
 	jne	Lbcnoteq
+#ifndef __mcoldfire__
 	dbf	%d0,Lbc32loop		|	till done
 	clrw	%d0
+#endif
 	subql	#1,%d0
 	jcc	Lbc32loop
 
@@ -146,19 +161,32 @@ Lbclong:
 	jeq	Lbcbyte			| if (cnt)
 	subql	#1,%d0			|	set up for dbf
 Lbclloop:
-	cmpml	(%a0)+,(%a1)+		|	compare a longword
+	CMPML((%a0)+,(%a1)+)		|	compare a longword
 	jne	Lbcnoteq		|	not equal, return non-zero
+#ifdef __mcoldfire__
+	subql	#1,%d0			|	decrement
+	jcc	Lbclloop		|	till done
+#else
 	dbf	%d0,Lbclloop		|	till done
+#endif
 	andl	#3,%d1			|	len %= 4
 	jeq	Lbcdone 
 
 	subql	#1,%d1			| set up for dbf
 Lbcbloop:
-	cmpmb	(%a0)+,(%a1)+		| compare a byte
+	CMPMB((%a0)+,(%a1)+)		| compare a byte
 	jne	Lbcnoteq		| not equal, return non-zero
 Lbcbyte:
+#ifdef __mcoldfire__
+	subql	#1,%d0			|	decrement
+	jcc	Lbcbloop		|	till done
+#else
 	dbf	%d1,Lbcbloop
+#endif
 Lbcdone:
+#ifdef __mcoldfire__
+	movl	(%sp)+,%d2		| restore temp
+#endif
 	movql	#0,%d0
 	rts
 
Index: src/common/lib/libc/arch/m68k/string/bcopy.S
diff -u src/common/lib/libc/arch/m68k/string/bcopy.S:1.4 src/common/lib/libc/arch/m68k/string/bcopy.S:1.5
--- src/common/lib/libc/arch/m68k/string/bcopy.S:1.4	Tue Jul 16 23:24:19 2013
+++ src/common/lib/libc/arch/m68k/string/bcopy.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcopy.S,v 1.4 2013/07/16 23:24:19 matt Exp $	*/
+/*	$NetBSD: bcopy.S,v 1.5 2013/07/18 22:42:50 matt Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 #if 0
 	RCSID("from: @(#)bcopy.s	5.1 (Berkeley) 5/12/90")
 #else
-	RCSID("$NetBSD: bcopy.S,v 1.4 2013/07/16 23:24:19 matt Exp $")
+	RCSID("$NetBSD: bcopy.S,v 1.5 2013/07/18 22:42:50 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -141,8 +141,10 @@ Lbcf32loop:
 	movl	(%a0)+,(%a1)+
 	movl	(%a0)+,(%a1)+
 	movl	(%a0)+,(%a1)+
+#ifndef __mcoldfire__
 	dbf	%d0,Lbcf32loop	|	till done
 	clrw	%d0
+#endif
 	subql	#1,%d0
 	jcc	Lbcf32loop
 
@@ -154,7 +156,12 @@ Lbcflong:
 	subql	#1,%d0		|	set up for dbf
 Lbcflloop:
 	movl	(%a0)+,(%a1)+	|	copy longwords
+#ifdef __mcoldfire__
+	subql	#1,%d0		|	decrement
+	jcc	Lbcflloop	|	til done
+#else
 	dbf	%d0,Lbcflloop	|	til done
+#endif
 	andl	#3,%d1		|	len %= 4
 	jeq	Lbcdone
 
@@ -162,7 +169,12 @@ Lbcflloop:
 Lbcfbloop:
 	movb	(%a0)+,(%a1)+	| copy bytes
 Lbcfbyte:
+#ifdef __mcoldfire__
+	subql	#1,%d0		|	decrement
+	jcc	Lbcfbloop	|	til done
+#else
 	dbf	%d1,Lbcfbloop	| till done
+#endif
 Lbcdone:
 #if defined(MEMCOPY) || defined(MEMMOVE)
 	movl	4(%sp),%d0	| dest address
@@ -224,8 +236,10 @@ Lbcb32loop:
 	movl	-(%a0),-(%a1)
 	movl	-(%a0),-(%a1)
 	movl	-(%a0),-(%a1)
+#ifndef __mcoldfire__
 	dbf	%d0,Lbcb32loop	|	till done
 	clrw	%d0
+#endif
 	subql	#1,%d0
 	jcc	Lbcb32loop
 	
@@ -237,7 +251,12 @@ Lbcblong:
 	subql	#1,%d0		|	set up for dbf
 Lbcblloop:
 	movl	-(%a0),-(%a1)	|	copy longwords
+#ifdef __mcoldfire__
+	subql	#1,%d0		|	decrement
+	jcc	Lbcblloop	|	til done
+#else
 	dbf	%d0,Lbcblloop	|	til done
+#endif
 	andl	#3,%d1		|	len %= 4
 	jeq	Lbcdone
 
@@ -245,7 +264,12 @@ Lbcblloop:
 Lbcbbloop:
 	movb	-(%a0),-(%a1)	| copy bytes
 Lbcbbyte:
+#ifdef __mcoldfire__
+	subql	#1,%d0		| decrement
+	jcc	Lbcbbloop	| til done
+#else
 	dbf	%d1,Lbcbbloop	| till done
+#endif
 
 #if defined(MEMCOPY) || defined(MEMMOVE)
 	movl	4(%sp),%d0	| dest address
Index: src/common/lib/libc/arch/m68k/string/bzero.S
diff -u src/common/lib/libc/arch/m68k/string/bzero.S:1.4 src/common/lib/libc/arch/m68k/string/bzero.S:1.5
--- src/common/lib/libc/arch/m68k/string/bzero.S:1.4	Tue Jul 16 23:24:19 2013
+++ src/common/lib/libc/arch/m68k/string/bzero.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bzero.S,v 1.4 2013/07/16 23:24:19 matt Exp $	*/
+/*	$NetBSD: bzero.S,v 1.5 2013/07/18 22:42:50 matt Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 #if 0
 	RCSID("from: @(#)bzero.s	5.1 (Berkeley) 5/12/90")
 #else
-	RCSID("$NetBSD: bzero.S,v 1.4 2013/07/16 23:24:19 matt Exp $")
+	RCSID("$NetBSD: bzero.S,v 1.5 2013/07/18 22:42:50 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -77,7 +77,7 @@ ENTRY(bzero)
 	movl	8(%sp),%a0		| destination
 	movl	12(%sp),%d1		| count
 
-	movql	#0,%d2
+	clrl	%d2
 
 	/* 
 	 * It isn't worth the overhead of aligning to {long}word boundries
@@ -114,8 +114,10 @@ Lbz32loop:
 	movl	%d2,(%a0)+
 	movl	%d2,(%a0)+
 	movl	%d2,(%a0)+
+#ifndef __mcoldfire__
 	dbf	%d0,Lbz32loop		|	till done
 	clrw	%d0
+#endif
 	subql	#1,%d0
 	jcc	Lbz32loop
 
@@ -127,7 +129,12 @@ Lbzlong:
 	subql	#1,%d0			|	set up for dbf
 Lbzlloop:
 	movl	%d2,(%a0)+		|	clear longwords
+#ifdef __mcoldfire__
+	subql	#1,%d0			|	decrement
+	jcc	Lbzlloop		|	till done
+#else
 	dbf	%d0,Lbzlloop		|	till done
+#endif
 	andl	#3,%d1			|	len %= 4
 	jeq	Lbzdone
 
@@ -135,7 +142,12 @@ Lbzlloop:
 Lbzbloop:
 	movb	%d2,(%a0)+		| zero bytes
 Lbzbyte:
+#ifdef __mcoldfire__
+	subql	#1,%d0			| decrement
+	jcc	Lbzbloop		| till done
+#else
 	dbf	%d1,Lbzbloop		| till done
+#endif
 Lbzdone:
 	movl	(%sp)+,%d2
 	rts
Index: src/common/lib/libc/arch/m68k/string/ffs.S
diff -u src/common/lib/libc/arch/m68k/string/ffs.S:1.4 src/common/lib/libc/arch/m68k/string/ffs.S:1.5
--- src/common/lib/libc/arch/m68k/string/ffs.S:1.4	Tue Jul 16 23:24:19 2013
+++ src/common/lib/libc/arch/m68k/string/ffs.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.S,v 1.4 2013/07/16 23:24:19 matt Exp $	*/
+/*	$NetBSD: ffs.S,v 1.5 2013/07/18 22:42:50 matt Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -39,7 +39,7 @@
 #if 0
 	RCSID("from: @(#)ffs.s	5.1 (Berkeley) 5/12/90")
 #else
-	RCSID("$NetBSD: ffs.S,v 1.4 2013/07/16 23:24:19 matt Exp $")
+	RCSID("$NetBSD: ffs.S,v 1.5 2013/07/18 22:42:50 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -47,7 +47,7 @@
 
 WEAK_ALIAS(__ffssi2,ffs)
 
-#ifndef	__mc68010__
+#if (!defined(__mc68010__) && !defined(__mcoldfire__)) || defined(__mcfisac__)
 
 ENTRY(ffs)
 	movl	4(%sp),%d0
@@ -55,11 +55,28 @@ ENTRY(ffs)
 	negl	%d0
 	andl	%d0,%d1
 	movql	#32,%d0
+#if defined(__mcfisac__)
+	ff1.l	%d1		| count leading zeros
+#else
 	bfffo	%d1{#0:#32},%d1
+#endif
 	subl	%d1,%d0
 	rts
 END(ffs)
 
+#elif defined(__mcoldfire__)
+
+ENTRY(ffs)
+	clrl	%d0
+	movl	4(%sp),%d1
+	jeq	L2		| return 0 if 0
+L1:
+	addql	#1,%d0
+	lsrl	#1,%d1		| shift low bit into carry
+	jcc	L1		| keep looping while carry is clear.
+L2:
+	rts
+
 #else	/* __mc68010__ */
 
 ENTRY(ffs)
Index: src/common/lib/libc/arch/m68k/string/memset.S
diff -u src/common/lib/libc/arch/m68k/string/memset.S:1.4 src/common/lib/libc/arch/m68k/string/memset.S:1.5
--- src/common/lib/libc/arch/m68k/string/memset.S:1.4	Tue Jul 16 23:24:19 2013
+++ src/common/lib/libc/arch/m68k/string/memset.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: memset.S,v 1.4 2013/07/16 23:24:19 matt Exp $	*/
+/*	$NetBSD: memset.S,v 1.5 2013/07/18 22:42:50 matt Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 #if 0
 	RCSID("from: @(#)bzero.s	5.1 (Berkeley) 5/12/90")
 #else
-	RCSID("$NetBSD: memset.S,v 1.4 2013/07/16 23:24:19 matt Exp $")
+	RCSID("$NetBSD: memset.S,v 1.5 2013/07/18 22:42:50 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -76,7 +76,11 @@ ENTRY(memset)
 	movl	%d2,-(%sp)
 	movl	8(%sp),%a0		| destination
 	movl	16(%sp),%d1		| count
-	movb	15(%sp),%d2		| character
+#ifdef __mcoldfire__
+	mvzb	15(%sp),%d2		| zero extend fill character
+#else
+	movb	15(%sp),%d2		| get fill character
+#endif
 
 	/* 
 	 * It isn't worth the overhead of aligning to {long}word boundries
@@ -85,15 +89,15 @@ ENTRY(memset)
 	cmpl	#15,%d1
 	jlt	Lbzbyte
 
-	clrl	%d0			| replicate byte to fill longword
-	movb	%d2,%d0
-	movl	%d0,%d2
-	lsll	#8,%d0
-	orl	%d0,%d2
-	lsll	#8,%d0 
-	orl	%d0,%d2
-	lsll	#8,%d0
-	orl	%d0,%d2
+#ifndef __mcoldfire__
+	andb	0xff,%d2		| clear high bytes
+#endif
+	movl	%d2,%d0
+	lsll	#8,%d0			| shift to 8-15
+	orl	%d0,%d2			| merge so low word is done
+	movl	%d2,%d0 		| copy word
+	swap	%d0			| swap it
+	orl	%d0,%d2			| put it upper half
 
 	/* word align */
 	movl	%a0,%d0
@@ -125,8 +129,10 @@ Lbz32loop:
 	movl	%d2,(%a0)+
 	movl	%d2,(%a0)+
 	movl	%d2,(%a0)+
+#ifndef __mcoldfire__
 	dbf	%d0,Lbz32loop		|	till done
 	clrw	%d0
+#endif
 	subql	#1,%d0
 	jcc	Lbz32loop
 #endif	/* !__mc68010__ */
@@ -139,12 +145,16 @@ Lbzlong:
 	subql	#1,%d0			|	set up for dbf
 Lbzlloop:
 	movl	%d2,(%a0)+		|	clear longwords
+#ifndef __mcoldfire__
 	dbf	%d0,Lbzlloop		|	till done
+#endif
 #ifdef	__mc68010__
 	clrw	%d0
+#endif	/* __mc68010__ */
+#if defined(__m68010) || defined(__mcoldfire__)
 	subql	#1,%d0
 	jcc	Lbzlloop
-#endif	/* __mc68010__ */
+#endif	/* __mc68010__ || __mcoldfire__ */
 	andl	#3,%d1			|	len %= 4
 	jeq	Lbzdone
 
@@ -152,7 +162,12 @@ Lbzlloop:
 Lbzbloop:
 	movb	%d2,(%a0)+		| set bytes
 Lbzbyte:
+#ifdef __mcoldfire__
+	subql	#1,%d1			| decrement
+	jcc	Lbzbloop		| till done
+#else
 	dbf	%d1,Lbzbloop		| till done
+#endif
 Lbzdone:
 	movl	8(%sp),%d0		| return destination
 #ifdef __SVR4_ABI__
Index: src/common/lib/libc/arch/m68k/string/strcmp.S
diff -u src/common/lib/libc/arch/m68k/string/strcmp.S:1.4 src/common/lib/libc/arch/m68k/string/strcmp.S:1.5
--- src/common/lib/libc/arch/m68k/string/strcmp.S:1.4	Tue Jul 16 23:24:19 2013
+++ src/common/lib/libc/arch/m68k/string/strcmp.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: strcmp.S,v 1.4 2013/07/16 23:24:19 matt Exp $	*/
+/*	$NetBSD: strcmp.S,v 1.5 2013/07/18 22:42:50 matt Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -33,36 +33,46 @@
 #include <machine/asm.h>
 
 #if defined(LIBC_SCCS) && !defined(lint)
-	RCSID("$NetBSD: strcmp.S,v 1.4 2013/07/16 23:24:19 matt Exp $")
+	RCSID("$NetBSD: strcmp.S,v 1.5 2013/07/18 22:42:50 matt Exp $")
 #endif /* LIBC_SCCS and not lint */
 
+#ifdef __mcoldfire__
+#define GETC(a,b)	mvsb	a,b
+#define	SUBC(a,b)	mvsb	a,%d0; subl %d0,b
+#else
+#define GETC(a,b)	movb	a,b
+#define	SUBC(a,b)	subb	a,b
+#endif
+
 ENTRY(strcmp)
 	movl	4(%sp),%a0
 	movl	8(%sp),%a1
 L1:				/* unrolled by 4 for 680[23]0's */
-	movb	(%a0)+,%d1
+	GETC((%a0)+,%d1)
 	jeq	L2
-	subb	(%a1)+,%d1
+	SUBC((%a1)+,%d1)
 	jne	L3
 
-	movb	(%a0)+,%d1
+	GETC((%a0)+,%d1)
 	jeq	L2
-	subb	(%a1)+,%d1
+	SUBC((%a1)+,%d1)
 	jne	L3
 
-	movb	(%a0)+,%d1
+	GETC((%a0)+,%d1)
 	jeq	L2
-	subb	(%a1)+,%d1
+	SUBC((%a1)+,%d1)
 	jne	L3
 
-	movb	(%a0)+,%d1
+	GETC((%a0)+,%d1)
 	jeq	L2
-	subb	(%a1)+,%d1
+	SUBC((%a1)+,%d1)
 	jeq	L1
 
-L3:	scs	%d0
-	EXTBL(%d0)
-	movb	%d1,%d0
+L3:
+#ifndef __mcoldfire__
+	EXTBL(%d1)
+#endif
+	movl	%d1,%d0
 	rts
 
 L2:	movq	#0,%d0
Index: src/common/lib/libc/arch/m68k/string/strncmp.S
diff -u src/common/lib/libc/arch/m68k/string/strncmp.S:1.4 src/common/lib/libc/arch/m68k/string/strncmp.S:1.5
--- src/common/lib/libc/arch/m68k/string/strncmp.S:1.4	Tue Jul 16 23:24:19 2013
+++ src/common/lib/libc/arch/m68k/string/strncmp.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: strncmp.S,v 1.4 2013/07/16 23:24:19 matt Exp $	*/
+/*	$NetBSD: strncmp.S,v 1.5 2013/07/18 22:42:50 matt Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -33,47 +33,64 @@
 #include <machine/asm.h>
 
 #if defined(LIBC_SCCS) && !defined(lint)
-	RCSID("$NetBSD: strncmp.S,v 1.4 2013/07/16 23:24:19 matt Exp $")
+	RCSID("$NetBSD: strncmp.S,v 1.5 2013/07/18 22:42:50 matt Exp $")
 #endif /* LIBC_SCCS and not lint */
 
+
+#ifdef __mcoldfire__
+#define GETC(a,b)	mvsb	a,b
+#define	SUBC(a,b)	mvsb	a,%d2; subl %d2,b
+#else
+#define GETC(a,b)	movb	a,b
+#define	SUBC(a,b)	subb	a,b
+#endif
+
 ENTRY(strncmp)
 	movl	12(%sp),%d0
 	jeq	L4
 	movl	4(%sp),%a0
 	movl	8(%sp),%a1
+	movl	%d2,-(%sp)	| save temp
 L1:				/* unroll by 4 for m680[23]0's */
-	movb	(%a0)+,%d1
+	GETC((%a0)+,%d1)
 	jeq	L2
-	subb	(%a1)+,%d1
+	SUBC((%a1)+,%d1)
 	jne	L3
 	subql	#1,%d0
 	jeq	L4
 
-	movb	(%a0)+,%d1
+	GETC((%a0)+,%d1)
 	jeq	L2
-	subb	(%a1)+,%d1
+	SUBC((%a1)+,%d1)
 	jne	L3
 	subql	#1,%d0
 	jeq	L4
 
-	movb	(%a0)+,%d1
+	GETC((%a0)+,%d1)
 	jeq	L2
-	subb	(%a1)+,%d1
+	SUBC((%a1)+,%d1)
 	jne	L3
 	subql	#1,%d0
 	jeq	L4
 
-	movb	(%a0)+,%d1
+	GETC((%a0)+,%d1)
 	jeq	L2
-	subb	(%a1)+,%d1
+	SUBC((%a1)+,%d1)
 	jne	L3
 	subql	#1,%d0
 	jne	L1
+#ifdef __mcoldfire__
+	movl	(%sp)+,%d2		| restore temp
+#endif
 L4:	rts
 
-L2:	subb	(%a1),%d1
-L3:	scs	%d0
-	EXTBL(%d0)
-	movb	%d1,%d0
+L2:	SUBC((%a1),%d1)
+L3:	
+#ifdef __mcoldfire__
+	movl	(%sp)+,%d2		| restore temp
+#else
+	EXTBL(%d1)
+#endif
+	movl	%d1,%d0
 	rts
 END(strncmp)

Index: src/common/lib/libc/arch/m68k/string/memcmp.S
diff -u src/common/lib/libc/arch/m68k/string/memcmp.S:1.3 src/common/lib/libc/arch/m68k/string/memcmp.S:1.4
--- src/common/lib/libc/arch/m68k/string/memcmp.S:1.3	Tue Jul 16 23:24:19 2013
+++ src/common/lib/libc/arch/m68k/string/memcmp.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: memcmp.S,v 1.3 2013/07/16 23:24:19 matt Exp $	*/
+/*	$NetBSD: memcmp.S,v 1.4 2013/07/18 22:42:50 matt Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -39,12 +39,22 @@
 #if 0
 	RCSID("from: @(#)bcmp.s	5.1 (Berkeley) 5/12/90")
 #else
-	RCSID("$NetBSD: memcmp.S,v 1.3 2013/07/16 23:24:19 matt Exp $")
+	RCSID("$NetBSD: memcmp.S,v 1.4 2013/07/18 22:42:50 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
 /* memcmp(s1, s2, n) */
 
+#ifdef __mcoldfire__
+#define	CMPMB(a,b)	movb b,%d2; cmpb a,%d2
+#define	CMPMW(a,b)	movw b,%d2; cmpw a,%d2
+#define	CMPML(a,b)	movl b,%d2; cmpl a,%d2
+#else
+#define	CMPMB(a,b)	cmpmb a,b
+#define	CMPMW(a,b)	cmpmw a,b
+#define	CMPML(a,b)	cmpml a,b
+#endif
+
 /*
  * This is probably not the best we can do, but it is still 2-10 times
  * faster than the C version in the portable gen directory.
@@ -57,11 +67,14 @@ ENTRY(memcmp)
 	movl	4(%sp),%a0		| string 1
 	movl	8(%sp),%a1		| string 2
 	movl	12(%sp),%d0		| length
+#ifdef __mcoldfire__
+	movl	%d2,-(%sp)		| save temp
+#endif
 	jeq	bcdone			| if zero, nothing to do
 	movl	%a0,%d1
 	btst	#0,%d1			| string 1 address odd?
 	jeq	bceven			| no, skip alignment
-	cmpmb	(%a0)+,(%a1)+		| yes, compare a byte
+	CMPMB((%a0)+,(%a1)+)		| yes, compare a byte
 	jne	bcnoteq			| not equal, return non-zero
 	subql	#1,%d0			| adjust count
 	jeq	bcdone			| count 0, reutrn zero
@@ -73,14 +86,14 @@ bceven:
 	lsrl	#2,%d1			| convert count to longword count
 	jeq	bcbloop			| count 0, skip longword loop
 bclloop:
-	cmpml	(%a0)+,(%a1)+		| compare a longword
+	CMPML((%a0)+,(%a1)+)		| compare a longword
 	jne	bcnoteql		| not equal, return non-zero
 	subql	#1,%d1			| adjust count
 	jne	bclloop			| still more, keep comparing
 	andl	#3,%d0			| what remains
 	jeq	bcdone			| nothing, all done
 bcbloop:
-	cmpmb	(%a0)+,(%a1)+		| compare a byte
+	CMPMB((%a0)+,(%a1)+)		| compare a byte
 	jne	bcnoteq			| not equal, return non-zero
 	subql	#1,%d0			| adjust count
 	jne	bcbloop			| still more, keep going
@@ -97,5 +110,8 @@ bcnoteq:
 	movb	-(%a1),%d1
 	subl	%d1,%d0
 bcdone:
+#ifdef __mcoldfire__
+	movl	(%sp)+,%sp		| restore temp
+#endif
 	rts
 END(memcmp)
Index: src/common/lib/libc/arch/m68k/string/strncpy.S
diff -u src/common/lib/libc/arch/m68k/string/strncpy.S:1.3 src/common/lib/libc/arch/m68k/string/strncpy.S:1.4
--- src/common/lib/libc/arch/m68k/string/strncpy.S:1.3	Tue Jul 16 23:24:19 2013
+++ src/common/lib/libc/arch/m68k/string/strncpy.S	Thu Jul 18 22:42:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: strncpy.S,v 1.3 2013/07/16 23:24:19 matt Exp $	*/
+/*	$NetBSD: strncpy.S,v 1.4 2013/07/18 22:42:50 matt Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -39,7 +39,7 @@
 #if 0
 	RCSID("from: @(#)strncpy.s	5.1 (Berkeley) 5/12/90")
 #else
-	RCSID("$NetBSD: strncpy.S,v 1.3 2013/07/16 23:24:19 matt Exp $")
+	RCSID("$NetBSD: strncpy.S,v 1.4 2013/07/18 22:42:50 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -52,9 +52,13 @@ ENTRY(strncpy)
 	subql	#1,%d1
 Lscloop:
 	movb	(%a0)+,(%a1)+		| copy a byte
+#ifndef __mcoldfire__
 	dbeq	%d1,Lscloop		| loop through low word of d1
+#endif
 	jeq	Lscpadding		| copied null, padding if necessary
+#ifndef __mcoldfire__
 	clrw	%d1			| clear low word of d1
+#endif
 	subql	#1,%d1			| adjust count for long copies
 	jcc	Lscloop			| more room, keep going
 Lscdone:
@@ -65,8 +69,10 @@ Lscdone:
 
 Lscploop:
 	clrb	(%a1)+			| clear a byte
+#ifndef __mcoldfire__
 	dbra	%d1,Lscploop		| keep going
 	clrw	%d1
+#endif
 Lscpadding:
 	subql	#1,%d1
 	jcc	Lscploop

Reply via email to