Merge libkern + libc common files. As requested by core. trunk
authorchristos <christos@NetBSD.org>
Tue, 20 Dec 2005 19:28:49 +0000
branchtrunk
changeset 141908 e9a9cdbc5908
parent 141907 2beb4f03fc4b
child 141909 ab1dfcc09b67
Merge libkern + libc common files. As requested by core.
common/lib/libc/Makefile.inc
common/lib/libc/arch/alpha/gen/byte_swap_2.S
common/lib/libc/arch/alpha/gen/byte_swap_4.S
common/lib/libc/arch/alpha/gmon/_mcount.S
common/lib/libc/arch/alpha/string/bcopy.S
common/lib/libc/arch/alpha/string/bzero.S
common/lib/libc/arch/alpha/string/ffs.S
common/lib/libc/arch/alpha/string/memcpy.S
common/lib/libc/arch/alpha/string/memmove.S
common/lib/libc/arch/arm/gen/byte_swap_2.S
common/lib/libc/arch/arm/gen/byte_swap_4.S
common/lib/libc/arch/arm/gen/divsi3.S
common/lib/libc/arch/arm/string/ffs.S
common/lib/libc/arch/arm/string/memcmp.S
common/lib/libc/arch/arm/string/memcpy.S
common/lib/libc/arch/arm/string/memcpy_arm.S
common/lib/libc/arch/arm/string/memcpy_xscale.S
common/lib/libc/arch/arm/string/memmove.S
common/lib/libc/arch/arm/string/memset.S
common/lib/libc/arch/arm/string/strcmp.S
common/lib/libc/arch/arm/string/strncmp.S
common/lib/libc/arch/i386/gen/byte_swap_2.S
common/lib/libc/arch/i386/gen/byte_swap_4.S
common/lib/libc/arch/i386/string/ffs.S
common/lib/libc/arch/i386/string/memchr.S
common/lib/libc/arch/i386/string/memcmp.S
common/lib/libc/arch/i386/string/memcpy.S
common/lib/libc/arch/i386/string/memmove.S
common/lib/libc/arch/i386/string/memset.S
common/lib/libc/arch/i386/string/strcat.S
common/lib/libc/arch/i386/string/strchr.S
common/lib/libc/arch/i386/string/strcmp.S
common/lib/libc/arch/i386/string/strcpy.S
common/lib/libc/arch/i386/string/strlen.S
common/lib/libc/arch/i386/string/strrchr.S
common/lib/libc/arch/m68k/gen/bswap16.S
common/lib/libc/arch/m68k/gen/bswap32.S
common/lib/libc/arch/m68k/gen/bswap64.S
common/lib/libc/arch/m68k/gen/divsi3.S
common/lib/libc/arch/m68k/gen/modsi3.S
common/lib/libc/arch/m68k/gen/mulsi3.S
common/lib/libc/arch/m68k/gen/udivsi3.S
common/lib/libc/arch/m68k/gen/umodsi3.S
common/lib/libc/arch/m68k/net/htonl.S
common/lib/libc/arch/m68k/net/htons.S
common/lib/libc/arch/m68k/net/ntohl.S
common/lib/libc/arch/m68k/net/ntohs.S
common/lib/libc/arch/m68k/string/bcmp.S
common/lib/libc/arch/m68k/string/bcopy.S
common/lib/libc/arch/m68k/string/bzero.S
common/lib/libc/arch/m68k/string/ffs.S
common/lib/libc/arch/m68k/string/index.S
common/lib/libc/arch/m68k/string/memcmp.S
common/lib/libc/arch/m68k/string/memcpy.S
common/lib/libc/arch/m68k/string/memmove.S
common/lib/libc/arch/m68k/string/memset.S
common/lib/libc/arch/m68k/string/rindex.S
common/lib/libc/arch/m68k/string/strcat.S
common/lib/libc/arch/m68k/string/strchr.S
common/lib/libc/arch/m68k/string/strcmp.S
common/lib/libc/arch/m68k/string/strcpy.S
common/lib/libc/arch/m68k/string/strlen.S
common/lib/libc/arch/m68k/string/strncmp.S
common/lib/libc/arch/m68k/string/strncpy.S
common/lib/libc/arch/m68k/string/strrchr.S
common/lib/libc/arch/mips/gen/byte_swap_2.S
common/lib/libc/arch/mips/gen/byte_swap_4.S
common/lib/libc/arch/mips/string/ffs.S
common/lib/libc/arch/mips/string/memcpy.S
common/lib/libc/arch/mips/string/memmove.S
common/lib/libc/arch/mips/string/memset.S
common/lib/libc/arch/mips/string/strcmp.S
common/lib/libc/arch/mips/string/strlen.S
common/lib/libc/arch/ns32k/gen/byte_swap_2.S
common/lib/libc/arch/ns32k/gen/byte_swap_4.S
common/lib/libc/arch/ns32k/string/bcmp.S
common/lib/libc/arch/ns32k/string/bcopy.S
common/lib/libc/arch/ns32k/string/bzero.S
common/lib/libc/arch/ns32k/string/ffs.S
common/lib/libc/arch/ns32k/string/memchr.S
common/lib/libc/arch/ns32k/string/memcmp.S
common/lib/libc/arch/ns32k/string/memcpy.S
common/lib/libc/arch/ns32k/string/memmove.S
common/lib/libc/arch/ns32k/string/memset.S
common/lib/libc/arch/ns32k/string/strcat.S
common/lib/libc/arch/ns32k/string/strchr.S
common/lib/libc/arch/ns32k/string/strcmp.S
common/lib/libc/arch/ns32k/string/strcpy.S
common/lib/libc/arch/ns32k/string/strlen.S
common/lib/libc/arch/ns32k/string/strncmp.S
common/lib/libc/arch/ns32k/string/strncpy.S
common/lib/libc/arch/ns32k/string/strrchr.S
common/lib/libc/arch/powerpc/string/ffs.S
common/lib/libc/arch/powerpc/string/strlen.S
common/lib/libc/arch/sh3/gen/ashiftrt.S
common/lib/libc/arch/sh3/gen/ashlsi3.S
common/lib/libc/arch/sh3/gen/ashrsi3.S
common/lib/libc/arch/sh3/gen/lshrsi3.S
common/lib/libc/arch/sh3/gen/movstr.S
common/lib/libc/arch/sh3/gen/movstrSI.S
common/lib/libc/arch/sh3/gen/movstr_i4.S
common/lib/libc/arch/sh3/gen/mulsi3.S
common/lib/libc/arch/sh3/gen/sdivsi3.S
common/lib/libc/arch/sh3/gen/udivsi3.S
common/lib/libc/arch/sh3/string/ffs.S
common/lib/libc/arch/sh3/string/memcpy.S
common/lib/libc/arch/sh3/string/memmove.S
common/lib/libc/arch/sh3/string/memset.S
common/lib/libc/arch/sh5/string/memcpy.S
common/lib/libc/arch/sh5/string/memset.S
common/lib/libc/arch/sh5/string/strcasecmp.S
common/lib/libc/arch/sh5/string/strcat.S
common/lib/libc/arch/sh5/string/strchr.S
common/lib/libc/arch/sh5/string/strcmp.S
common/lib/libc/arch/sh5/string/strcpy.S
common/lib/libc/arch/sh5/string/strlen.S
common/lib/libc/arch/sh5/string/strncasecmp.S
common/lib/libc/arch/sh5/string/strncmp.S
common/lib/libc/arch/sh5/string/strncpy.S
common/lib/libc/arch/sh5/string/strrchr.S
common/lib/libc/arch/sparc/gen/mul.S
common/lib/libc/arch/sparc/gen/saveregs.S
common/lib/libc/arch/sparc/gen/umul.S
common/lib/libc/arch/sparc/net/htonl.S
common/lib/libc/arch/sparc/net/htons.S
common/lib/libc/arch/sparc/net/ntohl.S
common/lib/libc/arch/sparc/net/ntohs.S
common/lib/libc/arch/sparc/string/bzero.S
common/lib/libc/arch/sparc/string/ffs.S
common/lib/libc/arch/sparc/string/memset.S
common/lib/libc/arch/sparc/string/strlen.S
common/lib/libc/arch/sparc64/gen/mul.S
common/lib/libc/arch/sparc64/gen/saveregs.S
common/lib/libc/arch/sparc64/gen/umul.S
common/lib/libc/arch/sparc64/net/htonl.S
common/lib/libc/arch/sparc64/net/htons.S
common/lib/libc/arch/sparc64/net/ntohl.S
common/lib/libc/arch/sparc64/net/ntohs.S
common/lib/libc/arch/sparc64/string/ffs.S
common/lib/libc/arch/sparc64/string/strlen.S
common/lib/libc/arch/vax/gen/bswap64.S
common/lib/libc/arch/vax/gen/udiv.S
common/lib/libc/arch/vax/gen/urem.S
common/lib/libc/arch/vax/string/memcpy.S
common/lib/libc/arch/vax/string/memmove.S
common/lib/libc/arch/x86_64/gen/byte_swap_2.S
common/lib/libc/arch/x86_64/gen/byte_swap_4.S
common/lib/libc/arch/x86_64/string/bcmp.S
common/lib/libc/arch/x86_64/string/bcopy.S
common/lib/libc/arch/x86_64/string/bzero.S
common/lib/libc/arch/x86_64/string/ffs.S
common/lib/libc/arch/x86_64/string/index.S
common/lib/libc/arch/x86_64/string/memchr.S
common/lib/libc/arch/x86_64/string/memcmp.S
common/lib/libc/arch/x86_64/string/memcpy.S
common/lib/libc/arch/x86_64/string/memmove.S
common/lib/libc/arch/x86_64/string/memset.S
common/lib/libc/arch/x86_64/string/rindex.S
common/lib/libc/arch/x86_64/string/strcat.S
common/lib/libc/arch/x86_64/string/strchr.S
common/lib/libc/arch/x86_64/string/strcmp.S
common/lib/libc/arch/x86_64/string/strcpy.S
common/lib/libc/arch/x86_64/string/strlen.S
common/lib/libc/arch/x86_64/string/strrchr.S
common/lib/libc/gen/bswap16.c
common/lib/libc/gen/bswap32.c
common/lib/libc/gen/bswap64.c
common/lib/libc/gmon/mcount.c
common/lib/libc/inet/inet_addr.c
common/lib/libc/md/md4c.c
common/lib/libc/md/md5c.c
common/lib/libc/net/__cmsg_alignbytes.c
common/lib/libc/net/htonl.c
common/lib/libc/net/htons.c
common/lib/libc/net/ntohl.c
common/lib/libc/net/ntohs.c
common/lib/libc/quad/adddi3.c
common/lib/libc/quad/anddi3.c
common/lib/libc/quad/ashldi3.c
common/lib/libc/quad/ashrdi3.c
common/lib/libc/quad/cmpdi2.c
common/lib/libc/quad/divdi3.c
common/lib/libc/quad/iordi3.c
common/lib/libc/quad/lshldi3.c
common/lib/libc/quad/lshrdi3.c
common/lib/libc/quad/moddi3.c
common/lib/libc/quad/muldi3.c
common/lib/libc/quad/negdi2.c
common/lib/libc/quad/notdi2.c
common/lib/libc/quad/qdivrem.c
common/lib/libc/quad/subdi3.c
common/lib/libc/quad/ucmpdi2.c
common/lib/libc/quad/udivdi3.c
common/lib/libc/quad/umoddi3.c
common/lib/libc/quad/xordi3.c
common/lib/libc/stdlib/random.c
common/lib/libc/stdlib/strtoul.c
common/lib/libc/string/bcmp.c
common/lib/libc/string/bcopy.c
common/lib/libc/string/bzero.c
common/lib/libc/string/ffs.c
common/lib/libc/string/memchr.c
common/lib/libc/string/memcmp.c
common/lib/libc/string/memcpy.c
common/lib/libc/string/memmove.c
common/lib/libc/string/memset.c
common/lib/libc/string/strcasecmp.c
common/lib/libc/string/strcat.c
common/lib/libc/string/strchr.c
common/lib/libc/string/strcmp.c
common/lib/libc/string/strcpy.c
common/lib/libc/string/strlcat.c
common/lib/libc/string/strlcpy.c
common/lib/libc/string/strlen.c
common/lib/libc/string/strncasecmp.c
common/lib/libc/string/strncmp.c
common/lib/libc/string/strncpy.c
common/lib/libc/string/strrchr.c
common/lib/libc/string/strstr.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/Makefile.inc	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,27 @@
+# $NetBSD: Makefile.inc,v 1.1 2005/12/20 19:28:49 christos Exp $
+
+COMMON_DIR:=${.PARSEDIR}
+COMMON_CODEDIRS=gen gmon hash/sha1 inet md net quad stdlib string
+
+.if exists(${COMMON_DIR}/arch/${MACHINE_ARCH})
+COMMON_ARCHSUBDIR=     ${MACHINE_ARCH}
+.elif exists(${COMMON_DIR}/arch/${MACHINE_CPU})
+COMMON_ARCHSUBDIR=     ${MACHINE_CPU}
+.else
+.BEGIN:
+        @echo no COMMON_ARCHSUBDIR for ${MACHINE_ARCH} nor ${MACHINE_CPU}
+	@false
+.endif    
+
+COMMON_ARCHDIR=${COMMON_DIR}/arch/${COMMON_ARCHSUBDIR}
+
+.for i in ${COMMON_CODEDIRS}
+.if exists(${COMMON_DIR}/$i)
+.PATH.c: ${COMMON_DIR}/$i
+.endif
+.if exists(${COMMON_ARCHDIR}/$i)
+.PATH.S: ${COMMON_ARCHDIR}/$i
+.endif
+.endfor
+
+CPPFLAGS+=-I${COMMON_DIR}/quad -I${COMMON_ARCHDIR}/string
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/alpha/gen/byte_swap_2.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,44 @@
+/* $NetBSD: byte_swap_2.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+
+/*
+ * Copyright (c) 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * Byte-swap a 2-byte quantity.  (Convert 0x0123 to 0x2301.)
+ *
+ * Argument is an unsigned 2-byte integer (u_int16_t).
+ */
+LEAF(__bswap16, 1)		/* a0 contains 0x0123 */
+XLEAF(htons, 1)
+XLEAF(ntohs, 1)
+	insbl	a0, 1, t0	/* t0 = 0x23   */
+	extbl	a0, 1, t1	/* t1 = 0x  01 */
+	or	t0, t1, v0	/* v0 = 0x2301 */
+	RET
+END(__bswap16)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/alpha/gen/byte_swap_4.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,50 @@
+/* $NetBSD: byte_swap_4.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+
+/*
+ * Copyright (c) 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * Byte-swap a 4-byte quantity.  (Convert 0x01234567 to 0x67452301.)
+ *
+ * Argument is an unsigned 4-byte integer (u_int32_t).
+ */
+LEAF(__bswap32, 1)		/* a0 contains 0x01234567 */
+XLEAF(htonl, 1)
+XLEAF(ntohl, 1)
+	insbl	a0, 3, t0	/* t0 = 0x67       */
+	extbl	a0, 1, t1	/* t1 = 0x      45 */
+	extbl	a0, 2, t2	/* t2 = 0x      23 */
+	extbl	a0, 3, t3	/* t3 = 0x      01 */
+	sll	t1, 16, t1	/* t1 = 0x  45     */
+	sll	t2, 8, t2	/* t2 = 0x    23   */
+	or	t3, t0, v0	/* v0 = 0x67    01 */
+	or	t1, t2, t1	/* t1 = 0x  4523   */
+	or	t1, v0, v0	/* v0 = 0x67452301 */
+	RET
+END(__bswap32)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/alpha/gmon/_mcount.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,125 @@
+/* $NetBSD: _mcount.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ * 
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ * 
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ * 
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <machine/asm.h>
+#include <machine/profile.h>
+
+#define	OFFSET_AT	(0 * 8)
+#define OFFSET_V0	(1 * 8)
+#define OFFSET_T0	(2 * 8)
+#define OFFSET_T1	(3 * 8)
+#define OFFSET_T2	(4 * 8)
+#define OFFSET_T3	(5 * 8)
+#define OFFSET_T4	(6 * 8)
+#define OFFSET_T5	(7 * 8)
+#define OFFSET_T6	(8 * 8)
+#define OFFSET_T7	(9 * 8)
+#define OFFSET_S6	(10 * 8)
+#define OFFSET_A0	(11 * 8)
+#define OFFSET_A1	(12 * 8)
+#define OFFSET_A2	(13 * 8)
+#define OFFSET_A3	(14 * 8)
+#define OFFSET_A4	(15 * 8)
+#define OFFSET_A5	(16 * 8)
+#define OFFSET_T8	(17 * 8)
+#define OFFSET_T9	(18 * 8)
+#define OFFSET_T10	(19 * 8)
+#define OFFSET_T11	(20 * 8)
+#define OFFSET_RA	(21 * 8)
+#define OFFSET_T12	(22 * 8)
+#define OFFSET_GP	(23 * 8)
+#define	FRAME_SIZE	(24 * 8)
+
+LEAF_NOPROFILE(_mcount,0)		/* XXX */
+	.set noat
+	.set noreorder
+
+	lda	sp, -FRAME_SIZE(sp)
+
+	stq	at_reg, OFFSET_AT(sp)
+	stq	v0, OFFSET_V0(sp)
+	stq	t0, OFFSET_T0(sp)
+	stq	t1, OFFSET_T1(sp)
+	stq	t2, OFFSET_T2(sp)
+	stq	t3, OFFSET_T3(sp)
+	stq	t4, OFFSET_T4(sp)
+	stq	t5, OFFSET_T5(sp)
+	stq	t6, OFFSET_T6(sp)
+	stq	t7, OFFSET_T7(sp)
+	stq	s6, OFFSET_S6(sp)	/* XXX because run _after_ prologue. */
+	stq	a0, OFFSET_A0(sp)
+	stq	a1, OFFSET_A1(sp)
+	stq	a2, OFFSET_A2(sp)
+	stq	a3, OFFSET_A3(sp)
+	stq	a4, OFFSET_A4(sp)
+	stq	a5, OFFSET_A5(sp)
+	stq	t8, OFFSET_T8(sp)
+	stq	t9, OFFSET_T9(sp)
+	stq	t10, OFFSET_T10(sp)
+	stq	t11, OFFSET_T11(sp)
+	stq	ra, OFFSET_RA(sp)
+	stq	t12, OFFSET_T12(sp)
+	stq	gp, OFFSET_GP(sp)
+
+	br	pv, 1f
+1:	LDGP(pv)
+	mov	ra, a0
+	mov	at_reg, a1
+	CALL(_MCOUNT_FUNC)
+
+	ldq	v0, OFFSET_V0(sp)
+	ldq	t0, OFFSET_T0(sp)
+	ldq	t1, OFFSET_T1(sp)
+	ldq	t2, OFFSET_T2(sp)
+	ldq	t3, OFFSET_T3(sp)
+	ldq	t4, OFFSET_T4(sp)
+	ldq	t5, OFFSET_T5(sp)
+	ldq	t6, OFFSET_T6(sp)
+	ldq	t7, OFFSET_T7(sp)
+	ldq	s6, OFFSET_S6(sp)	/* XXX because run _after_ prologue. */
+	ldq	a0, OFFSET_A0(sp)
+	ldq	a1, OFFSET_A1(sp)
+	ldq	a2, OFFSET_A2(sp)
+	ldq	a3, OFFSET_A3(sp)
+	ldq	a4, OFFSET_A4(sp)
+	ldq	a5, OFFSET_A5(sp)
+	ldq	t8, OFFSET_T8(sp)
+	ldq	t9, OFFSET_T9(sp)
+	ldq	t10, OFFSET_T10(sp)
+	ldq	t11, OFFSET_T11(sp)
+	ldq	ra, OFFSET_RA(sp)
+	ldq	t12, OFFSET_T12(sp)
+	ldq	gp, OFFSET_GP(sp)
+
+	ldq	at_reg, OFFSET_AT(sp)
+
+	lda	sp, FRAME_SIZE(sp)
+	ret	zero, (at_reg), 1
+
+	END(_mcount)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/alpha/string/bcopy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,288 @@
+/* $NetBSD: bcopy.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+
+/*
+ * Copyright (c) 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Trevor Blackwell.  Support for use as memcpy() and memmove()
+ *	   added by Chris Demetriou.
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <machine/asm.h>
+
+#if defined(MEMCOPY) || defined(MEMMOVE)
+#ifdef MEMCOPY
+#define	FUNCTION	memcpy
+#else
+#define FUNCTION	memmove
+#endif
+#define	SRCREG		a1
+#define	DSTREG		a0
+#else /* !(defined(MEMCOPY) || defined(MEMMOVE)) */
+#define	FUNCTION	bcopy
+#define	SRCREG		a0
+#define	DSTREG		a1
+#endif /* !(defined(MEMCOPY) || defined(MEMMOVE)) */
+
+#define	SIZEREG		a2
+
+/*
+ * Copy bytes.
+ *
+ * void bcopy(char *from, char *to, size_t len);
+ * char *memcpy(void *to, const void *from, size_t len);
+ * char *memmove(void *to, const void *from, size_t len);
+ *
+ * No matter how invoked, the source and destination registers
+ * for calculation.  There's no point in copying them to "working"
+ * registers, since the code uses their values "in place," and
+ * copying them would be slower.
+ */
+
+LEAF(FUNCTION,3)
+
+#if defined(MEMCOPY) || defined(MEMMOVE)
+	/* set up return value, while we still can */
+	mov	DSTREG,v0
+#endif
+
+	/* Check for negative length */
+	ble	SIZEREG,bcopy_done
+
+	/* Check for overlap */
+	subq	DSTREG,SRCREG,t5
+	cmpult	t5,SIZEREG,t5
+	bne	t5,bcopy_overlap
+
+	/* a3 = end address */
+	addq	SRCREG,SIZEREG,a3
+
+	/* Get the first word */
+	ldq_u	t2,0(SRCREG)
+
+	/* Do they have the same alignment? */
+	xor	SRCREG,DSTREG,t0
+	and	t0,7,t0
+	and	DSTREG,7,t1
+	bne	t0,bcopy_different_alignment
+
+	/* src & dst have same alignment */
+	beq	t1,bcopy_all_aligned
+
+	ldq_u	t3,0(DSTREG)
+	addq	SIZEREG,t1,SIZEREG
+	mskqh	t2,SRCREG,t2
+	mskql	t3,SRCREG,t3
+	or	t2,t3,t2
+
+	/* Dst is 8-byte aligned */
+
+bcopy_all_aligned:
+	/* If less than 8 bytes,skip loop */
+	subq	SIZEREG,1,t0
+	and	SIZEREG,7,SIZEREG
+	bic	t0,7,t0
+	beq	t0,bcopy_samealign_lp_end
+
+bcopy_samealign_lp:
+	stq_u	t2,0(DSTREG)
+	addq	DSTREG,8,DSTREG
+	ldq_u	t2,8(SRCREG)
+	subq	t0,8,t0
+	addq	SRCREG,8,SRCREG
+	bne	t0,bcopy_samealign_lp
+
+bcopy_samealign_lp_end:
+	/* If we're done, exit */
+	bne	SIZEREG,bcopy_small_left
+	stq_u	t2,0(DSTREG)
+	RET
+
+bcopy_small_left:
+	mskql	t2,SIZEREG,t4
+	ldq_u	t3,0(DSTREG)
+	mskqh	t3,SIZEREG,t3
+	or	t4,t3,t4
+	stq_u	t4,0(DSTREG)
+	RET
+
+bcopy_different_alignment:
+	/*
+	 * this is the fun part
+	 */
+	addq	SRCREG,SIZEREG,a3
+	cmpule	SIZEREG,8,t0
+	bne	t0,bcopy_da_finish
+
+	beq	t1,bcopy_da_noentry
+
+	/* Do the initial partial word */
+	subq	zero,DSTREG,t0
+	and	t0,7,t0
+	ldq_u	t3,7(SRCREG)
+	extql	t2,SRCREG,t2
+	extqh	t3,SRCREG,t3
+	or	t2,t3,t5
+	insql	t5,DSTREG,t5
+	ldq_u	t6,0(DSTREG)
+	mskql	t6,DSTREG,t6
+	or	t5,t6,t5
+	stq_u	t5,0(DSTREG)
+	addq	SRCREG,t0,SRCREG
+	addq	DSTREG,t0,DSTREG
+	subq	SIZEREG,t0,SIZEREG
+	ldq_u	t2,0(SRCREG)
+
+bcopy_da_noentry:
+	subq	SIZEREG,1,t0
+	bic	t0,7,t0
+	and	SIZEREG,7,SIZEREG
+	beq	t0,bcopy_da_finish2
+
+bcopy_da_lp:
+	ldq_u	t3,7(SRCREG)
+	addq	SRCREG,8,SRCREG
+	extql	t2,SRCREG,t4
+	extqh	t3,SRCREG,t5
+	subq	t0,8,t0
+	or	t4,t5,t5
+	stq	t5,0(DSTREG)
+	addq	DSTREG,8,DSTREG
+	beq	t0,bcopy_da_finish1
+	ldq_u	t2,7(SRCREG)
+	addq	SRCREG,8,SRCREG
+	extql	t3,SRCREG,t4
+	extqh	t2,SRCREG,t5
+	subq	t0,8,t0
+	or	t4,t5,t5
+	stq	t5,0(DSTREG)
+	addq	DSTREG,8,DSTREG
+	bne	t0,bcopy_da_lp
+
+bcopy_da_finish2:
+	/* Do the last new word */
+	mov	t2,t3
+
+bcopy_da_finish1:
+	/* Do the last partial word */
+	ldq_u	t2,-1(a3)
+	extql	t3,SRCREG,t3
+	extqh	t2,SRCREG,t2
+	or	t2,t3,t2
+	br	zero,bcopy_samealign_lp_end
+
+bcopy_da_finish:
+	/* Do the last word in the next source word */
+	ldq_u	t3,-1(a3)
+	extql	t2,SRCREG,t2
+	extqh	t3,SRCREG,t3
+	or	t2,t3,t2
+	insqh	t2,DSTREG,t3
+	insql	t2,DSTREG,t2
+	lda	t4,-1(zero)
+	mskql	t4,SIZEREG,t5
+	cmovne	t5,t5,t4
+	insqh	t4,DSTREG,t5
+	insql	t4,DSTREG,t4
+	addq	DSTREG,SIZEREG,a4
+	ldq_u	t6,0(DSTREG)
+	ldq_u	t7,-1(a4)
+	bic	t6,t4,t6
+	bic	t7,t5,t7
+	and	t2,t4,t2
+	and	t3,t5,t3
+	or	t2,t6,t2
+	or	t3,t7,t3
+	stq_u	t3,-1(a4)
+	stq_u	t2,0(DSTREG)
+	RET
+
+bcopy_overlap:
+	/*
+	 * Basically equivalent to previous case, only backwards.
+	 * Not quite as highly optimized
+	 */
+	addq	SRCREG,SIZEREG,a3
+	addq	DSTREG,SIZEREG,a4
+
+	/* less than 8 bytes - don't worry about overlap */
+	cmpule	SIZEREG,8,t0
+	bne	t0,bcopy_ov_short
+
+	/* Possibly do a partial first word */
+	and	a4,7,t4
+	beq	t4,bcopy_ov_nostart2
+	subq	a3,t4,a3
+	subq	a4,t4,a4
+	ldq_u	t1,0(a3)
+	subq	SIZEREG,t4,SIZEREG
+	ldq_u	t2,7(a3)
+	ldq	t3,0(a4)
+	extql	t1,a3,t1
+	extqh	t2,a3,t2
+	or	t1,t2,t1
+	mskqh	t3,t4,t3
+	mskql	t1,t4,t1
+	or	t1,t3,t1
+	stq	t1,0(a4)
+
+bcopy_ov_nostart2:
+	bic	SIZEREG,7,t4
+	and	SIZEREG,7,SIZEREG
+	beq	t4,bcopy_ov_lp_end
+
+bcopy_ov_lp:
+	/* This could be more pipelined, but it doesn't seem worth it */
+	ldq_u	t0,-8(a3)
+	subq	a4,8,a4
+	ldq_u	t1,-1(a3)
+	subq	a3,8,a3
+	extql	t0,a3,t0
+	extqh	t1,a3,t1
+	subq	t4,8,t4
+	or	t0,t1,t0
+	stq	t0,0(a4)
+	bne	t4,bcopy_ov_lp
+
+bcopy_ov_lp_end:
+	beq	SIZEREG,bcopy_done
+
+	ldq_u	t0,0(SRCREG)
+	ldq_u	t1,7(SRCREG)
+	ldq_u	t2,0(DSTREG)
+	extql	t0,SRCREG,t0
+	extqh	t1,SRCREG,t1
+	or	t0,t1,t0
+	insql	t0,DSTREG,t0
+	mskql	t2,DSTREG,t2
+	or	t2,t0,t2
+	stq_u	t2,0(DSTREG)
+
+bcopy_done:
+	RET
+
+bcopy_ov_short:
+	ldq_u	t2,0(SRCREG)
+	br	zero,bcopy_da_finish
+
+	END(FUNCTION)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/alpha/string/bzero.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,110 @@
+/*	$NetBSD: bzero.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*
+ * Copyright (c) 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Trevor Blackwell
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <machine/asm.h>
+
+LEAF(bzero,2)
+	ble	a1,bzero_done
+	bic	a1,63,t3	/* t3 is # bytes to do 64 bytes at a time */
+
+	/* If nothing in first word, ignore it */
+	subq	zero,a0,t0
+	and	t0,7,t0		/* t0 = (0-size)%8 */
+	beq	t0,bzero_nostart1
+
+	cmpult	a1,t0,t1	/* if size > size%8 goto noshort */
+	beq	t1,bzero_noshort
+
+	/*
+	 * The whole thing is less than a word.
+	 * Mask off 1..7 bytes, and finish.
+	 */
+	ldq_u	t2,0(a0)
+	lda	t0,-1(zero)	/* t0=-1 */
+	mskql	t0,a1,t0	/* Get ff in bytes (a0%8)..((a0+a1-1)%8) */
+	insql	t0,a0,t0
+	bic	t2,t0,t2	/* zero those bytes in word */
+	stq_u	t2,0(a0)
+	RET
+
+bzero_noshort:
+	/* Handle the first partial word */
+	ldq_u	t2,0(a0)
+	subq	a1,t0,a1
+	mskql	t2,a0,t2	/* zero bytes (a0%8)..7 in word */
+	stq_u	t2,0(a0)
+
+	addq	a0,t0,a0	/* round a0 up to next word */
+	bic	a1,63,t3	/* recalc t3 (# bytes to do 64 bytes at a
+				   time) */
+
+bzero_nostart1:
+	/*
+	 * Loop, zeroing 64 bytes at a time
+	 */
+	beq	t3,bzero_lp_done
+bzero_lp:
+	stq	zero,0(a0)
+	stq	zero,8(a0)
+	stq	zero,16(a0)
+	stq	zero,24(a0)
+	subq	t3,64,t3
+	stq	zero,32(a0)
+	stq	zero,40(a0)
+	stq	zero,48(a0)
+	stq	zero,56(a0)
+	addq	a0,64,a0
+	bne	t3,bzero_lp
+
+bzero_lp_done:
+	/*
+	 * Handle the last 0..7 words.
+	 * We mask off the low bits, so we don't need an extra
+	 * compare instruction for the loop (just a bne. heh-heh)
+	 */
+	and	a1,0x38,t4
+	beq	t4,bzero_finish_lp_done
+bzero_finish_lp:
+	stq	zero,0(a0)
+	subq	t4,8,t4
+	addq	a0,8,a0
+	bne	t4,bzero_finish_lp
+
+	/* Do the last partial word */
+bzero_finish_lp_done:
+	and	a1,7,t5		/* 0..7 bytes left */
+	beq	t5,bzero_done	/* mskqh won't change t0 if t5==0, but I
+				   don't want to touch, say, a new VM page */
+	ldq	t0,0(a0)
+	mskqh	t0,t5,t0
+	stq	t0,0(a0)
+bzero_done:
+	RET
+
+	END(bzero)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/alpha/string/ffs.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,94 @@
+/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+
+/*
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *          This product includes software developed for the
+ *          NetBSD Project.  See http://www.NetBSD.org/ for
+ *          information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
+ */
+
+#include <machine/asm.h>
+
+LEAF(ffs, 1)
+	addl	a0, 0, t0
+	beq	t0, Lallzero
+
+	/*
+	 * Initialize return value (v0), and set up t1 so that it
+	 * contains the mask with only the lowest bit set.
+	 */
+	subl	zero, t0, t1
+	ldil	v0, 1
+	and	t0, t1, t1
+
+	and	t1, 0xff, t2
+	bne	t2, Ldo8
+
+	/*
+	 * If lower 16 bits empty, add 16 to result and use upper 16.
+	 */
+	zapnot	t1, 0x03, t3
+	bne	t3, Ldo16
+	sra	t1, 16, t1
+	addl	v0, 16, v0
+
+Ldo16:
+	/*
+	 * If lower 8 bits empty, add 8 to result and use upper 8.
+	 */
+	and	t1, 0xff, t4
+	bne	t4, Ldo8
+	sra	t1, 8, t1
+	addl	v0, 8, v0
+
+Ldo8:
+	and	t1, 0x0f, t5		/* lower 4 of 8 empty? */
+	and	t1, 0x33, t6		/* lower 2 of each 4 empty? */
+	and	t1, 0x55, t7		/* lower 1 of each 2 empty? */
+
+	/* If lower 4 bits empty, add 4 to result. */
+	bne	t5, Ldo4
+	addl	v0, 4, v0
+
+Ldo4:	/* If lower 2 bits of each 4 empty, add 2 to result. */
+	bne	t6, Ldo2
+	addl	v0, 2, v0
+
+Ldo2:	/* If lower bit of each 2 empty, add 1 to result. */
+	bne	t7, Ldone
+	addl	v0, 1, v0
+
+Ldone:
+	RET
+
+Lallzero:
+	bis	zero, zero, v0
+	RET
+END(ffs)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/alpha/string/memcpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+#define MEMCOPY
+#include "bcopy.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/alpha/string/memmove.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: memmove.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+#define MEMMOVE
+#include "bcopy.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/gen/byte_swap_2.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,48 @@
+/*	$NetBSD: byte_swap_2.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+_ENTRY(_C_LABEL(__bswap16))
+_ENTRY(_C_LABEL(ntohs))
+_ENTRY(_C_LABEL(htons))
+_PROF_PROLOGUE
+	and		r1, r0, #0xff
+	mov		r0, r0, lsr #8
+	orr		r0, r0, r1, lsl #8
+	RET
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/gen/byte_swap_4.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,49 @@
+/*	$NetBSD: byte_swap_4.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Neil A. Carson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+_ENTRY(_C_LABEL(__bswap32))
+_ENTRY(_C_LABEL(ntohl))
+_ENTRY(_C_LABEL(htonl))
+_PROF_PROLOGUE
+	eor		r1, r0, r0, ror #16
+	bic		r1, r1, #0x00FF0000
+	mov		r0, r0, ror #8
+	eor		r0, r0, r1, lsr #8
+	RET
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/gen/divsi3.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,386 @@
+/*	$NetBSD: divsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+/* 
+ * stack is aligned as there's a possibility of branching to .L_overflow
+ * which makes a C call
+ */
+
+ENTRY(__umodsi3)
+	stmfd	sp!, {lr}
+	sub	sp, sp, #4	/* align stack */
+	bl	.L_udivide
+	add	sp, sp, #4	/* unalign stack */
+	mov	r0, r1
+	ldmfd	sp!, {pc}
+
+ENTRY(__modsi3)
+	stmfd	sp!, {lr}
+	sub	sp, sp, #4	/* align stack */
+	bl	.L_divide
+	add	sp, sp, #4	/* unalign stack */
+	mov	r0, r1
+	ldmfd	sp!, {pc}
+
+.L_overflow:
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+	mov	r0, #8			/* SIGFPE */
+	bl	PIC_SYM(_C_LABEL(raise), PLT)	/* raise it */
+	mov	r0, #0
+#else
+	/* XXX should cause a fatal error */
+	mvn	r0, #0
+#endif
+	RET
+
+ENTRY(__udivsi3)
+.L_udivide:				/* r0 = r0 / r1; r1 = r0 % r1 */
+	eor     r0, r1, r0 
+	eor     r1, r0, r1 
+	eor     r0, r1, r0 
+					/* r0 = r1 / r0; r1 = r1 % r0 */
+	cmp	r0, #1
+	bcc	.L_overflow
+	beq	.L_divide_l0
+	mov	ip, #0
+	movs	r1, r1
+	bpl	.L_divide_l1
+	orr	ip, ip, #0x20000000	/* ip bit 0x20000000 = -ve r1 */
+	movs	r1, r1, lsr #1
+	orrcs	ip, ip, #0x10000000	/* ip bit 0x10000000 = bit 0 of r1 */
+	b	.L_divide_l1
+
+.L_divide_l0:				/* r0 == 1 */
+	mov	r0, r1
+	mov	r1, #0
+	RET
+
+ENTRY(__divsi3)
+.L_divide:				/* r0 = r0 / r1; r1 = r0 % r1 */
+	eor     r0, r1, r0 
+	eor     r1, r0, r1 
+	eor     r0, r1, r0 
+					/* r0 = r1 / r0; r1 = r1 % r0 */
+	cmp	r0, #1
+	bcc	.L_overflow
+	beq	.L_divide_l0
+	ands	ip, r0, #0x80000000
+	rsbmi	r0, r0, #0
+	ands	r2, r1, #0x80000000
+	eor	ip, ip, r2
+	rsbmi	r1, r1, #0
+	orr	ip, r2, ip, lsr #1	/* ip bit 0x40000000 = -ve division */
+					/* ip bit 0x80000000 = -ve remainder */
+
+.L_divide_l1:
+	mov	r2, #1
+	mov	r3, #0
+
+	/*
+	 * If the highest bit of the dividend is set, we have to be
+	 * careful when shifting the divisor. Test this. 
+	 */
+	movs	r1,r1
+	bpl	.L_old_code
+
+	/*
+	 * At this point, the highest bit of r1 is known to be set.
+	 * We abuse this below in the tst instructions.
+	 */
+	tst	r1, r0 /*, lsl #0 */
+	bmi	.L_divide_b1
+	tst	r1, r0, lsl #1
+	bmi	.L_divide_b2
+	tst	r1, r0, lsl #2
+	bmi	.L_divide_b3
+	tst	r1, r0, lsl #3
+	bmi	.L_divide_b4
+	tst	r1, r0, lsl #4
+	bmi	.L_divide_b5
+	tst	r1, r0, lsl #5
+	bmi	.L_divide_b6
+	tst	r1, r0, lsl #6
+	bmi	.L_divide_b7
+	tst	r1, r0, lsl #7
+	bmi	.L_divide_b8
+	tst	r1, r0, lsl #8
+	bmi	.L_divide_b9
+	tst	r1, r0, lsl #9
+	bmi	.L_divide_b10
+	tst	r1, r0, lsl #10
+	bmi	.L_divide_b11
+	tst	r1, r0, lsl #11
+	bmi	.L_divide_b12
+	tst	r1, r0, lsl #12
+	bmi	.L_divide_b13
+	tst	r1, r0, lsl #13
+	bmi	.L_divide_b14
+	tst	r1, r0, lsl #14
+	bmi	.L_divide_b15
+	tst	r1, r0, lsl #15
+	bmi	.L_divide_b16
+	tst	r1, r0, lsl #16
+	bmi	.L_divide_b17
+	tst	r1, r0, lsl #17
+	bmi	.L_divide_b18
+	tst	r1, r0, lsl #18
+	bmi	.L_divide_b19
+	tst	r1, r0, lsl #19
+	bmi	.L_divide_b20
+	tst	r1, r0, lsl #20
+	bmi	.L_divide_b21
+	tst	r1, r0, lsl #21
+	bmi	.L_divide_b22
+	tst	r1, r0, lsl #22
+	bmi	.L_divide_b23
+	tst	r1, r0, lsl #23
+	bmi	.L_divide_b24
+	tst	r1, r0, lsl #24
+	bmi	.L_divide_b25
+	tst	r1, r0, lsl #25
+	bmi	.L_divide_b26
+	tst	r1, r0, lsl #26
+	bmi	.L_divide_b27
+	tst	r1, r0, lsl #27
+	bmi	.L_divide_b28
+	tst	r1, r0, lsl #28
+	bmi	.L_divide_b29
+	tst	r1, r0, lsl #29
+	bmi	.L_divide_b30
+	tst	r1, r0, lsl #30
+	bmi	.L_divide_b31
+/*
+ * instead of:
+ *	tst	r1, r0, lsl #31
+ *	bmi	.L_divide_b32
+ */
+	b	.L_divide_b32
+
+.L_old_code:
+	cmp	r1, r0
+	bcc	.L_divide_b0
+	cmp	r1, r0, lsl #1
+	bcc	.L_divide_b1
+	cmp	r1, r0, lsl #2
+	bcc	.L_divide_b2
+	cmp	r1, r0, lsl #3
+	bcc	.L_divide_b3
+	cmp	r1, r0, lsl #4
+	bcc	.L_divide_b4
+	cmp	r1, r0, lsl #5
+	bcc	.L_divide_b5
+	cmp	r1, r0, lsl #6
+	bcc	.L_divide_b6
+	cmp	r1, r0, lsl #7
+	bcc	.L_divide_b7
+	cmp	r1, r0, lsl #8
+	bcc	.L_divide_b8
+	cmp	r1, r0, lsl #9
+	bcc	.L_divide_b9
+	cmp	r1, r0, lsl #10
+	bcc	.L_divide_b10
+	cmp	r1, r0, lsl #11
+	bcc	.L_divide_b11
+	cmp	r1, r0, lsl #12
+	bcc	.L_divide_b12
+	cmp	r1, r0, lsl #13
+	bcc	.L_divide_b13
+	cmp	r1, r0, lsl #14
+	bcc	.L_divide_b14
+	cmp	r1, r0, lsl #15
+	bcc	.L_divide_b15
+	cmp	r1, r0, lsl #16
+	bcc	.L_divide_b16
+	cmp	r1, r0, lsl #17
+	bcc	.L_divide_b17
+	cmp	r1, r0, lsl #18
+	bcc	.L_divide_b18
+	cmp	r1, r0, lsl #19
+	bcc	.L_divide_b19
+	cmp	r1, r0, lsl #20
+	bcc	.L_divide_b20
+	cmp	r1, r0, lsl #21
+	bcc	.L_divide_b21
+	cmp	r1, r0, lsl #22
+	bcc	.L_divide_b22
+	cmp	r1, r0, lsl #23
+	bcc	.L_divide_b23
+	cmp	r1, r0, lsl #24
+	bcc	.L_divide_b24
+	cmp	r1, r0, lsl #25
+	bcc	.L_divide_b25
+	cmp	r1, r0, lsl #26
+	bcc	.L_divide_b26
+	cmp	r1, r0, lsl #27
+	bcc	.L_divide_b27
+	cmp	r1, r0, lsl #28
+	bcc	.L_divide_b28
+	cmp	r1, r0, lsl #29
+	bcc	.L_divide_b29
+	cmp	r1, r0, lsl #30
+	bcc	.L_divide_b30
+.L_divide_b32:
+	cmp	r1, r0, lsl #31
+	subhs	r1, r1,r0, lsl #31
+	addhs	r3, r3,r2, lsl #31
+.L_divide_b31:
+	cmp	r1, r0, lsl #30
+	subhs	r1, r1,r0, lsl #30
+	addhs	r3, r3,r2, lsl #30
+.L_divide_b30:
+	cmp	r1, r0, lsl #29
+	subhs	r1, r1,r0, lsl #29
+	addhs	r3, r3,r2, lsl #29
+.L_divide_b29:
+	cmp	r1, r0, lsl #28
+	subhs	r1, r1,r0, lsl #28
+	addhs	r3, r3,r2, lsl #28
+.L_divide_b28:
+	cmp	r1, r0, lsl #27
+	subhs	r1, r1,r0, lsl #27
+	addhs	r3, r3,r2, lsl #27
+.L_divide_b27:
+	cmp	r1, r0, lsl #26
+	subhs	r1, r1,r0, lsl #26
+	addhs	r3, r3,r2, lsl #26
+.L_divide_b26:
+	cmp	r1, r0, lsl #25
+	subhs	r1, r1,r0, lsl #25
+	addhs	r3, r3,r2, lsl #25
+.L_divide_b25:
+	cmp	r1, r0, lsl #24
+	subhs	r1, r1,r0, lsl #24
+	addhs	r3, r3,r2, lsl #24
+.L_divide_b24:
+	cmp	r1, r0, lsl #23
+	subhs	r1, r1,r0, lsl #23
+	addhs	r3, r3,r2, lsl #23
+.L_divide_b23:
+	cmp	r1, r0, lsl #22
+	subhs	r1, r1,r0, lsl #22
+	addhs	r3, r3,r2, lsl #22
+.L_divide_b22:
+	cmp	r1, r0, lsl #21
+	subhs	r1, r1,r0, lsl #21
+	addhs	r3, r3,r2, lsl #21
+.L_divide_b21:
+	cmp	r1, r0, lsl #20
+	subhs	r1, r1,r0, lsl #20
+	addhs	r3, r3,r2, lsl #20
+.L_divide_b20:
+	cmp	r1, r0, lsl #19
+	subhs	r1, r1,r0, lsl #19
+	addhs	r3, r3,r2, lsl #19
+.L_divide_b19:
+	cmp	r1, r0, lsl #18
+	subhs	r1, r1,r0, lsl #18
+	addhs	r3, r3,r2, lsl #18
+.L_divide_b18:
+	cmp	r1, r0, lsl #17
+	subhs	r1, r1,r0, lsl #17
+	addhs	r3, r3,r2, lsl #17
+.L_divide_b17:
+	cmp	r1, r0, lsl #16
+	subhs	r1, r1,r0, lsl #16
+	addhs	r3, r3,r2, lsl #16
+.L_divide_b16:
+	cmp	r1, r0, lsl #15
+	subhs	r1, r1,r0, lsl #15
+	addhs	r3, r3,r2, lsl #15
+.L_divide_b15:
+	cmp	r1, r0, lsl #14
+	subhs	r1, r1,r0, lsl #14
+	addhs	r3, r3,r2, lsl #14
+.L_divide_b14:
+	cmp	r1, r0, lsl #13
+	subhs	r1, r1,r0, lsl #13
+	addhs	r3, r3,r2, lsl #13
+.L_divide_b13:
+	cmp	r1, r0, lsl #12
+	subhs	r1, r1,r0, lsl #12
+	addhs	r3, r3,r2, lsl #12
+.L_divide_b12:
+	cmp	r1, r0, lsl #11
+	subhs	r1, r1,r0, lsl #11
+	addhs	r3, r3,r2, lsl #11
+.L_divide_b11:
+	cmp	r1, r0, lsl #10
+	subhs	r1, r1,r0, lsl #10
+	addhs	r3, r3,r2, lsl #10
+.L_divide_b10:
+	cmp	r1, r0, lsl #9
+	subhs	r1, r1,r0, lsl #9
+	addhs	r3, r3,r2, lsl #9
+.L_divide_b9:
+	cmp	r1, r0, lsl #8
+	subhs	r1, r1,r0, lsl #8
+	addhs	r3, r3,r2, lsl #8
+.L_divide_b8:
+	cmp	r1, r0, lsl #7
+	subhs	r1, r1,r0, lsl #7
+	addhs	r3, r3,r2, lsl #7
+.L_divide_b7:
+	cmp	r1, r0, lsl #6
+	subhs	r1, r1,r0, lsl #6
+	addhs	r3, r3,r2, lsl #6
+.L_divide_b6:
+	cmp	r1, r0, lsl #5
+	subhs	r1, r1,r0, lsl #5
+	addhs	r3, r3,r2, lsl #5
+.L_divide_b5:
+	cmp	r1, r0, lsl #4
+	subhs	r1, r1,r0, lsl #4
+	addhs	r3, r3,r2, lsl #4
+.L_divide_b4:
+	cmp	r1, r0, lsl #3
+	subhs	r1, r1,r0, lsl #3
+	addhs	r3, r3,r2, lsl #3
+.L_divide_b3:
+	cmp	r1, r0, lsl #2
+	subhs	r1, r1,r0, lsl #2
+	addhs	r3, r3,r2, lsl #2
+.L_divide_b2:
+	cmp	r1, r0, lsl #1
+	subhs	r1, r1,r0, lsl #1
+	addhs	r3, r3,r2, lsl #1
+.L_divide_b1:
+	cmp	r1, r0
+	subhs	r1, r1, r0
+	addhs	r3, r3, r2
+.L_divide_b0:
+
+	tst	ip, #0x20000000
+	bne	.L_udivide_l1
+	mov	r0, r3
+	cmp	ip, #0
+	rsbmi	r1, r1, #0
+	movs	ip, ip, lsl #1
+	bicmi	r0, r0, #0x80000000	/* Fix incase we divided 0x80000000 */
+	rsbmi	r0, r0, #0
+	RET
+
+.L_udivide_l1:
+	tst	ip, #0x10000000
+	mov	r1, r1, lsl #1
+	orrne	r1, r1, #1
+	mov	r3, r3, lsl #1
+	cmp	r1, r0
+	subhs	r1, r1, r0
+	addhs	r3, r3, r2
+	mov	r0, r3
+	RET
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/string/ffs.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,85 @@
+/*	$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+/*
+ * Copyright (c) 2001 Christopher Gilbert
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company nor the name of the author may be used to
+ *    endorse or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+
+/*
+ * ffs - find first set bit, this algorithm isolates the first set
+ * bit, then multiplies the number by 0x0450fbaf which leaves the top
+ * 6 bits as an index into the table.  This algorithm should be a win
+ * over the checking each bit in turn as per the C compiled version.
+ *
+ * On ARMv5 we use CLZ (count leading Zero's) and then subtract the result
+ * from 32.
+ *
+ * This is the ffs algorithm devised by d.seal and posted to comp.sys.arm on
+ * 16 Feb 1994.
+ */
+
+ENTRY(ffs)
+#ifdef _ARM_ARCH_5
+	/* (X & -X) gives LSB or zero.  */
+ 	rsb	r1, r0, #0
+ 	and	r0, r0, r1
+	clz	r0, r0
+	rsb	r0, r0, #32
+	RET
+#else
+	/* Standard trick to isolate bottom bit in r0 or 0 if r0 = 0 on entry */
+ 	rsb     r1, r0, #0
+ 	ands    r0, r0, r1
+	/*
+	 * now r0 has at most one set bit, call this X
+	 * if X = 0, all further instructions are skipped
+	 */
+	adrne   r2, .L_ffs_table
+	orrne   r0, r0, r0, lsl #4  /* r0 = X * 0x11 */ 
+	orrne   r0, r0, r0, lsl #6  /* r0 = X * 0x451 */
+	rsbne   r0, r0, r0, lsl #16 /* r0 = X * 0x0450fbaf */
+              
+	/* now lookup in table indexed on top 6 bits of r0 */
+	ldrneb  r0, [ r2, r0, lsr #26 ]
+
+        RET
+.text;
+.type .L_ffs_table, _ASM_TYPE_OBJECT;
+.L_ffs_table:
+/*               0   1   2   3   4   5   6   7           */
+	.byte	 0,  1,  2, 13,  3,  7,  0, 14  /*  0- 7 */
+	.byte	 4,  0,  8,  0,  0,  0,  0, 15  /*  8-15 */
+	.byte	11,  5,  0,  0,  9,  0,  0, 26  /* 16-23 */
+	.byte	 0,  0,  0,  0,  0, 22, 28, 16  /* 24-31 */
+	.byte	32, 12,  6,  0,  0,  0,  0,  0	/* 32-39 */
+	.byte	10,  0,  0, 25,  0,  0, 21, 27  /* 40-47 */
+	.byte	31,  0,  0,  0,  0, 24,  0, 20  /* 48-55 */
+	.byte   30,  0, 23, 19, 29, 18, 17,  0  /* 56-63 */
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/string/memcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,180 @@
+/*      $NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+
+/*
+ * Copyright 2003 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Steve C. Woodford for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Copyright (c) 2002 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+
+ENTRY(memcmp)
+	mov	ip, r0
+#if defined(_KERNEL) && !defined(_STANDALONE)
+	cmp	r2, #0x06
+	beq	.Lmemcmp_6bytes
+#endif
+	mov	r0, #0x00
+
+	/* Are both addresses aligned the same way? */
+	cmp	r2, #0x00
+	eornes	r3, ip, r1
+	RETc(eq)			/* len == 0, or same addresses! */
+	tst	r3, #0x03
+	subne	r2, r2, #0x01
+	bne	.Lmemcmp_bytewise2	/* Badly aligned. Do it the slow way */
+
+	/* Word-align the addresses, if necessary */
+	sub	r3, r1, #0x05
+	ands	r3, r3, #0x03
+	add	r3, r3, r3, lsl #1
+	addne	pc, pc, r3, lsl #3
+	nop
+
+	/* Compare up to 3 bytes */
+	ldrb	r0, [ip], #0x01
+	ldrb	r3, [r1], #0x01
+	subs	r0, r0, r3
+	RETc(ne)
+	subs	r2, r2, #0x01
+	RETc(eq)
+
+	/* Compare up to 2 bytes */
+	ldrb	r0, [ip], #0x01
+	ldrb	r3, [r1], #0x01
+	subs	r0, r0, r3
+	RETc(ne)
+	subs	r2, r2, #0x01
+	RETc(eq)
+
+	/* Compare 1 byte */
+	ldrb	r0, [ip], #0x01
+	ldrb	r3, [r1], #0x01
+	subs	r0, r0, r3
+	RETc(ne)
+	subs	r2, r2, #0x01
+	RETc(eq)
+
+	/* Compare 4 bytes at a time, if possible */
+	subs	r2, r2, #0x04
+	bcc	.Lmemcmp_bytewise
+.Lmemcmp_word_aligned:
+	ldr	r0, [ip], #0x04
+	ldr	r3, [r1], #0x04
+	subs	r2, r2, #0x04
+	cmpcs	r0, r3
+	beq	.Lmemcmp_word_aligned
+	sub	r0, r0, r3
+
+	/* Correct for extra subtraction, and check if done */
+	adds	r2, r2, #0x04
+	cmpeq	r0, #0x00		/* If done, did all bytes match? */
+	RETc(eq)			/* Yup. Just return */
+
+	/* Re-do the final word byte-wise */
+	sub	ip, ip, #0x04
+	sub	r1, r1, #0x04
+
+.Lmemcmp_bytewise:
+	add	r2, r2, #0x03
+.Lmemcmp_bytewise2:
+	ldrb	r0, [ip], #0x01
+	ldrb	r3, [r1], #0x01
+	subs	r2, r2, #0x01
+	cmpcs	r0, r3
+	beq	.Lmemcmp_bytewise2
+	sub	r0, r0, r3
+	RET
+
+#if defined(_KERNEL) && !defined(_STANDALONE)
+	/*
+	 * 6 byte compares are very common, thanks to the network stack.
+	 * This code is hand-scheduled to reduce the number of stalls for
+	 * load results. Everything else being equal, this will be ~32%
+	 * faster than a byte-wise memcmp.
+	 */
+	.align	5
+.Lmemcmp_6bytes:
+	ldrb	r3, [r1, #0x00]		/* r3 = b2#0 */
+	ldrb	r0, [ip, #0x00]		/* r0 = b1#0 */
+	ldrb	r2, [r1, #0x01]		/* r2 = b2#1 */
+	subs	r0, r0, r3		/* r0 = b1#0 - b2#0 */
+	ldreqb	r3, [ip, #0x01]		/* r3 = b1#1 */
+	RETc(ne)			/* Return if mismatch on #0 */
+	subs	r0, r3, r2		/* r0 = b1#1 - b2#1 */
+	ldreqb	r3, [r1, #0x02]		/* r3 = b2#2 */
+	ldreqb	r0, [ip, #0x02]		/* r0 = b1#2 */
+	RETc(ne)			/* Return if mismatch on #1 */
+	ldrb	r2, [r1, #0x03]		/* r2 = b2#3 */
+	subs	r0, r0, r3		/* r0 = b1#2 - b2#2 */
+	ldreqb	r3, [ip, #0x03]		/* r3 = b1#3 */
+	RETc(ne)			/* Return if mismatch on #2 */
+	subs	r0, r3, r2		/* r0 = b1#3 - b2#3 */
+	ldreqb	r3, [r1, #0x04]		/* r3 = b2#4 */
+	ldreqb	r0, [ip, #0x04]		/* r0 = b1#4 */
+	RETc(ne)			/* Return if mismatch on #3 */
+	ldrb	r2, [r1, #0x05]		/* r2 = b2#5 */
+	subs	r0, r0, r3		/* r0 = b1#4 - b2#4 */
+	ldreqb	r3, [ip, #0x05]		/* r3 = b1#5 */
+	RETc(ne)			/* Return if mismatch on #4 */
+	sub	r0, r3, r2		/* r0 = b1#5 - b2#5 */
+	RET
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/string/memcpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,7 @@
+/*	$NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+#if !defined(__XSCALE__) || defined(_STANDALONE)
+#include "memcpy_arm.S"
+#else
+#include "memcpy_xscale.S"
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/string/memcpy_arm.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,339 @@
+/*	$NetBSD: memcpy_arm.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Neil A. Carson and Mark Brinicombe
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * This is one fun bit of code ...
+ * Some easy listening music is suggested while trying to understand this
+ * code e.g. Iron Maiden
+ *
+ * For anyone attempting to understand it :
+ *
+ * The core code is implemented here with simple stubs for memcpy().
+ *
+ * All local labels are prefixed with Lmemcpy_
+ * Following the prefix a label starting f is used in the forward copy code
+ * while a label using b is used in the backwards copy code
+ * The source and destination addresses determine whether a forward or
+ * backward copy is performed.
+ * Separate bits of code are used to deal with the following situations
+ * for both the forward and backwards copy.
+ * unaligned source address
+ * unaligned destination address
+ * Separate copy routines are used to produce an optimised result for each
+ * of these cases.
+ * The copy code will use LDM/STM instructions to copy up to 32 bytes at
+ * a time where possible.
+ *
+ * Note: r12 (aka ip) can be trashed during the function along with
+ * r0-r3 although r0-r2 have defined uses i.e. src, dest, len through out.
+ * Additional registers are preserved prior to use i.e. r4, r5 & lr
+ *
+ * Apologies for the state of the comments ;-)
+ */
+/* LINTSTUB: Func: void *memcpy(void *dst, const void *src, size_t len) */
+ENTRY(memcpy)
+	/* save leaf functions having to store this away */
+	stmdb	sp!, {r0, lr}		/* memcpy() returns dest addr */
+
+	subs	r2, r2, #4
+	blt	.Lmemcpy_l4		/* less than 4 bytes */
+	ands	r12, r0, #3
+	bne	.Lmemcpy_destul		/* oh unaligned destination addr */
+	ands	r12, r1, #3
+	bne	.Lmemcpy_srcul		/* oh unaligned source addr */
+
+.Lmemcpy_t8:
+	/* We have aligned source and destination */
+	subs	r2, r2, #8
+	blt	.Lmemcpy_l12		/* less than 12 bytes (4 from above) */
+	subs	r2, r2, #0x14
+	blt	.Lmemcpy_l32		/* less than 32 bytes (12 from above) */
+	stmdb	sp!, {r4}		/* borrow r4 */
+
+	/* blat 32 bytes at a time */
+	/* XXX for really big copies perhaps we should use more registers */
+.Lmemcpy_loop32:
+	ldmia	r1!, {r3, r4, r12, lr}
+	stmia	r0!, {r3, r4, r12, lr}
+	ldmia	r1!, {r3, r4, r12, lr}
+	stmia	r0!, {r3, r4, r12, lr}
+	subs	r2, r2, #0x20
+	bge	.Lmemcpy_loop32
+
+	cmn	r2, #0x10
+	ldmgeia	r1!, {r3, r4, r12, lr}	/* blat a remaining 16 bytes */
+	stmgeia	r0!, {r3, r4, r12, lr}
+	subge	r2, r2, #0x10
+	ldmia	sp!, {r4}		/* return r4 */
+
+.Lmemcpy_l32:
+	adds	r2, r2, #0x14
+
+	/* blat 12 bytes at a time */
+.Lmemcpy_loop12:
+	ldmgeia	r1!, {r3, r12, lr}
+	stmgeia	r0!, {r3, r12, lr}
+	subges	r2, r2, #0x0c
+	bge	.Lmemcpy_loop12
+
+.Lmemcpy_l12:
+	adds	r2, r2, #8
+	blt	.Lmemcpy_l4
+
+	subs	r2, r2, #4
+	ldrlt	r3, [r1], #4
+	strlt	r3, [r0], #4
+	ldmgeia	r1!, {r3, r12}
+	stmgeia	r0!, {r3, r12}
+	subge	r2, r2, #4
+
+.Lmemcpy_l4:
+	/* less than 4 bytes to go */
+	adds	r2, r2, #4
+#ifdef __APCS_26_
+	ldmeqia sp!, {r0, pc}^		/* done */
+#else
+	ldmeqia	sp!, {r0, pc}		/* done */
+#endif
+	/* copy the crud byte at a time */
+	cmp	r2, #2
+	ldrb	r3, [r1], #1
+	strb	r3, [r0], #1
+	ldrgeb	r3, [r1], #1
+	strgeb	r3, [r0], #1
+	ldrgtb	r3, [r1], #1
+	strgtb	r3, [r0], #1
+	ldmia	sp!, {r0, pc}
+
+	/* erg - unaligned destination */
+.Lmemcpy_destul:
+	rsb	r12, r12, #4
+	cmp	r12, #2
+
+	/* align destination with byte copies */
+	ldrb	r3, [r1], #1
+	strb	r3, [r0], #1
+	ldrgeb	r3, [r1], #1
+	strgeb	r3, [r0], #1
+	ldrgtb	r3, [r1], #1
+	strgtb	r3, [r0], #1
+	subs	r2, r2, r12
+	blt	.Lmemcpy_l4		/* less the 4 bytes */
+
+	ands	r12, r1, #3
+	beq	.Lmemcpy_t8		/* we have an aligned source */
+
+	/* erg - unaligned source */
+	/* This is where it gets nasty ... */
+.Lmemcpy_srcul:
+	bic	r1, r1, #3
+	ldr	lr, [r1], #4
+	cmp	r12, #2
+	bgt	.Lmemcpy_srcul3
+	beq	.Lmemcpy_srcul2
+	cmp	r2, #0x0c
+	blt	.Lmemcpy_srcul1loop4
+	sub	r2, r2, #0x0c
+	stmdb	sp!, {r4, r5}
+
+.Lmemcpy_srcul1loop16:
+#ifdef __ARMEB__
+	mov	r3, lr, lsl #8
+#else
+	mov	r3, lr, lsr #8
+#endif
+	ldmia	r1!, {r4, r5, r12, lr}
+#ifdef __ARMEB__
+	orr	r3, r3, r4, lsr #24
+	mov	r4, r4, lsl #8
+	orr	r4, r4, r5, lsr #24
+	mov	r5, r5, lsl #8
+	orr	r5, r5, r12, lsr #24
+	mov	r12, r12, lsl #8
+	orr	r12, r12, lr, lsr #24
+#else
+	orr	r3, r3, r4, lsl #24
+	mov	r4, r4, lsr #8
+	orr	r4, r4, r5, lsl #24
+	mov	r5, r5, lsr #8
+	orr	r5, r5, r12, lsl #24
+	mov	r12, r12, lsr #8
+	orr	r12, r12, lr, lsl #24
+#endif
+	stmia	r0!, {r3-r5, r12}
+	subs	r2, r2, #0x10
+	bge	.Lmemcpy_srcul1loop16
+	ldmia	sp!, {r4, r5}
+	adds	r2, r2, #0x0c
+	blt	.Lmemcpy_srcul1l4
+
+.Lmemcpy_srcul1loop4:
+#ifdef __ARMEB__
+	mov	r12, lr, lsl #8
+#else
+	mov	r12, lr, lsr #8
+#endif
+	ldr	lr, [r1], #4
+#ifdef __ARMEB__
+	orr	r12, r12, lr, lsr #24
+#else
+	orr	r12, r12, lr, lsl #24
+#endif
+	str	r12, [r0], #4
+	subs	r2, r2, #4
+	bge	.Lmemcpy_srcul1loop4
+
+.Lmemcpy_srcul1l4:
+	sub	r1, r1, #3
+	b	.Lmemcpy_l4
+
+.Lmemcpy_srcul2:
+	cmp	r2, #0x0c
+	blt	.Lmemcpy_srcul2loop4
+	sub	r2, r2, #0x0c
+	stmdb	sp!, {r4, r5}
+
+.Lmemcpy_srcul2loop16:
+#ifdef __ARMEB__
+	mov	r3, lr, lsl #16
+#else
+	mov	r3, lr, lsr #16
+#endif
+	ldmia	r1!, {r4, r5, r12, lr}
+#ifdef __ARMEB__
+	orr	r3, r3, r4, lsr #16
+	mov	r4, r4, lsl #16
+	orr	r4, r4, r5, lsr #16
+	mov	r5, r5, lsl #16
+	orr	r5, r5, r12, lsr #16
+	mov	r12, r12, lsl #16
+	orr	r12, r12, lr, lsr #16
+#else
+	orr	r3, r3, r4, lsl #16
+	mov	r4, r4, lsr #16
+	orr	r4, r4, r5, lsl #16
+	mov	r5, r5, lsr #16
+	orr	r5, r5, r12, lsl #16
+	mov	r12, r12, lsr #16
+	orr	r12, r12, lr, lsl #16
+#endif
+	stmia	r0!, {r3-r5, r12}
+	subs	r2, r2, #0x10
+	bge	.Lmemcpy_srcul2loop16
+	ldmia	sp!, {r4, r5}
+	adds	r2, r2, #0x0c
+	blt	.Lmemcpy_srcul2l4
+
+.Lmemcpy_srcul2loop4:
+#ifdef __ARMEB__
+	mov	r12, lr, lsl #16
+#else
+	mov	r12, lr, lsr #16
+#endif
+	ldr	lr, [r1], #4
+#ifdef __ARMEB__
+	orr	r12, r12, lr, lsr #16
+#else
+	orr	r12, r12, lr, lsl #16
+#endif
+	str	r12, [r0], #4
+	subs	r2, r2, #4
+	bge	.Lmemcpy_srcul2loop4
+
+.Lmemcpy_srcul2l4:
+	sub	r1, r1, #2
+	b	.Lmemcpy_l4
+
+.Lmemcpy_srcul3:
+	cmp	r2, #0x0c
+	blt	.Lmemcpy_srcul3loop4
+	sub	r2, r2, #0x0c
+	stmdb	sp!, {r4, r5}
+
+.Lmemcpy_srcul3loop16:
+#ifdef __ARMEB__
+	mov	r3, lr, lsl #24
+#else
+	mov	r3, lr, lsr #24
+#endif
+	ldmia	r1!, {r4, r5, r12, lr}
+#ifdef __ARMEB__
+	orr	r3, r3, r4, lsr #8
+	mov	r4, r4, lsl #24
+	orr	r4, r4, r5, lsr #8
+	mov	r5, r5, lsl #24
+	orr	r5, r5, r12, lsr #8
+	mov	r12, r12, lsl #24
+	orr	r12, r12, lr, lsr #8
+#else
+	orr	r3, r3, r4, lsl #8
+	mov	r4, r4, lsr #24
+	orr	r4, r4, r5, lsl #8
+	mov	r5, r5, lsr #24
+	orr	r5, r5, r12, lsl #8
+	mov	r12, r12, lsr #24
+	orr	r12, r12, lr, lsl #8
+#endif
+	stmia	r0!, {r3-r5, r12}
+	subs	r2, r2, #0x10
+	bge	.Lmemcpy_srcul3loop16
+	ldmia	sp!, {r4, r5}
+	adds	r2, r2, #0x0c
+	blt	.Lmemcpy_srcul3l4
+
+.Lmemcpy_srcul3loop4:
+#ifdef __ARMEB__
+	mov	r12, lr, lsl #24
+#else
+	mov	r12, lr, lsr #24
+#endif
+	ldr	lr, [r1], #4
+#ifdef __ARMEB__
+	orr	r12, r12, lr, lsr #8
+#else
+	orr	r12, r12, lr, lsl #8
+#endif
+	str	r12, [r0], #4
+	subs	r2, r2, #4
+	bge	.Lmemcpy_srcul3loop4
+
+.Lmemcpy_srcul3l4:
+	sub	r1, r1, #1
+	b	.Lmemcpy_l4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/string/memcpy_xscale.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,1782 @@
+/*	$NetBSD: memcpy_xscale.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*
+ * Copyright 2003 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Steve C. Woodford for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+/* LINTSTUB: Func: void *memcpy(void *dst, const void *src, size_t len) */
+ENTRY(memcpy)
+	pld	[r1]
+	cmp	r2, #0x0c
+	ble	.Lmemcpy_short		/* <= 12 bytes */
+	mov	r3, r0			/* We must not clobber r0 */
+
+	/* Word-align the destination buffer */
+	ands	ip, r3, #0x03		/* Already word aligned? */
+	beq	.Lmemcpy_wordaligned	/* Yup */
+	cmp	ip, #0x02
+	ldrb	ip, [r1], #0x01
+	sub	r2, r2, #0x01
+	strb	ip, [r3], #0x01
+	ldrleb	ip, [r1], #0x01
+	suble	r2, r2, #0x01
+	strleb	ip, [r3], #0x01
+	ldrltb	ip, [r1], #0x01
+	sublt	r2, r2, #0x01
+	strltb	ip, [r3], #0x01
+
+	/* Destination buffer is now word aligned */
+.Lmemcpy_wordaligned:
+	ands	ip, r1, #0x03		/* Is src also word-aligned? */
+	bne	.Lmemcpy_bad_align	/* Nope. Things just got bad */
+
+	/* Quad-align the destination buffer */
+	tst	r3, #0x07		/* Already quad aligned? */
+	ldrne	ip, [r1], #0x04
+	stmfd	sp!, {r4-r9}		/* Free up some registers */
+	subne	r2, r2, #0x04
+	strne	ip, [r3], #0x04
+
+	/* Destination buffer quad aligned, source is at least word aligned */
+	subs	r2, r2, #0x80
+	blt	.Lmemcpy_w_lessthan128
+
+	/* Copy 128 bytes at a time */
+.Lmemcpy_w_loop128:
+	ldr	r4, [r1], #0x04		/* LD:00-03 */
+	ldr	r5, [r1], #0x04		/* LD:04-07 */
+	pld	[r1, #0x18]		/* Prefetch 0x20 */
+	ldr	r6, [r1], #0x04		/* LD:08-0b */
+	ldr	r7, [r1], #0x04		/* LD:0c-0f */
+	ldr	r8, [r1], #0x04		/* LD:10-13 */
+	ldr	r9, [r1], #0x04		/* LD:14-17 */
+	strd	r4, [r3], #0x08		/* ST:00-07 */
+	ldr	r4, [r1], #0x04		/* LD:18-1b */
+	ldr	r5, [r1], #0x04		/* LD:1c-1f */
+	strd	r6, [r3], #0x08		/* ST:08-0f */
+	ldr	r6, [r1], #0x04		/* LD:20-23 */
+	ldr	r7, [r1], #0x04		/* LD:24-27 */
+	pld	[r1, #0x18]		/* Prefetch 0x40 */
+	strd	r8, [r3], #0x08		/* ST:10-17 */
+	ldr	r8, [r1], #0x04		/* LD:28-2b */
+	ldr	r9, [r1], #0x04		/* LD:2c-2f */
+	strd	r4, [r3], #0x08		/* ST:18-1f */
+	ldr	r4, [r1], #0x04		/* LD:30-33 */
+	ldr	r5, [r1], #0x04		/* LD:34-37 */
+	strd	r6, [r3], #0x08		/* ST:20-27 */
+	ldr	r6, [r1], #0x04		/* LD:38-3b */
+	ldr	r7, [r1], #0x04		/* LD:3c-3f */
+	strd	r8, [r3], #0x08		/* ST:28-2f */
+	ldr	r8, [r1], #0x04		/* LD:40-43 */
+	ldr	r9, [r1], #0x04		/* LD:44-47 */
+	pld	[r1, #0x18]		/* Prefetch 0x60 */
+	strd	r4, [r3], #0x08		/* ST:30-37 */
+	ldr	r4, [r1], #0x04		/* LD:48-4b */
+	ldr	r5, [r1], #0x04		/* LD:4c-4f */
+	strd	r6, [r3], #0x08		/* ST:38-3f */
+	ldr	r6, [r1], #0x04		/* LD:50-53 */
+	ldr	r7, [r1], #0x04		/* LD:54-57 */
+	strd	r8, [r3], #0x08		/* ST:40-47 */
+	ldr	r8, [r1], #0x04		/* LD:58-5b */
+	ldr	r9, [r1], #0x04		/* LD:5c-5f */
+	strd	r4, [r3], #0x08		/* ST:48-4f */
+	ldr	r4, [r1], #0x04		/* LD:60-63 */
+	ldr	r5, [r1], #0x04		/* LD:64-67 */
+	pld	[r1, #0x18]		/* Prefetch 0x80 */
+	strd	r6, [r3], #0x08		/* ST:50-57 */
+	ldr	r6, [r1], #0x04		/* LD:68-6b */
+	ldr	r7, [r1], #0x04		/* LD:6c-6f */
+	strd	r8, [r3], #0x08		/* ST:58-5f */
+	ldr	r8, [r1], #0x04		/* LD:70-73 */
+	ldr	r9, [r1], #0x04		/* LD:74-77 */
+	strd	r4, [r3], #0x08		/* ST:60-67 */
+	ldr	r4, [r1], #0x04		/* LD:78-7b */
+	ldr	r5, [r1], #0x04		/* LD:7c-7f */
+	strd	r6, [r3], #0x08		/* ST:68-6f */
+	strd	r8, [r3], #0x08		/* ST:70-77 */
+	subs	r2, r2, #0x80
+	strd	r4, [r3], #0x08		/* ST:78-7f */
+	bge	.Lmemcpy_w_loop128
+
+.Lmemcpy_w_lessthan128:
+	adds	r2, r2, #0x80		/* Adjust for extra sub */
+	ldmeqfd	sp!, {r4-r9}
+	bxeq	lr			/* Return now if done */
+	subs	r2, r2, #0x20
+	blt	.Lmemcpy_w_lessthan32
+
+	/* Copy 32 bytes at a time */
+.Lmemcpy_w_loop32:
+	ldr	r4, [r1], #0x04
+	ldr	r5, [r1], #0x04
+	pld	[r1, #0x18]
+	ldr	r6, [r1], #0x04
+	ldr	r7, [r1], #0x04
+	ldr	r8, [r1], #0x04
+	ldr	r9, [r1], #0x04
+	strd	r4, [r3], #0x08
+	ldr	r4, [r1], #0x04
+	ldr	r5, [r1], #0x04
+	strd	r6, [r3], #0x08
+	strd	r8, [r3], #0x08
+	subs	r2, r2, #0x20
+	strd	r4, [r3], #0x08
+	bge	.Lmemcpy_w_loop32
+
+.Lmemcpy_w_lessthan32:
+	adds	r2, r2, #0x20		/* Adjust for extra sub */
+	ldmeqfd	sp!, {r4-r9}
+	bxeq	lr			/* Return now if done */
+
+	and	r4, r2, #0x18
+	rsbs	r4, r4, #0x18
+	addne	pc, pc, r4, lsl #1
+	nop
+
+	/* At least 24 bytes remaining */
+	ldr	r4, [r1], #0x04
+	ldr	r5, [r1], #0x04
+	sub	r2, r2, #0x08
+	strd	r4, [r3], #0x08
+
+	/* At least 16 bytes remaining */
+	ldr	r4, [r1], #0x04
+	ldr	r5, [r1], #0x04
+	sub	r2, r2, #0x08
+	strd	r4, [r3], #0x08
+
+	/* At least 8 bytes remaining */
+	ldr	r4, [r1], #0x04
+	ldr	r5, [r1], #0x04
+	subs	r2, r2, #0x08
+	strd	r4, [r3], #0x08
+
+	/* Less than 8 bytes remaining */
+	ldmfd	sp!, {r4-r9}
+	bxeq	lr			/* Return now if done */
+	subs	r2, r2, #0x04
+	ldrge	ip, [r1], #0x04
+	strge	ip, [r3], #0x04
+	bxeq	lr			/* Return now if done */
+	addlt	r2, r2, #0x04
+	ldrb	ip, [r1], #0x01
+	cmp	r2, #0x02
+	ldrgeb	r2, [r1], #0x01
+	strb	ip, [r3], #0x01
+	ldrgtb	ip, [r1]
+	strgeb	r2, [r3], #0x01
+	strgtb	ip, [r3]
+	bx	lr
+
+
+/*
+ * At this point, it has not been possible to word align both buffers.
+ * The destination buffer is word aligned, but the source buffer is not.
+ */
+.Lmemcpy_bad_align:
+	stmfd	sp!, {r4-r7}
+	bic	r1, r1, #0x03
+	cmp	ip, #2
+	ldr	ip, [r1], #0x04
+	bgt	.Lmemcpy_bad3
+	beq	.Lmemcpy_bad2
+	b	.Lmemcpy_bad1
+
+.Lmemcpy_bad1_loop16:
+#ifdef __ARMEB__
+	mov	r4, ip, lsl #8
+#else
+	mov	r4, ip, lsr #8
+#endif
+	ldr	r5, [r1], #0x04
+	pld	[r1, #0x018]
+	ldr	r6, [r1], #0x04
+	ldr	r7, [r1], #0x04
+	ldr	ip, [r1], #0x04
+#ifdef __ARMEB__
+	orr	r4, r4, r5, lsr #24
+	mov	r5, r5, lsl #8
+	orr	r5, r5, r6, lsr #24
+	mov	r6, r6, lsl #8
+	orr	r6, r6, r7, lsr #24
+	mov	r7, r7, lsl #8
+	orr	r7, r7, ip, lsr #24
+#else
+	orr	r4, r4, r5, lsl #24
+	mov	r5, r5, lsr #8
+	orr	r5, r5, r6, lsl #24
+	mov	r6, r6, lsr #8
+	orr	r6, r6, r7, lsl #24
+	mov	r7, r7, lsr #8
+	orr	r7, r7, ip, lsl #24
+#endif
+	str	r4, [r3], #0x04
+	str	r5, [r3], #0x04
+	str	r6, [r3], #0x04
+	str	r7, [r3], #0x04
+.Lmemcpy_bad1:
+	subs	r2, r2, #0x10
+	bge	.Lmemcpy_bad1_loop16
+
+	adds	r2, r2, #0x10
+	ldmeqfd	sp!, {r4-r7}
+	bxeq	lr			/* Return now if done */
+	subs	r2, r2, #0x04
+	sublt	r1, r1, #0x03
+	blt	.Lmemcpy_bad_done
+
+.Lmemcpy_bad1_loop4:
+#ifdef __ARMEB__
+	mov	r4, ip, lsl #8
+#else
+	mov	r4, ip, lsr #8
+#endif
+	ldr	ip, [r1], #0x04
+	subs	r2, r2, #0x04
+#ifdef __ARMEB__
+	orr	r4, r4, ip, lsr #24
+#else
+	orr	r4, r4, ip, lsl #24
+#endif
+	str	r4, [r3], #0x04
+	bge	.Lmemcpy_bad1_loop4
+	sub	r1, r1, #0x03
+	b	.Lmemcpy_bad_done
+
+.Lmemcpy_bad2_loop16:
+#ifdef __ARMEB__
+	mov	r4, ip, lsl #16
+#else
+	mov	r4, ip, lsr #16
+#endif
+	ldr	r5, [r1], #0x04
+	pld	[r1, #0x018]
+	ldr	r6, [r1], #0x04
+	ldr	r7, [r1], #0x04
+	ldr	ip, [r1], #0x04
+#ifdef __ARMEB__
+	orr	r4, r4, r5, lsr #16
+	mov	r5, r5, lsl #16
+	orr	r5, r5, r6, lsr #16
+	mov	r6, r6, lsl #16
+	orr	r6, r6, r7, lsr #16
+	mov	r7, r7, lsl #16
+	orr	r7, r7, ip, lsr #16
+#else
+	orr	r4, r4, r5, lsl #16
+	mov	r5, r5, lsr #16
+	orr	r5, r5, r6, lsl #16
+	mov	r6, r6, lsr #16
+	orr	r6, r6, r7, lsl #16
+	mov	r7, r7, lsr #16
+	orr	r7, r7, ip, lsl #16
+#endif
+	str	r4, [r3], #0x04
+	str	r5, [r3], #0x04
+	str	r6, [r3], #0x04
+	str	r7, [r3], #0x04
+.Lmemcpy_bad2:
+	subs	r2, r2, #0x10
+	bge	.Lmemcpy_bad2_loop16
+
+	adds	r2, r2, #0x10
+	ldmeqfd	sp!, {r4-r7}
+	bxeq	lr			/* Return now if done */
+	subs	r2, r2, #0x04
+	sublt	r1, r1, #0x02
+	blt	.Lmemcpy_bad_done
+
+.Lmemcpy_bad2_loop4:
+#ifdef __ARMEB__
+	mov	r4, ip, lsl #16
+#else
+	mov	r4, ip, lsr #16
+#endif
+	ldr	ip, [r1], #0x04
+	subs	r2, r2, #0x04
+#ifdef __ARMEB__
+	orr	r4, r4, ip, lsr #16
+#else
+	orr	r4, r4, ip, lsl #16
+#endif
+	str	r4, [r3], #0x04
+	bge	.Lmemcpy_bad2_loop4
+	sub	r1, r1, #0x02
+	b	.Lmemcpy_bad_done
+
+.Lmemcpy_bad3_loop16:
+#ifdef __ARMEB__
+	mov	r4, ip, lsl #24
+#else
+	mov	r4, ip, lsr #24
+#endif
+	ldr	r5, [r1], #0x04
+	pld	[r1, #0x018]
+	ldr	r6, [r1], #0x04
+	ldr	r7, [r1], #0x04
+	ldr	ip, [r1], #0x04
+#ifdef __ARMEB__
+	orr	r4, r4, r5, lsr #8
+	mov	r5, r5, lsl #24
+	orr	r5, r5, r6, lsr #8
+	mov	r6, r6, lsl #24
+	orr	r6, r6, r7, lsr #8
+	mov	r7, r7, lsl #24
+	orr	r7, r7, ip, lsr #8
+#else
+	orr	r4, r4, r5, lsl #8
+	mov	r5, r5, lsr #24
+	orr	r5, r5, r6, lsl #8
+	mov	r6, r6, lsr #24
+	orr	r6, r6, r7, lsl #8
+	mov	r7, r7, lsr #24
+	orr	r7, r7, ip, lsl #8
+#endif
+	str	r4, [r3], #0x04
+	str	r5, [r3], #0x04
+	str	r6, [r3], #0x04
+	str	r7, [r3], #0x04
+.Lmemcpy_bad3:
+	subs	r2, r2, #0x10
+	bge	.Lmemcpy_bad3_loop16
+
+	adds	r2, r2, #0x10
+	ldmeqfd	sp!, {r4-r7}
+	bxeq	lr			/* Return now if done */
+	subs	r2, r2, #0x04
+	sublt	r1, r1, #0x01
+	blt	.Lmemcpy_bad_done
+
+.Lmemcpy_bad3_loop4:
+#ifdef __ARMEB__
+	mov	r4, ip, lsl #24
+#else
+	mov	r4, ip, lsr #24
+#endif
+	ldr	ip, [r1], #0x04
+	subs	r2, r2, #0x04
+#ifdef __ARMEB__
+	orr	r4, r4, ip, lsr #8
+#else
+	orr	r4, r4, ip, lsl #8
+#endif
+	str	r4, [r3], #0x04
+	bge	.Lmemcpy_bad3_loop4
+	sub	r1, r1, #0x01
+
+.Lmemcpy_bad_done:
+	ldmfd	sp!, {r4-r7}
+	adds	r2, r2, #0x04
+	bxeq	lr
+	ldrb	ip, [r1], #0x01
+	cmp	r2, #0x02
+	ldrgeb	r2, [r1], #0x01
+	strb	ip, [r3], #0x01
+	ldrgtb	ip, [r1]
+	strgeb	r2, [r3], #0x01
+	strgtb	ip, [r3]
+	bx	lr
+
+
+/*
+ * Handle short copies (less than 16 bytes), possibly misaligned.
+ * Some of these are *very* common, thanks to the network stack,
+ * and so are handled specially.
+ */
+.Lmemcpy_short:
+#ifndef _STANDALONE
+	add	pc, pc, r2, lsl #2
+	nop
+	bx	lr			/* 0x00 */
+	b	.Lmemcpy_bytewise	/* 0x01 */
+	b	.Lmemcpy_bytewise	/* 0x02 */
+	b	.Lmemcpy_bytewise	/* 0x03 */
+	b	.Lmemcpy_4		/* 0x04 */
+	b	.Lmemcpy_bytewise	/* 0x05 */
+	b	.Lmemcpy_6		/* 0x06 */
+	b	.Lmemcpy_bytewise	/* 0x07 */
+	b	.Lmemcpy_8		/* 0x08 */
+	b	.Lmemcpy_bytewise	/* 0x09 */
+	b	.Lmemcpy_bytewise	/* 0x0a */
+	b	.Lmemcpy_bytewise	/* 0x0b */
+	b	.Lmemcpy_c		/* 0x0c */
+#endif
+.Lmemcpy_bytewise:
+	mov	r3, r0			/* We must not clobber r0 */
+	ldrb	ip, [r1], #0x01
+1:	subs	r2, r2, #0x01
+	strb	ip, [r3], #0x01
+	ldrneb	ip, [r1], #0x01
+	bne	1b
+	bx	lr
+
+#ifndef _STANDALONE
+/******************************************************************************
+ * Special case for 4 byte copies
+ */
+#define	LMEMCPY_4_LOG2	6	/* 64 bytes */
+#define	LMEMCPY_4_PAD	.align LMEMCPY_4_LOG2
+	LMEMCPY_4_PAD
+.Lmemcpy_4:
+	and	r2, r1, #0x03
+	orr	r2, r2, r0, lsl #2
+	ands	r2, r2, #0x0f
+	sub	r3, pc, #0x14
+	addne	pc, r3, r2, lsl #LMEMCPY_4_LOG2
+
+/*
+ * 0000: dst is 32-bit aligned, src is 32-bit aligned
+ */
+	ldr	r2, [r1]
+	str	r2, [r0]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 0001: dst is 32-bit aligned, src is 8-bit aligned
+ */
+	ldr	r3, [r1, #-1]		/* BE:r3 = x012  LE:r3 = 210x */
+	ldr	r2, [r1, #3]		/* BE:r2 = 3xxx  LE:r2 = xxx3 */
+#ifdef __ARMEB__
+	mov	r3, r3, lsl #8		/* r3 = 012. */
+	orr	r3, r3, r2, lsr #24	/* r3 = 0123 */
+#else
+	mov	r3, r3, lsr #8		/* r3 = .210 */
+	orr	r3, r3, r2, lsl #24	/* r3 = 3210 */
+#endif
+	str	r3, [r0]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 0010: dst is 32-bit aligned, src is 16-bit aligned
+ */
+#ifdef __ARMEB__
+	ldrh	r3, [r1]
+	ldrh	r2, [r1, #0x02]
+#else
+	ldrh	r3, [r1, #0x02]
+	ldrh	r2, [r1]
+#endif
+	orr	r3, r2, r3, lsl #16
+	str	r3, [r0]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 0011: dst is 32-bit aligned, src is 8-bit aligned
+ */
+	ldr	r3, [r1, #-3]		/* BE:r3 = xxx0  LE:r3 = 0xxx */
+	ldr	r2, [r1, #1]		/* BE:r2 = 123x  LE:r2 = x321 */
+#ifdef __ARMEB__
+	mov	r3, r3, lsl #24		/* r3 = 0... */
+	orr	r3, r3, r2, lsr #8	/* r3 = 0123 */
+#else
+	mov	r3, r3, lsr #24		/* r3 = ...0 */
+	orr	r3, r3, r2, lsl #8	/* r3 = 3210 */
+#endif
+	str	r3, [r0]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 0100: dst is 8-bit aligned, src is 32-bit aligned
+ */
+	ldr	r2, [r1]
+#ifdef __ARMEB__
+	strb	r2, [r0, #0x03]
+	mov	r3, r2, lsr #8
+	mov	r1, r2, lsr #24
+	strb	r1, [r0]
+#else
+	strb	r2, [r0]
+	mov	r3, r2, lsr #8
+	mov	r1, r2, lsr #24
+	strb	r1, [r0, #0x03]
+#endif
+	strh	r3, [r0, #0x01]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 0101: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldrh	r3, [r1, #0x01]
+	ldrb	r1, [r1, #0x03]
+	strb	r2, [r0]
+	strh	r3, [r0, #0x01]
+	strb	r1, [r0, #0x03]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 0110: dst is 8-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	ldrh	r3, [r1, #0x02]		/* LE:r3 = ..23  LE:r3 = ..32 */
+#ifdef __ARMEB__
+	mov	r1, r2, lsr #8		/* r1 = ...0 */
+	strb	r1, [r0]
+	mov	r2, r2, lsl #8		/* r2 = .01. */
+	orr	r2, r2, r3, lsr #8	/* r2 = .012 */
+#else
+	strb	r2, [r0]
+	mov	r2, r2, lsr #8		/* r2 = ...1 */
+	orr	r2, r2, r3, lsl #8	/* r2 = .321 */
+	mov	r3, r3, lsr #8		/* r3 = ...3 */
+#endif
+	strh	r2, [r0, #0x01]
+	strb	r3, [r0, #0x03]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 0111: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldrh	r3, [r1, #0x01]
+	ldrb	r1, [r1, #0x03]
+	strb	r2, [r0]
+	strh	r3, [r0, #0x01]
+	strb	r1, [r0, #0x03]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 1000: dst is 16-bit aligned, src is 32-bit aligned
+ */
+	ldr	r2, [r1]
+#ifdef __ARMEB__
+	strh	r2, [r0, #0x02]
+	mov	r3, r2, lsr #16
+	strh	r3, [r0]
+#else
+	strh	r2, [r0]
+	mov	r3, r2, lsr #16
+	strh	r3, [r0, #0x02]
+#endif
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 1001: dst is 16-bit aligned, src is 8-bit aligned
+ */
+	ldr	r2, [r1, #-1]		/* BE:r2 = x012  LE:r2 = 210x */
+	ldr	r3, [r1, #3]		/* BE:r3 = 3xxx  LE:r3 = xxx3 */
+	mov	r1, r2, lsr #8		/* BE:r1 = .x01  LE:r1 = .210 */
+	strh	r1, [r0]
+#ifdef __ARMEB__
+	mov	r2, r2, lsl #8		/* r2 = 012. */
+	orr	r2, r2, r3, lsr #24	/* r2 = 0123 */
+#else
+	mov	r2, r2, lsr #24		/* r2 = ...2 */
+	orr	r2, r2, r3, lsl #8	/* r2 = xx32 */
+#endif
+	strh	r2, [r0, #0x02]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 1010: dst is 16-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]
+	ldrh	r3, [r1, #0x02]
+	strh	r2, [r0]
+	strh	r3, [r0, #0x02]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 1011: dst is 16-bit aligned, src is 8-bit aligned
+ */
+	ldr	r3, [r1, #1]		/* BE:r3 = 123x  LE:r3 = x321 */
+	ldr	r2, [r1, #-3]		/* BE:r2 = xxx0  LE:r2 = 0xxx */
+	mov	r1, r3, lsr #8		/* BE:r1 = .123  LE:r1 = .x32 */
+	strh	r1, [r0, #0x02]
+#ifdef __ARMEB__
+	mov	r3, r3, lsr #24		/* r3 = ...1 */
+	orr	r3, r3, r2, lsl #8	/* r3 = xx01 */
+#else
+	mov	r3, r3, lsl #8		/* r3 = 321. */
+	orr	r3, r3, r2, lsr #24	/* r3 = 3210 */
+#endif
+	strh	r3, [r0]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 1100: dst is 8-bit aligned, src is 32-bit aligned
+ */
+	ldr	r2, [r1]		/* BE:r2 = 0123  LE:r2 = 3210 */
+#ifdef __ARMEB__
+	strb	r2, [r0, #0x03]
+	mov	r3, r2, lsr #8
+	mov	r1, r2, lsr #24
+	strh	r3, [r0, #0x01]
+	strb	r1, [r0]
+#else
+	strb	r2, [r0]
+	mov	r3, r2, lsr #8
+	mov	r1, r2, lsr #24
+	strh	r3, [r0, #0x01]
+	strb	r1, [r0, #0x03]
+#endif
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 1101: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldrh	r3, [r1, #0x01]
+	ldrb	r1, [r1, #0x03]
+	strb	r2, [r0]
+	strh	r3, [r0, #0x01]
+	strb	r1, [r0, #0x03]
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 1110: dst is 8-bit aligned, src is 16-bit aligned
+ */
+#ifdef __ARMEB__
+	ldrh	r3, [r1, #0x02]		/* BE:r3 = ..23  LE:r3 = ..32 */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	strb	r3, [r0, #0x03]
+	mov	r3, r3, lsr #8		/* r3 = ...2 */
+	orr	r3, r3, r2, lsl #8	/* r3 = ..12 */
+	strh	r3, [r0, #0x01]
+	mov	r2, r2, lsr #8		/* r2 = ...0 */
+	strb	r2, [r0]
+#else
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	ldrh	r3, [r1, #0x02]		/* BE:r3 = ..23  LE:r3 = ..32 */
+	strb	r2, [r0]
+	mov	r2, r2, lsr #8		/* r2 = ...1 */
+	orr	r2, r2, r3, lsl #8	/* r2 = .321 */
+	strh	r2, [r0, #0x01]
+	mov	r3, r3, lsr #8		/* r3 = ...3 */
+	strb	r3, [r0, #0x03]
+#endif
+	bx	lr
+	LMEMCPY_4_PAD
+
+/*
+ * 1111: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldrh	r3, [r1, #0x01]
+	ldrb	r1, [r1, #0x03]
+	strb	r2, [r0]
+	strh	r3, [r0, #0x01]
+	strb	r1, [r0, #0x03]
+	bx	lr
+	LMEMCPY_4_PAD
+
+
+/******************************************************************************
+ * Special case for 6 byte copies
+ */
+#define	LMEMCPY_6_LOG2	6	/* 64 bytes */
+#define	LMEMCPY_6_PAD	.align LMEMCPY_6_LOG2
+	LMEMCPY_6_PAD
+.Lmemcpy_6:
+	and	r2, r1, #0x03
+	orr	r2, r2, r0, lsl #2
+	ands	r2, r2, #0x0f
+	sub	r3, pc, #0x14
+	addne	pc, r3, r2, lsl #LMEMCPY_6_LOG2
+
+/*
+ * 0000: dst is 32-bit aligned, src is 32-bit aligned
+ */
+	ldr	r2, [r1]
+	ldrh	r3, [r1, #0x04]
+	str	r2, [r0]
+	strh	r3, [r0, #0x04]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 0001: dst is 32-bit aligned, src is 8-bit aligned
+ */
+	ldr	r2, [r1, #-1]		/* BE:r2 = x012  LE:r2 = 210x */
+	ldr	r3, [r1, #0x03]		/* BE:r3 = 345x  LE:r3 = x543 */
+#ifdef __ARMEB__
+	mov	r2, r2, lsl #8		/* r2 = 012. */
+	orr	r2, r2, r3, lsr #24	/* r2 = 0123 */
+#else
+	mov	r2, r2, lsr #8		/* r2 = .210 */
+	orr	r2, r2, r3, lsl #24	/* r2 = 3210 */
+#endif
+	mov	r3, r3, lsr #8		/* BE:r3 = .345  LE:r3 = .x54 */
+	str	r2, [r0]
+	strh	r3, [r0, #0x04]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 0010: dst is 32-bit aligned, src is 16-bit aligned
+ */
+	ldr	r3, [r1, #0x02]		/* BE:r3 = 2345  LE:r3 = 5432 */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+#ifdef __ARMEB__
+	mov	r1, r3, lsr #16		/* r1 = ..23 */
+	orr	r1, r1, r2, lsl #16	/* r1 = 0123 */
+	str	r1, [r0]
+	strh	r3, [r0, #0x04]
+#else
+	mov	r1, r3, lsr #16		/* r1 = ..54 */
+	orr	r2, r2, r3, lsl #16	/* r2 = 3210 */
+	str	r2, [r0]
+	strh	r1, [r0, #0x04]
+#endif
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 0011: dst is 32-bit aligned, src is 8-bit aligned
+ */
+	ldr	r2, [r1, #-3]		/* BE:r2 = xxx0  LE:r2 = 0xxx */
+	ldr	r3, [r1, #1]		/* BE:r3 = 1234  LE:r3 = 4321 */
+	ldr	r1, [r1, #5]		/* BE:r1 = 5xxx  LE:r3 = xxx5 */
+#ifdef __ARMEB__
+	mov	r2, r2, lsl #24		/* r2 = 0... */
+	orr	r2, r2, r3, lsr #8	/* r2 = 0123 */
+	mov	r3, r3, lsl #8		/* r3 = 234. */
+	orr	r1, r3, r1, lsr #24	/* r1 = 2345 */
+#else
+	mov	r2, r2, lsr #24		/* r2 = ...0 */
+	orr	r2, r2, r3, lsl #8	/* r2 = 3210 */
+	mov	r1, r1, lsl #8		/* r1 = xx5. */
+	orr	r1, r1, r3, lsr #24	/* r1 = xx54 */
+#endif
+	str	r2, [r0]
+	strh	r1, [r0, #0x04]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 0100: dst is 8-bit aligned, src is 32-bit aligned
+ */
+	ldr	r3, [r1]		/* BE:r3 = 0123  LE:r3 = 3210 */
+	ldrh	r2, [r1, #0x04]		/* BE:r2 = ..45  LE:r2 = ..54 */
+	mov	r1, r3, lsr #8		/* BE:r1 = .012  LE:r1 = .321 */
+	strh	r1, [r0, #0x01]
+#ifdef __ARMEB__
+	mov	r1, r3, lsr #24		/* r1 = ...0 */
+	strb	r1, [r0]
+	mov	r3, r3, lsl #8		/* r3 = 123. */
+	orr	r3, r3, r2, lsr #8	/* r3 = 1234 */
+#else
+	strb	r3, [r0]
+	mov	r3, r3, lsr #24		/* r3 = ...3 */
+	orr	r3, r3, r2, lsl #8	/* r3 = .543 */
+	mov	r2, r2, lsr #8		/* r2 = ...5 */
+#endif
+	strh	r3, [r0, #0x03]
+	strb	r2, [r0, #0x05]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 0101: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldrh	r3, [r1, #0x01]
+	ldrh	ip, [r1, #0x03]
+	ldrb	r1, [r1, #0x05]
+	strb	r2, [r0]
+	strh	r3, [r0, #0x01]
+	strh	ip, [r0, #0x03]
+	strb	r1, [r0, #0x05]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 0110: dst is 8-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	ldr	r1, [r1, #0x02]		/* BE:r1 = 2345  LE:r1 = 5432 */
+#ifdef __ARMEB__
+	mov	r3, r2, lsr #8		/* r3 = ...0 */
+	strb	r3, [r0]
+	strb	r1, [r0, #0x05]
+	mov	r3, r1, lsr #8		/* r3 = .234 */
+	strh	r3, [r0, #0x03]
+	mov	r3, r2, lsl #8		/* r3 = .01. */
+	orr	r3, r3, r1, lsr #24	/* r3 = .012 */
+	strh	r3, [r0, #0x01]
+#else
+	strb	r2, [r0]
+	mov	r3, r1, lsr #24
+	strb	r3, [r0, #0x05]
+	mov	r3, r1, lsr #8		/* r3 = .543 */
+	strh	r3, [r0, #0x03]
+	mov	r3, r2, lsr #8		/* r3 = ...1 */
+	orr	r3, r3, r1, lsl #8	/* r3 = 4321 */
+	strh	r3, [r0, #0x01]
+#endif
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 0111: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldrh	r3, [r1, #0x01]
+	ldrh	ip, [r1, #0x03]
+	ldrb	r1, [r1, #0x05]
+	strb	r2, [r0]
+	strh	r3, [r0, #0x01]
+	strh	ip, [r0, #0x03]
+	strb	r1, [r0, #0x05]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 1000: dst is 16-bit aligned, src is 32-bit aligned
+ */
+#ifdef __ARMEB__
+	ldr	r2, [r1]		/* r2 = 0123 */
+	ldrh	r3, [r1, #0x04]		/* r3 = ..45 */
+	mov	r1, r2, lsr #16		/* r1 = ..01 */
+	orr	r3, r3, r2, lsl#16	/* r3 = 2345 */
+	strh	r1, [r0]
+	str	r3, [r0, #0x02]
+#else
+	ldrh	r2, [r1, #0x04]		/* r2 = ..54 */
+	ldr	r3, [r1]		/* r3 = 3210 */
+	mov	r2, r2, lsl #16		/* r2 = 54.. */
+	orr	r2, r2, r3, lsr #16	/* r2 = 5432 */
+	strh	r3, [r0]
+	str	r2, [r0, #0x02]
+#endif
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 1001: dst is 16-bit aligned, src is 8-bit aligned
+ */
+	ldr	r3, [r1, #-1]		/* BE:r3 = x012  LE:r3 = 210x */
+	ldr	r2, [r1, #3]		/* BE:r2 = 345x  LE:r2 = x543 */
+	mov	r1, r3, lsr #8		/* BE:r1 = .x01  LE:r1 = .210 */
+#ifdef __ARMEB__
+	mov	r2, r2, lsr #8		/* r2 = .345 */
+	orr	r2, r2, r3, lsl #24	/* r2 = 2345 */
+#else
+	mov	r2, r2, lsl #8		/* r2 = 543. */
+	orr	r2, r2, r3, lsr #24	/* r2 = 5432 */
+#endif
+	strh	r1, [r0]
+	str	r2, [r0, #0x02]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 1010: dst is 16-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]
+	ldr	r3, [r1, #0x02]
+	strh	r2, [r0]
+	str	r3, [r0, #0x02]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 1011: dst is 16-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r3, [r1]		/* r3 = ...0 */
+	ldr	r2, [r1, #0x01]		/* BE:r2 = 1234  LE:r2 = 4321 */
+	ldrb	r1, [r1, #0x05]		/* r1 = ...5 */
+#ifdef __ARMEB__
+	mov	r3, r3, lsl #8		/* r3 = ..0. */
+	orr	r3, r3, r2, lsr #24	/* r3 = ..01 */
+	orr	r1, r1, r2, lsl #8	/* r1 = 2345 */
+#else
+	orr	r3, r3, r2, lsl #8	/* r3 = 3210 */
+	mov	r1, r1, lsl #24		/* r1 = 5... */
+	orr	r1, r1, r2, lsr #8	/* r1 = 5432 */
+#endif
+	strh	r3, [r0]
+	str	r1, [r0, #0x02]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 1100: dst is 8-bit aligned, src is 32-bit aligned
+ */
+	ldr	r2, [r1]		/* BE:r2 = 0123  LE:r2 = 3210 */
+	ldrh	r1, [r1, #0x04]		/* BE:r1 = ..45  LE:r1 = ..54 */
+#ifdef __ARMEB__
+	mov	r3, r2, lsr #24		/* r3 = ...0 */
+	strb	r3, [r0]
+	mov	r2, r2, lsl #8		/* r2 = 123. */
+	orr	r2, r2, r1, lsr #8	/* r2 = 1234 */
+#else
+	strb	r2, [r0]
+	mov	r2, r2, lsr #8		/* r2 = .321 */
+	orr	r2, r2, r1, lsl #24	/* r2 = 4321 */
+	mov	r1, r1, lsr #8		/* r1 = ...5 */
+#endif
+	str	r2, [r0, #0x01]
+	strb	r1, [r0, #0x05]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 1101: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldrh	r3, [r1, #0x01]
+	ldrh	ip, [r1, #0x03]
+	ldrb	r1, [r1, #0x05]
+	strb	r2, [r0]
+	strh	r3, [r0, #0x01]
+	strh	ip, [r0, #0x03]
+	strb	r1, [r0, #0x05]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 1110: dst is 8-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	ldr	r1, [r1, #0x02]		/* BE:r1 = 2345  LE:r1 = 5432 */
+#ifdef __ARMEB__
+	mov	r3, r2, lsr #8		/* r3 = ...0 */
+	strb	r3, [r0]
+	mov	r2, r2, lsl #24		/* r2 = 1... */
+	orr	r2, r2, r1, lsr #8	/* r2 = 1234 */
+#else
+	strb	r2, [r0]
+	mov	r2, r2, lsr #8		/* r2 = ...1 */
+	orr	r2, r2, r1, lsl #8	/* r2 = 4321 */
+	mov	r1, r1, lsr #24		/* r1 = ...5 */
+#endif
+	str	r2, [r0, #0x01]
+	strb	r1, [r0, #0x05]
+	bx	lr
+	LMEMCPY_6_PAD
+
+/*
+ * 1111: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldr	r3, [r1, #0x01]
+	ldrb	r1, [r1, #0x05]
+	strb	r2, [r0]
+	str	r3, [r0, #0x01]
+	strb	r1, [r0, #0x05]
+	bx	lr
+	LMEMCPY_6_PAD
+
+
+/******************************************************************************
+ * Special case for 8 byte copies
+ */
+#define	LMEMCPY_8_LOG2	6	/* 64 bytes */
+#define	LMEMCPY_8_PAD	.align LMEMCPY_8_LOG2
+	LMEMCPY_8_PAD
+.Lmemcpy_8:
+	and	r2, r1, #0x03
+	orr	r2, r2, r0, lsl #2
+	ands	r2, r2, #0x0f
+	sub	r3, pc, #0x14
+	addne	pc, r3, r2, lsl #LMEMCPY_8_LOG2
+
+/*
+ * 0000: dst is 32-bit aligned, src is 32-bit aligned
+ */
+	ldr	r2, [r1]
+	ldr	r3, [r1, #0x04]
+	str	r2, [r0]
+	str	r3, [r0, #0x04]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 0001: dst is 32-bit aligned, src is 8-bit aligned
+ */
+	ldr	r3, [r1, #-1]		/* BE:r3 = x012  LE:r3 = 210x */
+	ldr	r2, [r1, #0x03]		/* BE:r2 = 3456  LE:r2 = 6543 */
+	ldrb	r1, [r1, #0x07]		/* r1 = ...7 */
+#ifdef __ARMEB__
+	mov	r3, r3, lsl #8		/* r3 = 012. */
+	orr	r3, r3, r2, lsr #24	/* r3 = 0123 */
+	orr	r2, r1, r2, lsl #8	/* r2 = 4567 */
+#else
+	mov	r3, r3, lsr #8		/* r3 = .210 */
+	orr	r3, r3, r2, lsl #24	/* r3 = 3210 */
+	mov	r1, r1, lsl #24		/* r1 = 7... */
+	orr	r2, r1, r2, lsr #8	/* r2 = 7654 */
+#endif
+	str	r3, [r0]
+	str	r2, [r0, #0x04]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 0010: dst is 32-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	ldr	r3, [r1, #0x02]		/* BE:r3 = 2345  LE:r3 = 5432 */
+	ldrh	r1, [r1, #0x06]		/* BE:r1 = ..67  LE:r1 = ..76 */
+#ifdef __ARMEB__
+	mov	r2, r2, lsl #16		/* r2 = 01.. */
+	orr	r2, r2, r3, lsr #16	/* r2 = 0123 */
+	orr	r3, r1, r3, lsl #16	/* r3 = 4567 */
+#else
+	orr	r2, r2, r3, lsl #16	/* r2 = 3210 */
+	mov	r3, r3, lsr #16		/* r3 = ..54 */
+	orr	r3, r3, r1, lsl #16	/* r3 = 7654 */
+#endif
+	str	r2, [r0]
+	str	r3, [r0, #0x04]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 0011: dst is 32-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r3, [r1]		/* r3 = ...0 */
+	ldr	r2, [r1, #0x01]		/* BE:r2 = 1234  LE:r2 = 4321 */
+	ldr	r1, [r1, #0x05]		/* BE:r1 = 567x  LE:r1 = x765 */
+#ifdef __ARMEB__
+	mov	r3, r3, lsl #24		/* r3 = 0... */
+	orr	r3, r3, r2, lsr #8	/* r3 = 0123 */
+	mov	r2, r2, lsl #24		/* r2 = 4... */
+	orr	r2, r2, r1, lsr #8	/* r2 = 4567 */
+#else
+	orr	r3, r3, r2, lsl #8	/* r3 = 3210 */
+	mov	r2, r2, lsr #24		/* r2 = ...4 */
+	orr	r2, r2, r1, lsl #8	/* r2 = 7654 */
+#endif
+	str	r3, [r0]
+	str	r2, [r0, #0x04]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 0100: dst is 8-bit aligned, src is 32-bit aligned
+ */
+	ldr	r3, [r1]		/* BE:r3 = 0123  LE:r3 = 3210 */
+	ldr	r2, [r1, #0x04]		/* BE:r2 = 4567  LE:r2 = 7654 */
+#ifdef __ARMEB__
+	mov	r1, r3, lsr #24		/* r1 = ...0 */
+	strb	r1, [r0]
+	mov	r1, r3, lsr #8		/* r1 = .012 */
+	strb	r2, [r0, #0x07]
+	mov	r3, r3, lsl #24		/* r3 = 3... */
+	orr	r3, r3, r2, lsr #8	/* r3 = 3456 */
+#else
+	strb	r3, [r0]
+	mov	r1, r2, lsr #24		/* r1 = ...7 */
+	strb	r1, [r0, #0x07]
+	mov	r1, r3, lsr #8		/* r1 = .321 */
+	mov	r3, r3, lsr #24		/* r3 = ...3 */
+	orr	r3, r3, r2, lsl #8	/* r3 = 6543 */
+#endif
+	strh	r1, [r0, #0x01]
+	str	r3, [r0, #0x03]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 0101: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldrh	r3, [r1, #0x01]
+	ldr	ip, [r1, #0x03]
+	ldrb	r1, [r1, #0x07]
+	strb	r2, [r0]
+	strh	r3, [r0, #0x01]
+	str	ip, [r0, #0x03]
+	strb	r1, [r0, #0x07]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 0110: dst is 8-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	ldr	r3, [r1, #0x02]		/* BE:r3 = 2345  LE:r3 = 5432 */
+	ldrh	r1, [r1, #0x06]		/* BE:r1 = ..67  LE:r1 = ..76 */
+#ifdef __ARMEB__
+	mov	ip, r2, lsr #8		/* ip = ...0 */
+	strb	ip, [r0]
+	mov	ip, r2, lsl #8		/* ip = .01. */
+	orr	ip, ip, r3, lsr #24	/* ip = .012 */
+	strb	r1, [r0, #0x07]
+	mov	r3, r3, lsl #8		/* r3 = 345. */
+	orr	r3, r3, r1, lsr #8	/* r3 = 3456 */
+#else
+	strb	r2, [r0]		/* 0 */
+	mov	ip, r1, lsr #8		/* ip = ...7 */
+	strb	ip, [r0, #0x07]		/* 7 */
+	mov	ip, r2, lsr #8		/* ip = ...1 */
+	orr	ip, ip, r3, lsl #8	/* ip = 4321 */
+	mov	r3, r3, lsr #8		/* r3 = .543 */
+	orr	r3, r3, r1, lsl #24	/* r3 = 6543 */
+#endif
+	strh	ip, [r0, #0x01]
+	str	r3, [r0, #0x03]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 0111: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r3, [r1]		/* r3 = ...0 */
+	ldr	ip, [r1, #0x01]		/* BE:ip = 1234  LE:ip = 4321 */
+	ldrh	r2, [r1, #0x05]		/* BE:r2 = ..56  LE:r2 = ..65 */
+	ldrb	r1, [r1, #0x07]		/* r1 = ...7 */
+	strb	r3, [r0]
+	mov	r3, ip, lsr #16		/* BE:r3 = ..12  LE:r3 = ..43 */
+#ifdef __ARMEB__
+	strh	r3, [r0, #0x01]
+	orr	r2, r2, ip, lsl #16	/* r2 = 3456 */
+#else
+	strh	ip, [r0, #0x01]
+	orr	r2, r3, r2, lsl #16	/* r2 = 6543 */
+#endif
+	str	r2, [r0, #0x03]
+	strb	r1, [r0, #0x07]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 1000: dst is 16-bit aligned, src is 32-bit aligned
+ */
+	ldr	r2, [r1]		/* BE:r2 = 0123  LE:r2 = 3210 */
+	ldr	r3, [r1, #0x04]		/* BE:r3 = 4567  LE:r3 = 7654 */
+	mov	r1, r2, lsr #16		/* BE:r1 = ..01  LE:r1 = ..32 */
+#ifdef __ARMEB__
+	strh	r1, [r0]
+	mov	r1, r3, lsr #16		/* r1 = ..45 */
+	orr	r2, r1 ,r2, lsl #16	/* r2 = 2345 */
+#else
+	strh	r2, [r0]
+	orr	r2, r1, r3, lsl #16	/* r2 = 5432 */
+	mov	r3, r3, lsr #16		/* r3 = ..76 */
+#endif
+	str	r2, [r0, #0x02]
+	strh	r3, [r0, #0x06]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 1001: dst is 16-bit aligned, src is 8-bit aligned
+ */
+	ldr	r2, [r1, #-1]		/* BE:r2 = x012  LE:r2 = 210x */
+	ldr	r3, [r1, #0x03]		/* BE:r3 = 3456  LE:r3 = 6543 */
+	ldrb	ip, [r1, #0x07]		/* ip = ...7 */
+	mov	r1, r2, lsr #8		/* BE:r1 = .x01  LE:r1 = .210 */
+	strh	r1, [r0]
+#ifdef __ARMEB__
+	mov	r1, r2, lsl #24		/* r1 = 2... */
+	orr	r1, r1, r3, lsr #8	/* r1 = 2345 */
+	orr	r3, ip, r3, lsl #8	/* r3 = 4567 */
+#else
+	mov	r1, r2, lsr #24		/* r1 = ...2 */
+	orr	r1, r1, r3, lsl #8	/* r1 = 5432 */
+	mov	r3, r3, lsr #24		/* r3 = ...6 */
+	orr	r3, r3, ip, lsl #8	/* r3 = ..76 */
+#endif
+	str	r1, [r0, #0x02]
+	strh	r3, [r0, #0x06]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 1010: dst is 16-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]
+	ldr	ip, [r1, #0x02]
+	ldrh	r3, [r1, #0x06]
+	strh	r2, [r0]
+	str	ip, [r0, #0x02]
+	strh	r3, [r0, #0x06]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 1011: dst is 16-bit aligned, src is 8-bit aligned
+ */
+	ldr	r3, [r1, #0x05]		/* BE:r3 = 567x  LE:r3 = x765 */
+	ldr	r2, [r1, #0x01]		/* BE:r2 = 1234  LE:r2 = 4321 */
+	ldrb	ip, [r1]		/* ip = ...0 */
+	mov	r1, r3, lsr #8		/* BE:r1 = .567  LE:r1 = .x76 */
+	strh	r1, [r0, #0x06]
+#ifdef __ARMEB__
+	mov	r3, r3, lsr #24		/* r3 = ...5 */
+	orr	r3, r3, r2, lsl #8	/* r3 = 2345 */
+	mov	r2, r2, lsr #24		/* r2 = ...1 */
+	orr	r2, r2, ip, lsl #8	/* r2 = ..01 */
+#else
+	mov	r3, r3, lsl #24		/* r3 = 5... */
+	orr	r3, r3, r2, lsr #8	/* r3 = 5432 */
+	orr	r2, ip, r2, lsl #8	/* r2 = 3210 */
+#endif
+	str	r3, [r0, #0x02]
+	strh	r2, [r0]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 1100: dst is 8-bit aligned, src is 32-bit aligned
+ */
+	ldr	r3, [r1, #0x04]		/* BE:r3 = 4567  LE:r3 = 7654 */
+	ldr	r2, [r1]		/* BE:r2 = 0123  LE:r2 = 3210 */
+	mov	r1, r3, lsr #8		/* BE:r1 = .456  LE:r1 = .765 */
+	strh	r1, [r0, #0x05]
+#ifdef __ARMEB__
+	strb	r3, [r0, #0x07]
+	mov	r1, r2, lsr #24		/* r1 = ...0 */
+	strb	r1, [r0]
+	mov	r2, r2, lsl #8		/* r2 = 123. */
+	orr	r2, r2, r3, lsr #24	/* r2 = 1234 */
+	str	r2, [r0, #0x01]
+#else
+	strb	r2, [r0]
+	mov	r1, r3, lsr #24		/* r1 = ...7 */
+	strb	r1, [r0, #0x07]
+	mov	r2, r2, lsr #8		/* r2 = .321 */
+	orr	r2, r2, r3, lsl #24	/* r2 = 4321 */
+	str	r2, [r0, #0x01]
+#endif
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 1101: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r3, [r1]		/* r3 = ...0 */
+	ldrh	r2, [r1, #0x01]		/* BE:r2 = ..12  LE:r2 = ..21 */
+	ldr	ip, [r1, #0x03]		/* BE:ip = 3456  LE:ip = 6543 */
+	ldrb	r1, [r1, #0x07]		/* r1 = ...7 */
+	strb	r3, [r0]
+	mov	r3, ip, lsr #16		/* BE:r3 = ..34  LE:r3 = ..65 */
+#ifdef __ARMEB__
+	strh	ip, [r0, #0x05]
+	orr	r2, r3, r2, lsl #16	/* r2 = 1234 */
+#else
+	strh	r3, [r0, #0x05]
+	orr	r2, r2, ip, lsl #16	/* r2 = 4321 */
+#endif
+	str	r2, [r0, #0x01]
+	strb	r1, [r0, #0x07]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 1110: dst is 8-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	ldr	r3, [r1, #0x02]		/* BE:r3 = 2345  LE:r3 = 5432 */
+	ldrh	r1, [r1, #0x06]		/* BE:r1 = ..67  LE:r1 = ..76 */
+#ifdef __ARMEB__
+	mov	ip, r2, lsr #8		/* ip = ...0 */
+	strb	ip, [r0]
+	mov	ip, r2, lsl #24		/* ip = 1... */
+	orr	ip, ip, r3, lsr #8	/* ip = 1234 */
+	strb	r1, [r0, #0x07]
+	mov	r1, r1, lsr #8		/* r1 = ...6 */
+	orr	r1, r1, r3, lsl #8	/* r1 = 3456 */
+#else
+	strb	r2, [r0]
+	mov	ip, r2, lsr #8		/* ip = ...1 */
+	orr	ip, ip, r3, lsl #8	/* ip = 4321 */
+	mov	r2, r1, lsr #8		/* r2 = ...7 */
+	strb	r2, [r0, #0x07]
+	mov	r1, r1, lsl #8		/* r1 = .76. */
+	orr	r1, r1, r3, lsr #24	/* r1 = .765 */
+#endif
+	str	ip, [r0, #0x01]
+	strh	r1, [r0, #0x05]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/*
+ * 1111: dst is 8-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]
+	ldr	ip, [r1, #0x01]
+	ldrh	r3, [r1, #0x05]
+	ldrb	r1, [r1, #0x07]
+	strb	r2, [r0]
+	str	ip, [r0, #0x01]
+	strh	r3, [r0, #0x05]
+	strb	r1, [r0, #0x07]
+	bx	lr
+	LMEMCPY_8_PAD
+
+/******************************************************************************
+ * Special case for 12 byte copies
+ */
+#define	LMEMCPY_C_LOG2	7	/* 128 bytes */
+#define	LMEMCPY_C_PAD	.align LMEMCPY_C_LOG2
+	LMEMCPY_C_PAD
+.Lmemcpy_c:
+	and	r2, r1, #0x03
+	orr	r2, r2, r0, lsl #2
+	ands	r2, r2, #0x0f
+	sub	r3, pc, #0x14
+	addne	pc, r3, r2, lsl #LMEMCPY_C_LOG2
+
+/*
+ * 0000: dst is 32-bit aligned, src is 32-bit aligned
+ */
+	ldr	r2, [r1]
+	ldr	r3, [r1, #0x04]
+	ldr	r1, [r1, #0x08]
+	str	r2, [r0]
+	str	r3, [r0, #0x04]
+	str	r1, [r0, #0x08]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 0001: dst is 32-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1, #0xb]		/* r2 = ...B */
+	ldr	ip, [r1, #0x07]		/* BE:ip = 789A  LE:ip = A987 */
+	ldr	r3, [r1, #0x03]		/* BE:r3 = 3456  LE:r3 = 6543 */
+	ldr	r1, [r1, #-1]		/* BE:r1 = x012  LE:r1 = 210x */
+#ifdef __ARMEB__
+	orr	r2, r2, ip, lsl #8	/* r2 = 89AB */
+	str	r2, [r0, #0x08]
+	mov	r2, ip, lsr #24		/* r2 = ...7 */
+	orr	r2, r2, r3, lsl #8	/* r2 = 4567 */
+	mov	r1, r1, lsl #8		/* r1 = 012. */
+	orr	r1, r1, r3, lsr #24	/* r1 = 0123 */
+#else
+	mov	r2, r2, lsl #24		/* r2 = B... */
+	orr	r2, r2, ip, lsr #8	/* r2 = BA98 */
+	str	r2, [r0, #0x08]
+	mov	r2, ip, lsl #24		/* r2 = 7... */
+	orr	r2, r2, r3, lsr #8	/* r2 = 7654 */
+	mov	r1, r1, lsr #8		/* r1 = .210 */
+	orr	r1, r1, r3, lsl #24	/* r1 = 3210 */
+#endif
+	str	r2, [r0, #0x04]
+	str	r1, [r0]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 0010: dst is 32-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	ldr	r3, [r1, #0x02]		/* BE:r3 = 2345  LE:r3 = 5432 */
+	ldr	ip, [r1, #0x06]		/* BE:ip = 6789  LE:ip = 9876 */
+	ldrh	r1, [r1, #0x0a]		/* BE:r1 = ..AB  LE:r1 = ..BA */
+#ifdef __ARMEB__
+	mov	r2, r2, lsl #16		/* r2 = 01.. */
+	orr	r2, r2, r3, lsr #16	/* r2 = 0123 */
+	str	r2, [r0]
+	mov	r3, r3, lsl #16		/* r3 = 45.. */
+	orr	r3, r3, ip, lsr #16	/* r3 = 4567 */
+	orr	r1, r1, ip, lsl #16	/* r1 = 89AB */
+#else
+	orr	r2, r2, r3, lsl #16	/* r2 = 3210 */
+	str	r2, [r0]
+	mov	r3, r3, lsr #16		/* r3 = ..54 */
+	orr	r3, r3, ip, lsl #16	/* r3 = 7654 */
+	mov	r1, r1, lsl #16		/* r1 = BA.. */
+	orr	r1, r1, ip, lsr #16	/* r1 = BA98 */
+#endif
+	str	r3, [r0, #0x04]
+	str	r1, [r0, #0x08]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 0011: dst is 32-bit aligned, src is 8-bit aligned
+ */
+	ldrb	r2, [r1]		/* r2 = ...0 */
+	ldr	r3, [r1, #0x01]		/* BE:r3 = 1234  LE:r3 = 4321 */
+	ldr	ip, [r1, #0x05]		/* BE:ip = 5678  LE:ip = 8765 */
+	ldr	r1, [r1, #0x09]		/* BE:r1 = 9ABx  LE:r1 = xBA9 */
+#ifdef __ARMEB__
+	mov	r2, r2, lsl #24		/* r2 = 0... */
+	orr	r2, r2, r3, lsr #8	/* r2 = 0123 */
+	str	r2, [r0]
+	mov	r3, r3, lsl #24		/* r3 = 4... */
+	orr	r3, r3, ip, lsr #8	/* r3 = 4567 */
+	mov	r1, r1, lsr #8		/* r1 = .9AB */
+	orr	r1, r1, ip, lsl #24	/* r1 = 89AB */
+#else
+	orr	r2, r2, r3, lsl #8	/* r2 = 3210 */
+	str	r2, [r0]
+	mov	r3, r3, lsr #24		/* r3 = ...4 */
+	orr	r3, r3, ip, lsl #8	/* r3 = 7654 */
+	mov	r1, r1, lsl #8		/* r1 = BA9. */
+	orr	r1, r1, ip, lsr #24	/* r1 = BA98 */
+#endif
+	str	r3, [r0, #0x04]
+	str	r1, [r0, #0x08]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 0100: dst is 8-bit aligned (byte 1), src is 32-bit aligned
+ */
+	ldr	r2, [r1]		/* BE:r2 = 0123  LE:r2 = 3210 */
+	ldr	r3, [r1, #0x04]		/* BE:r3 = 4567  LE:r3 = 7654 */
+	ldr	ip, [r1, #0x08]		/* BE:ip = 89AB  LE:ip = BA98 */
+	mov	r1, r2, lsr #8		/* BE:r1 = .012  LE:r1 = .321 */
+	strh	r1, [r0, #0x01]
+#ifdef __ARMEB__
+	mov	r1, r2, lsr #24		/* r1 = ...0 */
+	strb	r1, [r0]
+	mov	r1, r2, lsl #24		/* r1 = 3... */
+	orr	r2, r1, r3, lsr #8	/* r1 = 3456 */
+	mov	r1, r3, lsl #24		/* r1 = 7... */
+	orr	r1, r1, ip, lsr #8	/* r1 = 789A */
+#else
+	strb	r2, [r0]
+	mov	r1, r2, lsr #24		/* r1 = ...3 */
+	orr	r2, r1, r3, lsl #8	/* r1 = 6543 */
+	mov	r1, r3, lsr #24		/* r1 = ...7 */
+	orr	r1, r1, ip, lsl #8	/* r1 = A987 */
+	mov	ip, ip, lsr #24		/* ip = ...B */
+#endif
+	str	r2, [r0, #0x03]
+	str	r1, [r0, #0x07]
+	strb	ip, [r0, #0x0b]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 0101: dst is 8-bit aligned (byte 1), src is 8-bit aligned (byte 1)
+ */
+	ldrb	r2, [r1]
+	ldrh	r3, [r1, #0x01]
+	ldr	ip, [r1, #0x03]
+	strb	r2, [r0]
+	ldr	r2, [r1, #0x07]
+	ldrb	r1, [r1, #0x0b]
+	strh	r3, [r0, #0x01]
+	str	ip, [r0, #0x03]
+	str	r2, [r0, #0x07]
+	strb	r1, [r0, #0x0b]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 0110: dst is 8-bit aligned (byte 1), src is 16-bit aligned
+ */
+	ldrh	r2, [r1]		/* BE:r2 = ..01  LE:r2 = ..10 */
+	ldr	r3, [r1, #0x02]		/* BE:r3 = 2345  LE:r3 = 5432 */
+	ldr	ip, [r1, #0x06]		/* BE:ip = 6789  LE:ip = 9876 */
+	ldrh	r1, [r1, #0x0a]		/* BE:r1 = ..AB  LE:r1 = ..BA */
+#ifdef __ARMEB__
+	mov	r2, r2, ror #8		/* r2 = 1..0 */
+	strb	r2, [r0]
+	mov	r2, r2, lsr #16		/* r2 = ..1. */
+	orr	r2, r2, r3, lsr #24	/* r2 = ..12 */
+	strh	r2, [r0, #0x01]
+	mov	r2, r3, lsl #8		/* r2 = 345. */
+	orr	r3, r2, ip, lsr #24	/* r3 = 3456 */
+	mov	r2, ip, lsl #8		/* r2 = 789. */
+	orr	r2, r2, r1, lsr #8	/* r2 = 789A */
+#else
+	strb	r2, [r0]
+	mov	r2, r2, lsr #8		/* r2 = ...1 */
+	orr	r2, r2, r3, lsl #8	/* r2 = 4321 */
+	strh	r2, [r0, #0x01]
+	mov	r2, r3, lsr #8		/* r2 = .543 */
+	orr	r3, r2, ip, lsl #24	/* r3 = 6543 */
+	mov	r2, ip, lsr #8		/* r2 = .987 */
+	orr	r2, r2, r1, lsl #24	/* r2 = A987 */
+	mov	r1, r1, lsr #8		/* r1 = ...B */
+#endif
+	str	r3, [r0, #0x03]
+	str	r2, [r0, #0x07]
+	strb	r1, [r0, #0x0b]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 0111: dst is 8-bit aligned (byte 1), src is 8-bit aligned (byte 3)
+ */
+	ldrb	r2, [r1]
+	ldr	r3, [r1, #0x01]		/* BE:r3 = 1234  LE:r3 = 4321 */
+	ldr	ip, [r1, #0x05]		/* BE:ip = 5678  LE:ip = 8765 */
+	ldr	r1, [r1, #0x09]		/* BE:r1 = 9ABx  LE:r1 = xBA9 */
+	strb	r2, [r0]
+#ifdef __ARMEB__
+	mov	r2, r3, lsr #16		/* r2 = ..12 */
+	strh	r2, [r0, #0x01]
+	mov	r3, r3, lsl #16		/* r3 = 34.. */
+	orr	r3, r3, ip, lsr #16	/* r3 = 3456 */
+	mov	ip, ip, lsl #16		/* ip = 78.. */
+	orr	ip, ip, r1, lsr #16	/* ip = 789A */
+	mov	r1, r1, lsr #8		/* r1 = .9AB */
+#else
+	strh	r3, [r0, #0x01]
+	mov	r3, r3, lsr #16		/* r3 = ..43 */
+	orr	r3, r3, ip, lsl #16	/* r3 = 6543 */
+	mov	ip, ip, lsr #16		/* ip = ..87 */
+	orr	ip, ip, r1, lsl #16	/* ip = A987 */
+	mov	r1, r1, lsr #16		/* r1 = ..xB */
+#endif
+	str	r3, [r0, #0x03]
+	str	ip, [r0, #0x07]
+	strb	r1, [r0, #0x0b]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 1000: dst is 16-bit aligned, src is 32-bit aligned
+ */
+	ldr	ip, [r1]		/* BE:ip = 0123  LE:ip = 3210 */
+	ldr	r3, [r1, #0x04]		/* BE:r3 = 4567  LE:r3 = 7654 */
+	ldr	r2, [r1, #0x08]		/* BE:r2 = 89AB  LE:r2 = BA98 */
+	mov	r1, ip, lsr #16		/* BE:r1 = ..01  LE:r1 = ..32 */
+#ifdef __ARMEB__
+	strh	r1, [r0]
+	mov	r1, ip, lsl #16		/* r1 = 23.. */
+	orr	r1, r1, r3, lsr #16	/* r1 = 2345 */
+	mov	r3, r3, lsl #16		/* r3 = 67.. */
+	orr	r3, r3, r2, lsr #16	/* r3 = 6789 */
+#else
+	strh	ip, [r0]
+	orr	r1, r1, r3, lsl #16	/* r1 = 5432 */
+	mov	r3, r3, lsr #16		/* r3 = ..76 */
+	orr	r3, r3, r2, lsl #16	/* r3 = 9876 */
+	mov	r2, r2, lsr #16		/* r2 = ..BA */
+#endif
+	str	r1, [r0, #0x02]
+	str	r3, [r0, #0x06]
+	strh	r2, [r0, #0x0a]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 1001: dst is 16-bit aligned, src is 8-bit aligned (byte 1)
+ */
+	ldr	r2, [r1, #-1]		/* BE:r2 = x012  LE:r2 = 210x */
+	ldr	r3, [r1, #0x03]		/* BE:r3 = 3456  LE:r3 = 6543 */
+	mov	ip, r2, lsr #8		/* BE:ip = .x01  LE:ip = .210 */
+	strh	ip, [r0]
+	ldr	ip, [r1, #0x07]		/* BE:ip = 789A  LE:ip = A987 */
+	ldrb	r1, [r1, #0x0b]		/* r1 = ...B */
+#ifdef __ARMEB__
+	mov	r2, r2, lsl #24		/* r2 = 2... */
+	orr	r2, r2, r3, lsr #8	/* r2 = 2345 */
+	mov	r3, r3, lsl #24		/* r3 = 6... */
+	orr	r3, r3, ip, lsr #8	/* r3 = 6789 */
+	orr	r1, r1, ip, lsl #8	/* r1 = 89AB */
+#else
+	mov	r2, r2, lsr #24		/* r2 = ...2 */
+	orr	r2, r2, r3, lsl #8	/* r2 = 5432 */
+	mov	r3, r3, lsr #24		/* r3 = ...6 */
+	orr	r3, r3, ip, lsl #8	/* r3 = 9876 */
+	mov	r1, r1, lsl #8		/* r1 = ..B. */
+	orr	r1, r1, ip, lsr #24	/* r1 = ..BA */
+#endif
+	str	r2, [r0, #0x02]
+	str	r3, [r0, #0x06]
+	strh	r1, [r0, #0x0a]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 1010: dst is 16-bit aligned, src is 16-bit aligned
+ */
+	ldrh	r2, [r1]
+	ldr	r3, [r1, #0x02]
+	ldr	ip, [r1, #0x06]
+	ldrh	r1, [r1, #0x0a]
+	strh	r2, [r0]
+	str	r3, [r0, #0x02]
+	str	ip, [r0, #0x06]
+	strh	r1, [r0, #0x0a]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 1011: dst is 16-bit aligned, src is 8-bit aligned (byte 3)
+ */
+	ldr	r2, [r1, #0x09]		/* BE:r2 = 9ABx  LE:r2 = xBA9 */
+	ldr	r3, [r1, #0x05]		/* BE:r3 = 5678  LE:r3 = 8765 */
+	mov	ip, r2, lsr #8		/* BE:ip = .9AB  LE:ip = .xBA */
+	strh	ip, [r0, #0x0a]
+	ldr	ip, [r1, #0x01]		/* BE:ip = 1234  LE:ip = 4321 */
+	ldrb	r1, [r1]		/* r1 = ...0 */
+#ifdef __ARMEB__
+	mov	r2, r2, lsr #24		/* r2 = ...9 */
+	orr	r2, r2, r3, lsl #8	/* r2 = 6789 */
+	mov	r3, r3, lsr #24		/* r3 = ...5 */
+	orr	r3, r3, ip, lsl #8	/* r3 = 2345 */
+	mov	r1, r1, lsl #8		/* r1 = ..0. */
+	orr	r1, r1, ip, lsr #24	/* r1 = ..01 */
+#else
+	mov	r2, r2, lsl #24		/* r2 = 9... */
+	orr	r2, r2, r3, lsr #8	/* r2 = 9876 */
+	mov	r3, r3, lsl #24		/* r3 = 5... */
+	orr	r3, r3, ip, lsr #8	/* r3 = 5432 */
+	orr	r1, r1, ip, lsl #8	/* r1 = 3210 */
+#endif
+	str	r2, [r0, #0x06]
+	str	r3, [r0, #0x02]
+	strh	r1, [r0]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 1100: dst is 8-bit aligned (byte 3), src is 32-bit aligned
+ */
+	ldr	r2, [r1]		/* BE:r2 = 0123  LE:r2 = 3210 */
+	ldr	ip, [r1, #0x04]		/* BE:ip = 4567  LE:ip = 7654 */
+	ldr	r1, [r1, #0x08]		/* BE:r1 = 89AB  LE:r1 = BA98 */
+#ifdef __ARMEB__
+	mov	r3, r2, lsr #24		/* r3 = ...0 */
+	strb	r3, [r0]
+	mov	r2, r2, lsl #8		/* r2 = 123. */
+	orr	r2, r2, ip, lsr #24	/* r2 = 1234 */
+	str	r2, [r0, #0x01]
+	mov	r2, ip, lsl #8		/* r2 = 567. */
+	orr	r2, r2, r1, lsr #24	/* r2 = 5678 */
+	str	r2, [r0, #0x05]
+	mov	r2, r1, lsr #8		/* r2 = ..9A */
+	strh	r2, [r0, #0x09]
+	strb	r1, [r0, #0x0b]
+#else
+	strb	r2, [r0]
+	mov	r3, r2, lsr #8		/* r3 = .321 */
+	orr	r3, r3, ip, lsl #24	/* r3 = 4321 */
+	str	r3, [r0, #0x01]
+	mov	r3, ip, lsr #8		/* r3 = .765 */
+	orr	r3, r3, r1, lsl #24	/* r3 = 8765 */
+	str	r3, [r0, #0x05]
+	mov	r1, r1, lsr #8		/* r1 = .BA9 */
+	strh	r1, [r0, #0x09]
+	mov	r1, r1, lsr #16		/* r1 = ...B */
+	strb	r1, [r0, #0x0b]
+#endif
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 1101: dst is 8-bit aligned (byte 3), src is 8-bit aligned (byte 1)
+ */
+	ldrb	r2, [r1, #0x0b]		/* r2 = ...B */
+	ldr	r3, [r1, #0x07]		/* BE:r3 = 789A  LE:r3 = A987 */
+	ldr	ip, [r1, #0x03]		/* BE:ip = 3456  LE:ip = 6543 */
+	ldr	r1, [r1, #-1]		/* BE:r1 = x012  LE:r1 = 210x */
+	strb	r2, [r0, #0x0b]
+#ifdef __ARMEB__
+	strh	r3, [r0, #0x09]
+	mov	r3, r3, lsr #16		/* r3 = ..78 */
+	orr	r3, r3, ip, lsl #16	/* r3 = 5678 */
+	mov	ip, ip, lsr #16		/* ip = ..34 */
+	orr	ip, ip, r1, lsl #16	/* ip = 1234 */
+	mov	r1, r1, lsr #16		/* r1 = ..x0 */
+#else
+	mov	r2, r3, lsr #16		/* r2 = ..A9 */
+	strh	r2, [r0, #0x09]
+	mov	r3, r3, lsl #16		/* r3 = 87.. */
+	orr	r3, r3, ip, lsr #16	/* r3 = 8765 */
+	mov	ip, ip, lsl #16		/* ip = 43.. */
+	orr	ip, ip, r1, lsr #16	/* ip = 4321 */
+	mov	r1, r1, lsr #8		/* r1 = .210 */
+#endif
+	str	r3, [r0, #0x05]
+	str	ip, [r0, #0x01]
+	strb	r1, [r0]
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 1110: dst is 8-bit aligned (byte 3), src is 16-bit aligned
+ */
+#ifdef __ARMEB__
+	ldrh	r2, [r1, #0x0a]		/* r2 = ..AB */
+	ldr	ip, [r1, #0x06]		/* ip = 6789 */
+	ldr	r3, [r1, #0x02]		/* r3 = 2345 */
+	ldrh	r1, [r1]		/* r1 = ..01 */
+	strb	r2, [r0, #0x0b]
+	mov	r2, r2, lsr #8		/* r2 = ...A */
+	orr	r2, r2, ip, lsl #8	/* r2 = 789A */
+	mov	ip, ip, lsr #8		/* ip = .678 */
+	orr	ip, ip, r3, lsl #24	/* ip = 5678 */
+	mov	r3, r3, lsr #8		/* r3 = .234 */
+	orr	r3, r3, r1, lsl #24	/* r3 = 1234 */
+	mov	r1, r1, lsr #8		/* r1 = ...0 */
+	strb	r1, [r0]
+	str	r3, [r0, #0x01]
+	str	ip, [r0, #0x05]
+	strh	r2, [r0, #0x09]
+#else
+	ldrh	r2, [r1]		/* r2 = ..10 */
+	ldr	r3, [r1, #0x02]		/* r3 = 5432 */
+	ldr	ip, [r1, #0x06]		/* ip = 9876 */
+	ldrh	r1, [r1, #0x0a]		/* r1 = ..BA */
+	strb	r2, [r0]
+	mov	r2, r2, lsr #8		/* r2 = ...1 */
+	orr	r2, r2, r3, lsl #8	/* r2 = 4321 */
+	mov	r3, r3, lsr #24		/* r3 = ...5 */
+	orr	r3, r3, ip, lsl #8	/* r3 = 8765 */
+	mov	ip, ip, lsr #24		/* ip = ...9 */
+	orr	ip, ip, r1, lsl #8	/* ip = .BA9 */
+	mov	r1, r1, lsr #8		/* r1 = ...B */
+	str	r2, [r0, #0x01]
+	str	r3, [r0, #0x05]
+	strh	ip, [r0, #0x09]
+	strb	r1, [r0, #0x0b]
+#endif
+	bx	lr
+	LMEMCPY_C_PAD
+
+/*
+ * 1111: dst is 8-bit aligned (byte 3), src is 8-bit aligned (byte 3)
+ */
+	ldrb	r2, [r1]
+	ldr	r3, [r1, #0x01]
+	ldr	ip, [r1, #0x05]
+	strb	r2, [r0]
+	ldrh	r2, [r1, #0x09]
+	ldrb	r1, [r1, #0x0b]
+	str	r3, [r0, #0x01]
+	str	ip, [r0, #0x05]
+	strh	r2, [r0, #0x09]
+	strb	r1, [r0, #0x0b]
+	bx	lr
+#endif	/* !_STANDALONE */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/string/memmove.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,588 @@
+/*	$NetBSD: memmove.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Neil A. Carson and Mark Brinicombe
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the NetBSD
+ *	Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#ifndef _BCOPY
+/* LINTSTUB: Func: void *memmove(void *, const void *, size_t) */
+ENTRY(memmove)
+#else
+/* bcopy = memcpy/memmove with arguments reversed. */
+/* LINTSTUB: Func: void bcopy(void *, void *, size_t) */
+ENTRY(bcopy)
+	/* switch the source and destination registers */
+	eor     r0, r1, r0
+	eor     r1, r0, r1
+	eor     r0, r1, r0
+#endif
+	/* Do the buffers overlap? */
+	cmp	r0, r1
+	RETc(eq)		/* Bail now if src/dst are the same */
+	subcc	r3, r0, r1	/* if (dst > src) r3 = dst - src */
+	subcs	r3, r1, r0	/* if (src > dsr) r3 = src - dst */
+	cmp	r3, r2		/* if (r3 < len) we have an overlap */
+	bcc	PIC_SYM(_C_LABEL(memcpy), PLT)
+
+	/* Determine copy direction */
+	cmp	r1, r0
+	bcc	.Lmemmove_backwards
+
+	moveq	r0, #0			/* Quick abort for len=0 */
+	RETc(eq)
+
+	stmdb	sp!, {r0, lr}		/* memmove() returns dest addr */
+	subs	r2, r2, #4
+	blt	.Lmemmove_fl4		/* less than 4 bytes */
+	ands	r12, r0, #3
+	bne	.Lmemmove_fdestul	/* oh unaligned destination addr */
+	ands	r12, r1, #3
+	bne	.Lmemmove_fsrcul		/* oh unaligned source addr */
+
+.Lmemmove_ft8:
+	/* We have aligned source and destination */
+	subs	r2, r2, #8
+	blt	.Lmemmove_fl12		/* less than 12 bytes (4 from above) */
+	subs	r2, r2, #0x14
+	blt	.Lmemmove_fl32		/* less than 32 bytes (12 from above) */
+	stmdb	sp!, {r4}		/* borrow r4 */
+
+	/* blat 32 bytes at a time */
+	/* XXX for really big copies perhaps we should use more registers */
+.Lmemmove_floop32:
+	ldmia	r1!, {r3, r4, r12, lr}
+	stmia	r0!, {r3, r4, r12, lr}
+	ldmia	r1!, {r3, r4, r12, lr}
+	stmia	r0!, {r3, r4, r12, lr}
+	subs	r2, r2, #0x20
+	bge	.Lmemmove_floop32
+
+	cmn	r2, #0x10
+	ldmgeia	r1!, {r3, r4, r12, lr}	/* blat a remaining 16 bytes */
+	stmgeia	r0!, {r3, r4, r12, lr}
+	subge	r2, r2, #0x10
+	ldmia	sp!, {r4}		/* return r4 */
+
+.Lmemmove_fl32:
+	adds	r2, r2, #0x14
+
+	/* blat 12 bytes at a time */
+.Lmemmove_floop12:
+	ldmgeia	r1!, {r3, r12, lr}
+	stmgeia	r0!, {r3, r12, lr}
+	subges	r2, r2, #0x0c
+	bge	.Lmemmove_floop12
+
+.Lmemmove_fl12:
+	adds	r2, r2, #8
+	blt	.Lmemmove_fl4
+
+	subs	r2, r2, #4
+	ldrlt	r3, [r1], #4
+	strlt	r3, [r0], #4
+	ldmgeia	r1!, {r3, r12}
+	stmgeia	r0!, {r3, r12}
+	subge	r2, r2, #4
+
+.Lmemmove_fl4:
+	/* less than 4 bytes to go */
+	adds	r2, r2, #4
+	ldmeqia	sp!, {r0, pc}		/* done */
+
+	/* copy the crud byte at a time */
+	cmp	r2, #2
+	ldrb	r3, [r1], #1
+	strb	r3, [r0], #1
+	ldrgeb	r3, [r1], #1
+	strgeb	r3, [r0], #1
+	ldrgtb	r3, [r1], #1
+	strgtb	r3, [r0], #1
+	ldmia	sp!, {r0, pc}
+
+	/* erg - unaligned destination */
+.Lmemmove_fdestul:
+	rsb	r12, r12, #4
+	cmp	r12, #2
+
+	/* align destination with byte copies */
+	ldrb	r3, [r1], #1
+	strb	r3, [r0], #1
+	ldrgeb	r3, [r1], #1
+	strgeb	r3, [r0], #1
+	ldrgtb	r3, [r1], #1
+	strgtb	r3, [r0], #1
+	subs	r2, r2, r12
+	blt	.Lmemmove_fl4		/* less the 4 bytes */
+
+	ands	r12, r1, #3
+	beq	.Lmemmove_ft8		/* we have an aligned source */
+
+	/* erg - unaligned source */
+	/* This is where it gets nasty ... */
+.Lmemmove_fsrcul:
+	bic	r1, r1, #3
+	ldr	lr, [r1], #4
+	cmp	r12, #2
+	bgt	.Lmemmove_fsrcul3
+	beq	.Lmemmove_fsrcul2
+	cmp	r2, #0x0c
+	blt	.Lmemmove_fsrcul1loop4
+	sub	r2, r2, #0x0c
+	stmdb	sp!, {r4, r5}
+
+.Lmemmove_fsrcul1loop16:
+#ifdef __ARMEB__
+	mov	r3, lr, lsl #8
+#else
+	mov	r3, lr, lsr #8
+#endif
+	ldmia	r1!, {r4, r5, r12, lr}
+#ifdef __ARMEB__
+	orr	r3, r3, r4, lsr #24
+	mov	r4, r4, lsl #8
+	orr	r4, r4, r5, lsr #24
+	mov	r5, r5, lsl #8
+	orr	r5, r5, r12, lsr #24
+	mov	r12, r12, lsl #8
+	orr	r12, r12, lr, lsr #24
+#else
+	orr	r3, r3, r4, lsl #24
+	mov	r4, r4, lsr #8
+	orr	r4, r4, r5, lsl #24
+	mov	r5, r5, lsr #8
+	orr	r5, r5, r12, lsl #24
+	mov	r12, r12, lsr #8
+	orr	r12, r12, lr, lsl #24
+#endif
+	stmia	r0!, {r3-r5, r12}
+	subs	r2, r2, #0x10
+	bge	.Lmemmove_fsrcul1loop16
+	ldmia	sp!, {r4, r5}
+	adds	r2, r2, #0x0c
+	blt	.Lmemmove_fsrcul1l4
+
+.Lmemmove_fsrcul1loop4:
+#ifdef __ARMEB__
+	mov	r12, lr, lsl #8
+#else
+	mov	r12, lr, lsr #8
+#endif
+	ldr	lr, [r1], #4
+#ifdef __ARMEB__
+	orr	r12, r12, lr, lsr #24
+#else
+	orr	r12, r12, lr, lsl #24
+#endif
+	str	r12, [r0], #4
+	subs	r2, r2, #4
+	bge	.Lmemmove_fsrcul1loop4
+
+.Lmemmove_fsrcul1l4:
+	sub	r1, r1, #3
+	b	.Lmemmove_fl4
+
+.Lmemmove_fsrcul2:
+	cmp	r2, #0x0c
+	blt	.Lmemmove_fsrcul2loop4
+	sub	r2, r2, #0x0c
+	stmdb	sp!, {r4, r5}
+
+.Lmemmove_fsrcul2loop16:
+#ifdef __ARMEB__
+	mov	r3, lr, lsl #16
+#else
+	mov	r3, lr, lsr #16
+#endif
+	ldmia	r1!, {r4, r5, r12, lr}
+#ifdef __ARMEB__
+	orr	r3, r3, r4, lsr #16
+	mov	r4, r4, lsl #16
+	orr	r4, r4, r5, lsr #16
+	mov	r5, r5, lsl #16
+	orr	r5, r5, r12, lsr #16
+	mov	r12, r12, lsl #16
+	orr	r12, r12, lr, lsr #16
+#else
+	orr	r3, r3, r4, lsl #16
+	mov	r4, r4, lsr #16
+	orr	r4, r4, r5, lsl #16
+	mov	r5, r5, lsr #16
+	orr	r5, r5, r12, lsl #16
+	mov	r12, r12, lsr #16
+	orr	r12, r12, lr, lsl #16
+#endif
+	stmia	r0!, {r3-r5, r12}
+	subs	r2, r2, #0x10
+	bge	.Lmemmove_fsrcul2loop16
+	ldmia	sp!, {r4, r5}
+	adds	r2, r2, #0x0c
+	blt	.Lmemmove_fsrcul2l4
+
+.Lmemmove_fsrcul2loop4:
+#ifdef __ARMEB__
+	mov	r12, lr, lsl #16
+#else
+	mov	r12, lr, lsr #16
+#endif
+	ldr	lr, [r1], #4
+#ifdef __ARMEB__
+	orr	r12, r12, lr, lsr #16
+#else
+	orr	r12, r12, lr, lsl #16
+#endif
+	str	r12, [r0], #4
+	subs	r2, r2, #4
+	bge	.Lmemmove_fsrcul2loop4
+
+.Lmemmove_fsrcul2l4:
+	sub	r1, r1, #2
+	b	.Lmemmove_fl4
+
+.Lmemmove_fsrcul3:
+	cmp	r2, #0x0c
+	blt	.Lmemmove_fsrcul3loop4
+	sub	r2, r2, #0x0c
+	stmdb	sp!, {r4, r5}
+
+.Lmemmove_fsrcul3loop16:
+#ifdef __ARMEB__
+	mov	r3, lr, lsl #24
+#else
+	mov	r3, lr, lsr #24
+#endif
+	ldmia	r1!, {r4, r5, r12, lr}
+#ifdef __ARMEB__
+	orr	r3, r3, r4, lsr #8
+	mov	r4, r4, lsl #24
+	orr	r4, r4, r5, lsr #8
+	mov	r5, r5, lsl #24
+	orr	r5, r5, r12, lsr #8
+	mov	r12, r12, lsl #24
+	orr	r12, r12, lr, lsr #8
+#else
+	orr	r3, r3, r4, lsl #8
+	mov	r4, r4, lsr #24
+	orr	r4, r4, r5, lsl #8
+	mov	r5, r5, lsr #24
+	orr	r5, r5, r12, lsl #8
+	mov	r12, r12, lsr #24
+	orr	r12, r12, lr, lsl #8
+#endif
+	stmia	r0!, {r3-r5, r12}
+	subs	r2, r2, #0x10
+	bge	.Lmemmove_fsrcul3loop16
+	ldmia	sp!, {r4, r5}
+	adds	r2, r2, #0x0c
+	blt	.Lmemmove_fsrcul3l4
+
+.Lmemmove_fsrcul3loop4:
+#ifdef __ARMEB__
+	mov	r12, lr, lsl #24
+#else
+	mov	r12, lr, lsr #24
+#endif
+	ldr	lr, [r1], #4
+#ifdef __ARMEB__
+	orr	r12, r12, lr, lsr #8
+#else
+	orr	r12, r12, lr, lsl #8
+#endif
+	str	r12, [r0], #4
+	subs	r2, r2, #4
+	bge	.Lmemmove_fsrcul3loop4
+
+.Lmemmove_fsrcul3l4:
+	sub	r1, r1, #1
+	b	.Lmemmove_fl4
+
+.Lmemmove_backwards:
+	add	r1, r1, r2
+	add	r0, r0, r2
+	subs	r2, r2, #4
+	blt	.Lmemmove_bl4		/* less than 4 bytes */
+	ands	r12, r0, #3
+	bne	.Lmemmove_bdestul	/* oh unaligned destination addr */
+	ands	r12, r1, #3
+	bne	.Lmemmove_bsrcul		/* oh unaligned source addr */
+
+.Lmemmove_bt8:
+	/* We have aligned source and destination */
+	subs	r2, r2, #8
+	blt	.Lmemmove_bl12		/* less than 12 bytes (4 from above) */
+	stmdb	sp!, {r4, lr}
+	subs	r2, r2, #0x14		/* less than 32 bytes (12 from above) */
+	blt	.Lmemmove_bl32
+
+	/* blat 32 bytes at a time */
+	/* XXX for really big copies perhaps we should use more registers */
+.Lmemmove_bloop32:
+	ldmdb	r1!, {r3, r4, r12, lr}
+	stmdb	r0!, {r3, r4, r12, lr}
+	ldmdb	r1!, {r3, r4, r12, lr}
+	stmdb	r0!, {r3, r4, r12, lr}
+	subs	r2, r2, #0x20
+	bge	.Lmemmove_bloop32
+
+.Lmemmove_bl32:
+	cmn	r2, #0x10
+	ldmgedb	r1!, {r3, r4, r12, lr}	/* blat a remaining 16 bytes */
+	stmgedb	r0!, {r3, r4, r12, lr}
+	subge	r2, r2, #0x10
+	adds	r2, r2, #0x14
+	ldmgedb	r1!, {r3, r12, lr}	/* blat a remaining 12 bytes */
+	stmgedb	r0!, {r3, r12, lr}
+	subge	r2, r2, #0x0c
+	ldmia	sp!, {r4, lr}
+
+.Lmemmove_bl12:
+	adds	r2, r2, #8
+	blt	.Lmemmove_bl4
+	subs	r2, r2, #4
+	ldrlt	r3, [r1, #-4]!
+	strlt	r3, [r0, #-4]!
+	ldmgedb	r1!, {r3, r12}
+	stmgedb	r0!, {r3, r12}
+	subge	r2, r2, #4
+
+.Lmemmove_bl4:
+	/* less than 4 bytes to go */
+	adds	r2, r2, #4
+	RETc(eq)
+
+	/* copy the crud byte at a time */
+	cmp	r2, #2
+	ldrb	r3, [r1, #-1]!
+	strb	r3, [r0, #-1]!
+	ldrgeb	r3, [r1, #-1]!
+	strgeb	r3, [r0, #-1]!
+	ldrgtb	r3, [r1, #-1]!
+	strgtb	r3, [r0, #-1]!
+	RET
+
+	/* erg - unaligned destination */
+.Lmemmove_bdestul:
+	cmp	r12, #2
+
+	/* align destination with byte copies */
+	ldrb	r3, [r1, #-1]!
+	strb	r3, [r0, #-1]!
+	ldrgeb	r3, [r1, #-1]!
+	strgeb	r3, [r0, #-1]!
+	ldrgtb	r3, [r1, #-1]!
+	strgtb	r3, [r0, #-1]!
+	subs	r2, r2, r12
+	blt	.Lmemmove_bl4		/* less than 4 bytes to go */
+	ands	r12, r1, #3
+	beq	.Lmemmove_bt8		/* we have an aligned source */
+
+	/* erg - unaligned source */
+	/* This is where it gets nasty ... */
+.Lmemmove_bsrcul:
+	bic	r1, r1, #3
+	ldr	r3, [r1, #0]
+	cmp	r12, #2
+	blt	.Lmemmove_bsrcul1
+	beq	.Lmemmove_bsrcul2
+	cmp	r2, #0x0c
+	blt	.Lmemmove_bsrcul3loop4
+	sub	r2, r2, #0x0c
+	stmdb	sp!, {r4, r5, lr}
+
+.Lmemmove_bsrcul3loop16:
+#ifdef __ARMEB__
+	mov	lr, r3, lsr #8
+#else
+	mov	lr, r3, lsl #8
+#endif
+	ldmdb	r1!, {r3-r5, r12}
+#ifdef __ARMEB__
+	orr	lr, lr, r12, lsl #24
+	mov	r12, r12, lsr #8
+	orr	r12, r12, r5, lsl #24
+	mov	r5, r5, lsr #8
+	orr	r5, r5, r4, lsl #24
+	mov	r4, r4, lsr #8
+	orr	r4, r4, r3, lsl #24
+#else
+	orr	lr, lr, r12, lsr #24
+	mov	r12, r12, lsl #8
+	orr	r12, r12, r5, lsr #24
+	mov	r5, r5, lsl #8
+	orr	r5, r5, r4, lsr #24
+	mov	r4, r4, lsl #8
+	orr	r4, r4, r3, lsr #24
+#endif
+	stmdb	r0!, {r4, r5, r12, lr}
+	subs	r2, r2, #0x10
+	bge	.Lmemmove_bsrcul3loop16
+	ldmia	sp!, {r4, r5, lr}
+	adds	r2, r2, #0x0c
+	blt	.Lmemmove_bsrcul3l4
+
+.Lmemmove_bsrcul3loop4:
+#ifdef __ARMEB__
+	mov	r12, r3, lsr #8
+#else
+	mov	r12, r3, lsl #8
+#endif
+	ldr	r3, [r1, #-4]!
+#ifdef __ARMEB__
+	orr	r12, r12, r3, lsl #24
+#else
+	orr	r12, r12, r3, lsr #24
+#endif
+	str	r12, [r0, #-4]!
+	subs	r2, r2, #4
+	bge	.Lmemmove_bsrcul3loop4
+
+.Lmemmove_bsrcul3l4:
+	add	r1, r1, #3
+	b	.Lmemmove_bl4
+
+.Lmemmove_bsrcul2:
+	cmp	r2, #0x0c
+	blt	.Lmemmove_bsrcul2loop4
+	sub	r2, r2, #0x0c
+	stmdb	sp!, {r4, r5, lr}
+
+.Lmemmove_bsrcul2loop16:
+#ifdef __ARMEB__
+	mov	lr, r3, lsr #16
+#else
+	mov	lr, r3, lsl #16
+#endif
+	ldmdb	r1!, {r3-r5, r12}
+#ifdef __ARMEB__
+	orr	lr, lr, r12, lsl #16
+	mov	r12, r12, lsr #16
+	orr	r12, r12, r5, lsl #16
+	mov	r5, r5, lsr #16
+	orr	r5, r5, r4, lsl #16
+	mov	r4, r4, lsr #16
+	orr	r4, r4, r3, lsl #16
+#else
+	orr	lr, lr, r12, lsr #16
+	mov	r12, r12, lsl #16
+	orr	r12, r12, r5, lsr #16
+	mov	r5, r5, lsl #16
+	orr	r5, r5, r4, lsr #16
+	mov	r4, r4, lsl #16
+	orr	r4, r4, r3, lsr #16
+#endif
+	stmdb	r0!, {r4, r5, r12, lr}
+	subs	r2, r2, #0x10
+	bge	.Lmemmove_bsrcul2loop16
+	ldmia	sp!, {r4, r5, lr}
+	adds	r2, r2, #0x0c
+	blt	.Lmemmove_bsrcul2l4
+
+.Lmemmove_bsrcul2loop4:
+#ifdef __ARMEB__
+	mov	r12, r3, lsr #16
+#else
+	mov	r12, r3, lsl #16
+#endif
+	ldr	r3, [r1, #-4]!
+#ifdef __ARMEB__
+	orr	r12, r12, r3, lsl #16
+#else
+	orr	r12, r12, r3, lsr #16
+#endif
+	str	r12, [r0, #-4]!
+	subs	r2, r2, #4
+	bge	.Lmemmove_bsrcul2loop4
+
+.Lmemmove_bsrcul2l4:
+	add	r1, r1, #2
+	b	.Lmemmove_bl4
+
+.Lmemmove_bsrcul1:
+	cmp	r2, #0x0c
+	blt	.Lmemmove_bsrcul1loop4
+	sub	r2, r2, #0x0c
+	stmdb	sp!, {r4, r5, lr}
+
+.Lmemmove_bsrcul1loop32:
+#ifdef __ARMEB__
+	mov	lr, r3, lsr #24
+#else
+	mov	lr, r3, lsl #24
+#endif
+	ldmdb	r1!, {r3-r5, r12}
+#ifdef __ARMEB__
+	orr	lr, lr, r12, lsl #8
+	mov	r12, r12, lsr #24
+	orr	r12, r12, r5, lsl #8
+	mov	r5, r5, lsr #24
+	orr	r5, r5, r4, lsl #8
+	mov	r4, r4, lsr #24
+	orr	r4, r4, r3, lsl #8
+#else
+	orr	lr, lr, r12, lsr #8
+	mov	r12, r12, lsl #24
+	orr	r12, r12, r5, lsr #8
+	mov	r5, r5, lsl #24
+	orr	r5, r5, r4, lsr #8
+	mov	r4, r4, lsl #24
+	orr	r4, r4, r3, lsr #8
+#endif
+	stmdb	r0!, {r4, r5, r12, lr}
+	subs	r2, r2, #0x10
+	bge	.Lmemmove_bsrcul1loop32
+	ldmia	sp!, {r4, r5, lr}
+	adds	r2, r2, #0x0c
+	blt	.Lmemmove_bsrcul1l4
+
+.Lmemmove_bsrcul1loop4:
+#ifdef __ARMEB__
+	mov	r12, r3, lsr #24
+#else
+	mov	r12, r3, lsl #24
+#endif
+	ldr	r3, [r1, #-4]!
+#ifdef __ARMEB__
+	orr	r12, r12, r3, lsl #8
+#else
+	orr	r12, r12, r3, lsr #8
+#endif
+	str	r12, [r0, #-4]!
+	subs	r2, r2, #4
+	bge	.Lmemmove_bsrcul1loop4
+
+.Lmemmove_bsrcul1l4:
+	add	r1, r1, #1
+	b	.Lmemmove_bl4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/string/memset.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,235 @@
+/*	$NetBSD: memset.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*
+ * Copyright 2003 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Steve C. Woodford for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Copyright (c) 1995 Mark Brinicombe.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Mark Brinicombe.
+ * 4. The name of the company nor the name of the author may be used to
+ *    endorse or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * memset: Sets a block of memory to the specified value
+ *
+ * On entry:
+ *   r0 - dest address
+ *   r1 - byte to write
+ *   r2 - number of bytes to write
+ *
+ * On exit:
+ *   r0 - dest address
+ */
+#ifdef _BZERO
+/* LINTSTUB: Func: void bzero(void *, size_t) */
+ENTRY(bzero)
+	mov	r3, #0x00
+#else
+/* LINTSTUB: Func: void *memset(void *, int, size_t) */
+ENTRY(memset)
+	and	r3, r1, #0xff		/* We deal with bytes */
+	mov	r1, r2
+#endif
+	cmp	r1, #0x04		/* Do we have less than 4 bytes */
+	mov	ip, r0
+	blt	.Lmemset_lessthanfour
+
+	/* Ok first we will word align the address */
+	ands	r2, ip, #0x03		/* Get the bottom two bits */
+	bne	.Lmemset_wordunaligned	/* The address is not word aligned */
+
+	/* We are now word aligned */
+.Lmemset_wordaligned:
+#ifndef _BZERO
+	orr	r3, r3, r3, lsl #8	/* Extend value to 16-bits */
+#endif
+#ifdef __XSCALE__
+	tst	ip, #0x04		/* Quad-align for Xscale */
+#else
+	cmp	r1, #0x10
+#endif
+#ifndef _BZERO
+	orr	r3, r3, r3, lsl #16	/* Extend value to 32-bits */
+#endif
+#ifdef __XSCALE__
+	subne	r1, r1, #0x04		/* Quad-align if necessary */
+	strne	r3, [ip], #0x04
+	cmp	r1, #0x10
+#endif
+	blt	.Lmemset_loop4		/* If less than 16 then use words */
+	mov	r2, r3			/* Duplicate data */
+	cmp	r1, #0x80		/* If < 128 then skip the big loop */
+	blt	.Lmemset_loop32
+
+	/* Do 128 bytes at a time */
+.Lmemset_loop128:
+	subs	r1, r1, #0x80
+#ifdef __XSCALE__
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+#else
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+#endif
+	bgt	.Lmemset_loop128
+	RETc(eq)			/* Zero length so just exit */
+
+	add	r1, r1, #0x80		/* Adjust for extra sub */
+
+	/* Do 32 bytes at a time */
+.Lmemset_loop32:
+	subs	r1, r1, #0x20
+#ifdef __XSCALE__
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+#else
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+#endif
+	bgt	.Lmemset_loop32
+	RETc(eq)			/* Zero length so just exit */
+
+	adds	r1, r1, #0x10		/* Partially adjust for extra sub */
+
+	/* Deal with 16 bytes or more */
+#ifdef __XSCALE__
+	strged	r2, [ip], #0x08
+	strged	r2, [ip], #0x08
+#else
+	stmgeia	ip!, {r2-r3}
+	stmgeia	ip!, {r2-r3}
+#endif
+	RETc(eq)			/* Zero length so just exit */
+
+	addlt	r1, r1, #0x10		/* Possibly adjust for extra sub */
+
+	/* We have at least 4 bytes so copy as words */
+.Lmemset_loop4:
+	subs	r1, r1, #0x04
+	strge	r3, [ip], #0x04
+	bgt	.Lmemset_loop4
+	RETc(eq)			/* Zero length so just exit */
+
+#ifdef __XSCALE__
+	/* Compensate for 64-bit alignment check */
+	adds	r1, r1, #0x04
+	RETc(eq)
+	cmp	r1, #2
+#else
+	cmp	r1, #-2
+#endif
+
+	strb	r3, [ip], #0x01		/* Set 1 byte */
+	strgeb	r3, [ip], #0x01		/* Set another byte */
+	strgtb	r3, [ip]		/* and a third */
+	RET				/* Exit */
+
+.Lmemset_wordunaligned:
+	rsb	r2, r2, #0x004
+	strb	r3, [ip], #0x01		/* Set 1 byte */
+	cmp	r2, #0x02
+	strgeb	r3, [ip], #0x01		/* Set another byte */
+	sub	r1, r1, r2
+	strgtb	r3, [ip], #0x01		/* and a third */
+	cmp	r1, #0x04		/* More than 4 bytes left? */
+	bge	.Lmemset_wordaligned	/* Yup */
+
+.Lmemset_lessthanfour:
+	cmp	r1, #0x00
+	RETc(eq)				/* Zero length so exit */
+	strb	r3, [ip], #0x01		/* Set 1 byte */
+	cmp	r1, #0x02
+	strgeb	r3, [ip], #0x01		/* Set another byte */
+	strgtb	r3, [ip]		/* and a third */
+	RET				/* Exit */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/string/strcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,43 @@
+/*      $NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+
+/*
+ * Copyright (c) 2002 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+
+ENTRY(strcmp)
+1:
+	ldrb	r2, [r0], #1
+	ldrb	r3, [r1], #1
+	cmp	r2, #1
+	cmpcs	r2, r3
+	beq	1b
+	sub	r0, r2, r3
+	RET
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/arm/string/strncmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,51 @@
+/*      $NetBSD: strncmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
+
+/*
+ * Copyright (c) 2002 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: strncmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+
+ENTRY(strncmp)
+/* if ((len - 1) < 0) return 0 */
+	subs	r2, r2, #1
+	movmi	r0, #0
+	RETc(mi)
+
+/* ip == last src address to compare */
+	add	ip, r0, r2
+1:
+	ldrb	r2, [r0], #1
+	ldrb	r3, [r1], #1
+	cmp	ip, r0
+	cmpcs	r2, #1
+	cmpcs	r2, r3
+	beq	1b
+	sub	r0, r2, r3
+	RET
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/gen/byte_swap_2.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,48 @@
+/*	$NetBSD: byte_swap_2.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	from: @(#)htons.s	5.2 (Berkeley) 12/17/90
+ */
+
+#include <machine/asm.h>
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: byte_swap_2.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+_ENTRY(_C_LABEL(__bswap16))
+_ENTRY(_C_LABEL(ntohs))
+_ENTRY(_C_LABEL(htons))
+_PROF_PROLOGUE
+	movzwl	4(%esp),%eax
+	rorw	$8,%ax
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/gen/byte_swap_4.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,50 @@
+/*	$NetBSD: byte_swap_4.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	from: @(#)htonl.s	5.3 (Berkeley) 12/17/90
+ */
+
+#include <machine/asm.h>
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: byte_swap_4.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+_ENTRY(_C_LABEL(__bswap32))
+_ENTRY(_C_LABEL(ntohl))
+_ENTRY(_C_LABEL(htonl))
+_PROF_PROLOGUE
+	movl	4(%esp),%eax
+	rorw	$8,%ax
+	roll	$16,%eax
+	rorw	$8,%ax
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/ffs.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,20 @@
+/*
+ * Written by J.T. Conklin <jtc@NetBSD.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+ENTRY(ffs)
+	bsfl	4(%esp),%eax
+	jz	L1	 		/* ZF is set if all bits are 0 */
+	incl	%eax			/* bits numbered from 1, not 0 */
+	ret
+
+	_ALIGN_TEXT
+L1:	xorl	%eax,%eax		/* clear result */
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/memchr.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,109 @@
+/*
+ * Written by J.T. Conklin <jtc@acorntoolworks.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: memchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+ENTRY(memchr)
+	pushl	%esi
+	movl	8(%esp),%eax
+	movzbl	12(%esp),%ecx
+	movl	16(%esp),%esi
+
+	/*
+	 * Align to word boundary. 
+	 * Consider unrolling loop?
+	 */
+	testl	%esi,%esi	/* nbytes == 0? */
+	je	.Lzero
+.Lalign:
+	testb	$3,%al
+	je	.Lword_aligned
+	cmpb	(%eax),%cl
+	je	.Ldone
+	incl	%eax
+	decl	%esi
+	jnz	.Lalign
+	jmp	.Lzero
+
+.Lword_aligned:
+	/* copy char to all bytes in word */
+	movb	%cl,%ch
+	movl	%ecx,%edx
+	sall	$16,%ecx
+	orl	%edx,%ecx
+
+	_ALIGN_TEXT
+.Lloop:
+	cmpl	$3,%esi		/* nbytes > 4 */
+	jbe	.Lbyte
+	movl	(%eax),%edx
+	addl	$4,%eax
+	xorl	%ecx,%edx
+	subl	$4,%esi
+	subl	$0x01010101,%edx
+	testl	$0x80808080,%edx
+	je	.Lloop
+
+	/*
+	 * In rare cases, the above loop may exit prematurely. We must
+	 * return to the loop if none of the bytes in the word are
+	 * equal to ch.
+	 */
+
+	/*
+	 * High load-use latency on the Athlon leads to significant
+	 * stalls, so we preload the next char as soon as possible
+	 * instead of using cmp mem8, reg8.
+	 *
+	 * Alignment here avoids a stall on the Athlon, even though
+	 * it's not a branch target.
+	 */
+	_ALIGN_TEXT
+	cmpb	-4(%eax),%cl	/* 1st byte == ch? */
+	movb	-3(%eax),%dl
+	jne	1f
+	subl	$4,%eax
+	jmp	.Ldone
+
+	_ALIGN_TEXT
+1:	cmpb	%dl,%cl		/* 2nd byte == ch? */
+	movb	-2(%eax),%dl
+	jne	1f
+	subl	$3,%eax
+	jmp	.Ldone
+
+	_ALIGN_TEXT
+1:	cmpb	%dl,%cl		/* 3rd byte == ch? */
+	movb	-1(%eax),%dl
+	jne	1f
+	subl	$2,%eax
+	jmp	.Ldone
+
+	_ALIGN_TEXT
+1:	cmpb	%dl,%cl		/* 4th byte == ch? */
+	jne	.Lloop
+	decl	%eax
+	jmp	.Ldone
+
+.Lbyte:
+	testl	%esi,%esi
+	je	.Lzero
+.Lbyte_loop:
+	cmpb	(%eax),%cl
+	je	.Ldone
+	incl	%eax
+	decl	%esi
+	jnz	.Lbyte_loop
+
+.Lzero:
+	xorl	%eax,%eax
+
+.Ldone:
+	popl	%esi
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/memcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,48 @@
+/*
+ * Written by J.T. Conklin <jtc@NetBSD.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+ENTRY(memcmp)
+	pushl	%edi
+	pushl	%esi
+	movl	12(%esp),%edi
+	movl	16(%esp),%esi
+	cld				/* set compare direction forward */
+
+	movl	20(%esp),%ecx		/* compare by words */
+	shrl	$2,%ecx
+	repe
+	cmpsl
+	jne	L5			/* do we match so far? */
+
+	movl	20(%esp),%ecx		/* compare remainder by bytes */
+	andl	$3,%ecx
+	repe
+	cmpsb
+	jne	L6			/* do we match? */
+
+	xorl	%eax,%eax		/* we match, return zero	*/
+	popl	%esi
+	popl	%edi
+	ret
+
+L5:	movl	$4,%ecx			/* We know that one of the next	*/
+	subl	%ecx,%edi		/* four pairs of bytes do not	*/
+	subl	%ecx,%esi		/* match.			*/
+	repe
+	cmpsb
+L6:	xorl	%eax,%eax		/* Perform unsigned comparison	*/
+	movb	-1(%edi),%al
+	xorl	%edx,%edx
+	movb	-1(%esi),%dl
+	subl    %edx,%eax
+	popl	%esi
+	popl	%edi
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/memcpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,133 @@
+/*	$NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from locore.s.
+ * Optimised by David Laight 2003
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+	/*
+	 * (ov)bcopy (src,dst,cnt)
+	 *  ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
+	 */
+
+#ifdef BCOPY
+ENTRY(bcopy)
+#else
+#ifdef MEMMOVE
+ENTRY(memmove)
+#else
+#define MEMCPY
+#define NO_OVERLAP
+ENTRY(memcpy)
+#endif
+#endif
+	push	%esi
+	mov	%edi,%edx
+#if defined(MEMCPY) || defined(MEMMOVE)
+	movl	8(%esp),%edi
+	movl	12(%esp),%esi
+#else
+	movl	8(%esp),%esi
+	movl	12(%esp),%edi
+#endif
+	movl	16(%esp),%ecx
+#if defined(NO_OVERLAP)
+	movl	%ecx,%eax
+#else
+	movl	%edi,%eax
+	subl	%esi,%eax
+	cmpl	%ecx,%eax	/* overlapping? */
+	movl	%ecx,%eax
+	jb	backwards
+#endif
+	cld			/* nope, copy forwards. */
+	shrl	$2,%ecx		/* copy by words */
+	rep
+	movsl
+	and	$3,%eax		/* any bytes left? */
+	jnz	trailing
+done:
+#if defined(MEMCPY) || defined(MEMMOVE)
+	movl	8(%esp),%eax
+#endif
+	mov	%edx,%edi
+	pop	%esi
+	ret
+
+trailing:
+	cmp	$2,%eax
+	jb	1f
+	movw	(%esi),%ax
+	movw	%ax,(%edi)
+	je	done
+	movb	2(%esi),%al
+	movb	%al,2(%edi)
+	jmp	done
+1:	movb	(%esi),%al
+	movb	%al,(%edi)
+	jmp	done
+
+#if !defined(NO_OVERLAP)
+backwards:
+	addl	%ecx,%edi	/* copy backwards. */
+	addl	%ecx,%esi
+	and	$3,%eax		/* any fractional bytes? */
+	jnz	back_align
+back_aligned:
+	shrl	$2,%ecx
+	subl	$4,%esi
+	subl	$4,%edi
+	std
+	rep
+	movsl
+	cld
+	jmp	done
+
+back_align:
+	sub	%eax,%esi
+	sub	%eax,%edi
+	cmp	$2,%eax
+	jb	1f
+	je	2f
+	movb	2(%esi),%al
+	movb	%al,2(%edi)
+2:	movw	(%esi),%ax
+	movw	%ax,(%edi)
+	jmp	back_aligned
+1:	movb	(%esi),%al
+	movb	%al,(%edi)
+	jmp	back_aligned
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/memmove.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: memmove.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+#define MEMMOVE
+#include "memcpy.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/memset.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,111 @@
+/*	$NetBSD: memset.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David Laight.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: memset.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+#ifdef BZERO
+ENTRY(bzero)
+#else
+ENTRY(memset)
+#endif
+#ifdef BZERO
+	movl	8(%esp),%ecx
+	xor	%eax,%eax
+#else
+	movl	12(%esp),%ecx
+	movzbl	8(%esp),%eax		/* unsigned char, zero extend */
+#endif
+	cmpl	$0x0f,%ecx		/* avoid mispredicted branch... */
+
+	pushl	%edi
+	movl	8(%esp),%edi
+
+	cld				/* set fill direction forward */
+
+	/*
+	 * if the string is too short, it's really not worth the overhead
+	 * of aligning to word boundries, etc.  So we jump to a plain
+	 * unaligned set.
+	 *
+	 * NB aligning the transfer is actually pointless on my athlon 700,
+	 * It does make a difference to a PII though.
+	 *
+	 * The PII, PIII and PIV all seem to have a massive performance
+	 * drop when the initial target address is an odd multiple of 4.
+	 */
+	jbe	by_bytes
+
+#ifndef BZERO
+	movb	%al,%ah			/* copy char to all bytes in word */
+	movl	%eax,%edx
+	sall	$16,%eax
+	orl	%edx,%eax
+#endif
+
+	movl	%edi,%edx		/* detect misalignment */
+	neg	%edx
+	andl	$7,%edx
+	jnz	align
+aligned:
+	movl	%eax,-4(%edi,%ecx)	/* zap last 4 bytes */
+	shrl	$2,%ecx			/* zero by words */
+	rep
+	stosl
+done:
+#ifndef BZERO
+	movl	8(%esp),%eax		/* return address of buffer */
+#endif
+	pop	%edi
+	ret
+
+align:
+	movl	%eax,(%edi)		/* zap first 8 bytes */
+	movl	%eax,4(%edi)
+	subl	%edx,%ecx		/* remove from main count */
+	add	%edx,%edi
+	jmp	aligned
+
+by_bytes:
+	rep
+	stosb
+
+#ifndef BZERO
+	movl	8(%esp),%eax		/* return address of buffer */
+#endif
+	popl	%edi
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/strcat.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,127 @@
+/*
+ * Written by J.T. Conklin <jtc@acorntoolworks.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: strcat.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+ENTRY(strcat)
+	pushl	%ebx
+	movl	8(%esp),%ecx
+	movl	12(%esp),%eax
+
+	/*
+	 * Align destination to word boundary.
+	 * Consider unrolling loop?
+	 */
+.Lscan:
+.Lscan_align:
+	testb	$3,%cl
+	je	.Lscan_aligned
+	cmpb	$0,(%ecx)
+	je	.Lcopy
+	incl	%ecx
+	jmp	.Lscan_align
+
+	_ALIGN_TEXT
+.Lscan_aligned:
+.Lscan_loop:
+	movl	(%ecx),%ebx
+	addl	$4,%ecx
+	leal	-0x01010101(%ebx),%edx
+	testl	$0x80808080,%edx
+	je	.Lscan_loop
+
+	/*
+	 * In rare cases, the above loop may exit prematurely. We must
+	 * return to the loop if none of the bytes in the word equal 0.
+	 */
+
+	/*
+	 * The optimal code for determining whether each byte is zero
+	 * differs by processor.  This space-optimized code should be
+	 * acceptable on all, especially since we don't expect it to
+	 * be run frequently,
+	 */
+
+	testb	%bl,%bl		/* 1st byte == 0? */
+	jne	1f
+	subl	$4,%ecx
+	jmp	.Lcopy
+
+1:	testb	%bh,%bh		/* 2nd byte == 0? */
+	jne	1f
+	subl	$3,%ecx
+	jmp	.Lcopy
+
+1:	shrl	$16,%ebx
+	testb	%bl,%bl		/* 3rd byte == 0? */
+	jne	1f
+	subl	$2,%ecx
+	jmp	.Lcopy
+
+1:	testb	%bh,%bh		/* 4th byte == 0? */
+	jne	.Lscan_loop
+	subl	$1,%ecx
+
+	/*
+	 * Align source to a word boundary.
+	 * Consider unrolling loop?
+	 */
+.Lcopy:
+.Lcopy_align:
+	testl	$3,%eax
+	je	.Lcopy_aligned
+	movb	(%eax),%bl
+	incl	%eax
+	movb	%bl,(%ecx)
+	incl	%ecx
+	testb	%bl,%bl
+	jne	.Lcopy_align
+	jmp	.Ldone
+
+	_ALIGN_TEXT
+.Lcopy_loop:
+	movl	%ebx,(%ecx)
+	addl	$4,%ecx
+.Lcopy_aligned:
+	movl	(%eax),%ebx
+	addl	$4,%eax
+	leal	-0x01010101(%ebx),%edx
+	testl	$0x80808080,%edx
+	je	.Lcopy_loop
+
+	/*
+	 * In rare cases, the above loop may exit prematurely. We must
+	 * return to the loop if none of the bytes in the word equal 0.
+	 */
+
+	movb	%bl,(%ecx)
+	incl	%ecx
+	testb	%bl,%bl
+	je	.Ldone
+
+	movb	%bh,(%ecx)
+	incl	%ecx
+	testb	%bh,%bh
+	je	.Ldone
+
+	shrl	$16,%ebx
+	movb	%bl,(%ecx)
+	incl	%ecx
+	testb	%bl,%bl
+	je	.Ldone
+
+	movb	%bh,(%ecx)
+	incl	%ecx
+	testb	%bh,%bh
+	jne	.Lcopy_aligned
+
+.Ldone:
+	movl	8(%esp),%eax
+	popl	%ebx
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/strchr.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,105 @@
+/*
+ * Written by J.T. Conklin <jtc@acorntoolworks.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: strchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+#ifdef INDEX
+ENTRY(index)
+#else
+ENTRY(strchr)
+#endif
+	pushl	%esi
+	pushl	%ebx
+	movl	12(%esp),%eax
+	movzbl	16(%esp),%ecx
+
+	/*
+	 * Align to word boundary.
+	 * Consider unrolling loop?
+	 */
+.Lalign:
+	testb	$3,%al
+	je	.Lword_aligned
+	movb	(%eax),%bl
+	cmpb	%cl,%bl
+	je	.Ldone
+	testb	%bl,%bl
+	je	.Lzero
+	incl	%eax
+	jmp	.Lalign
+
+.Lword_aligned:
+	/* copy char to all bytes in word */
+	movb	%cl,%ch
+	movl	%ecx,%edx
+	sall	$16,%ecx
+	orl	%edx,%ecx
+
+	/* Check whether any byte in the word is equal to ch or 0. */
+	_ALIGN_TEXT
+.Lloop:
+	movl	(%eax),%ebx
+	addl	$4,%eax
+	movl	%ebx,%esi
+	leal	-0x01010101(%ebx),%edx
+	xorl	%ecx,%esi
+	subl	$0x01010101,%esi
+	orl	%esi,%edx
+	testl	$0x80808080,%edx
+	je	.Lloop
+
+	/*
+	 * In rare cases, the above loop may exit prematurely. We must
+	 * return to the loop if none of the bytes in the word match
+	 * ch or are equal to 0.
+	 */
+
+	/*
+	 * Alignment here avoids a stall on the Athlon, even though
+	 * it's not a branch target.
+	 */
+
+	_ALIGN_TEXT
+	cmpb	%cl,%bl		/* 1st byte == ch? */
+	jne	1f
+	subl	$4,%eax
+	jmp	.Ldone
+1:	testb	%bl,%bl		/* 1st byte == 0? */
+	je	.Lzero
+
+	cmpb	%cl,%bh		/* 2nd byte == ch? */
+	jne	1f
+	subl	$3,%eax
+	jmp	.Ldone
+1:	testb	%bh,%bh		/* 2nd byte == 0? */
+	je	.Lzero
+
+	shrl	$16,%ebx
+	cmpb	%cl,%bl		/* 3rd byte == ch? */
+	jne	1f
+	subl	$2,%eax
+	jmp	.Ldone
+1:	testb	%bl,%bl		/* 3rd byte == 0? */
+	je	.Lzero
+
+	cmpb	%cl,%bh		/* 4th byte == ch? */
+	jne	1f
+	decl	%eax
+	jmp	.Ldone
+1:	testb	%bh,%bh		/* 4th byte == 0? */
+	jne	.Lloop
+
+.Lzero:
+	/* If a ch wasn't found, return 0. */
+	xorl	%eax,%eax
+
+.Ldone:
+	popl	%ebx
+	popl	%esi
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/strcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,77 @@
+/*
+ * Written by J.T. Conklin <jtc@acorntoolworks.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+ENTRY(strcmp)
+	pushl	%esi
+	pushl	%ebx
+	movl	12(%esp),%ebx
+	movl	16(%esp),%esi
+
+	/*
+	 * Align s1 to word boundary.
+	 * Consider unrolling loop?
+	 */
+.Ls1align:
+	testb	$3,%bl
+	je	.Ls1aligned
+	movb	(%ebx),%al
+	incl	%ebx
+	movb	(%esi),%dl
+	incl	%esi
+	testb	%al,%al
+	je	.Ldone
+	cmpb	%al,%dl
+	je	.Ls1align
+	jmp	.Ldone
+
+	/*
+	 * Check whether s2 is aligned to a word boundary.  If it is, we
+	 * can compare by words.  Otherwise we have to compare by bytes.
+	 */
+.Ls1aligned:
+	testl	$3,%esi
+	jne	.Lbyte_loop
+
+	subl	$4,%ebx
+	subl	$4,%esi
+
+	_ALIGN_TEXT
+.Lword_loop:
+	movl	4(%ebx),%eax
+	addl	$4,%ebx
+	movl	4(%esi),%edx
+	addl	$4,%esi
+	cmpl	%eax,%edx
+	jne	.Lbyte_loop
+	subl	$0x01010101,%edx
+	notl	%eax
+	andl	%eax,%edx
+	testl	$0x80808080,%edx
+	je	.Lword_loop
+
+	_ALIGN_TEXT
+.Lbyte_loop:
+	movb	(%ebx),%al
+	incl	%ebx
+	movb	(%esi),%dl
+	incl	%esi
+	testb	%al,%al
+	je	.Ldone
+	cmpb	%al,%dl
+	je	.Lbyte_loop
+
+.Ldone:
+	movzbl	%al,%eax
+	movzbl	%dl,%edx
+	subl	%edx,%eax
+	popl	%ebx
+	popl	%esi
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/strcpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,86 @@
+/*
+ * Written by J.T. Conklin <jtc@acorntoolworks.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+/*
+ * This strcpy implementation copies a byte at a time until the
+ * source pointer is aligned to a word boundary, it then copies by
+ * words until it finds a word containing a zero byte, and finally
+ * copies by bytes until the end of the string is reached.
+ *	
+ * While this may result in unaligned stores if the source and
+ * destination pointers are unaligned with respect to each other,
+ * it is still faster than either byte copies or the overhead of
+ * an implementation suitable for machines with strict alignment
+ * requirements.
+ */
+
+ENTRY(strcpy)
+	pushl	%ebx
+	movl	8(%esp),%ecx
+	movl	12(%esp),%eax
+
+	/*
+	 * Align source to a word boundary.
+	 * Consider unrolling loop?
+	 */
+	_ALIGN_TEXT
+.Lalign:
+	testl	$3,%eax
+	je	.Lword_aligned
+	movb	(%eax),%bl
+	incl	%eax
+	movb	%bl,(%ecx)
+	incl	%ecx
+	testb	%bl,%bl
+	jne	.Lalign
+	jmp	.Ldone
+
+	_ALIGN_TEXT
+.Lloop:
+	movl	%ebx,(%ecx)
+	addl	$4,%ecx
+.Lword_aligned:
+	movl	(%eax),%ebx
+	addl	$4,%eax
+	leal	-0x01010101(%ebx),%edx
+	testl	$0x80808080,%edx
+	je	.Lloop
+	
+	/*
+	 * In rare cases, the above loop may exit prematurely. We must
+	 * return to the loop if none of the bytes in the word equal 0.
+	 */
+
+	movb	%bl,(%ecx)
+	incl	%ecx
+	testb	%bl,%bl
+	je	.Ldone
+
+	movb	%bh,(%ecx)
+	incl	%ecx
+	testb	%bh,%bh
+	je	.Ldone
+
+	shrl	$16,%ebx
+	movb	%bl,(%ecx)
+	incl	%ecx
+	testb	%bl,%bl
+	je	.Ldone
+
+	movb	%bh,(%ecx)
+	incl	%ecx
+	testb	%bh,%bh
+	jne	.Lword_aligned
+
+.Ldone:
+	movl	8(%esp),%eax
+	popl	%ebx
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/strlen.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,141 @@
+/*
+ * Written by J.T. Conklin <jtc@acorntoolworks.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+ENTRY(strlen)
+	movl	4(%esp),%eax
+
+.Lalign:
+	/* Consider unrolling loop? */
+	testb	$3,%al
+	je	.Lword_aligned
+	cmpb	$0,(%eax)
+	je	.Ldone
+	incl	%eax
+	jmp	.Lalign
+
+	/*
+	 * There are many well known branch-free sequences which are used
+	 * for determining whether a zero-byte is contained within a word.
+	 * These sequences are generally much more efficent than loading
+	 * and comparing each byte individually.
+	 *
+	 * The expression [1,2]:
+	 *
+	 * (1)  ~(((x & 0x7f7f7f7f) + 0x7f7f7f7f) | (x | 0x7f7f7f7f))
+	 *
+	 * evaluates to a non-zero value if any of the bytes in the
+	 * original word is zero.
+	 *
+	 * It also has the useful property that bytes in the result word
+	 * that correspond to non-zero bytes in the original word have
+	 * the value 0x00, while bytes corresponding to zero bytes have
+	 * the value 0x80. This allows calculation of the first (and
+	 * last) occurrence of a zero byte within the word (useful for C's
+	 * str* primitives) by counting the number of leading (or
+	 * trailing) zeros and dividing the result by 8.  On machines
+	 * without (or with slow) clz() / ctz() instructions, testing
+	 * each byte in the result word for zero is necessary.
+	 *
+	 * This typically takes 4 instructions (5 on machines without
+	 * "not-or") not including those needed to load the constant.
+	 *
+	 *
+	 * The expression:
+	 *
+	 * (2)  ((x - 0x01010101) & ~x & 0x80808080)
+	 *
+	 * evaluates to a non-zero value if any of the bytes in the
+	 * original word is zero.
+	 *
+	 * On little endian machines, the first byte in the result word
+	 * that corresponds to a zero byte in the original byte is 0x80,
+	 * so clz() can be used as above.  On big endian machines, and
+	 * little endian machines without (or with a slow) clz() insn,
+	 * testing each byte in the original for zero is necessary.
+	 *
+	 * This typically takes 3 instructions (4 on machines without
+	 * "and with complement") not including those needed to load
+	 * constants.
+	 *
+	 *
+	 * The expression:
+	 *
+	 * (3)  ((x - 0x01010101) & 0x80808080)
+	 *
+	 * always evaluates to a non-zero value if any of the bytes in
+	 * the original word is zero.  However, in rare cases, it also
+	 * evaluates to a non-zero value when none of the bytes in the
+	 * original word is zero.
+	 *
+	 * To account for possible false positives, each byte of the
+	 * original word must be checked when the expression evaluates to
+	 * a non-zero value.  However, because it is simpler than those
+	 * presented above, code that uses it will be faster as long as
+	 * the rate of false positives is low.
+	 *
+	 * This is likely, because the the false positive can only occur
+	 * if the most siginificant bit of a byte within the word is set.
+	 * The expression will never fail for typical 7-bit ASCII strings.
+	 *
+	 * This typically takes 2 instructions not including those needed
+	 * to load constants.
+	 *
+	 *
+	 * [1] Henry S. Warren Jr., "Hacker's Delight", Addison-Westley 2003
+	 *
+	 * [2] International Business Machines, "The PowerPC Compiler Writer's
+	 *     Guide", Warthman Associates, 1996
+	 */
+
+	_ALIGN_TEXT
+.Lword_aligned:
+.Lloop:
+	movl	(%eax),%ecx
+	addl	$4,%eax
+	leal	-0x01010101(%ecx),%edx
+	testl	$0x80808080,%edx
+	je	.Lloop
+
+	/*
+	 * In rare cases, the above loop may exit prematurely. We must
+	 * return to the loop if none of the bytes in the word equal 0.
+	 */
+
+	/*
+	 * The optimal code for determining whether each byte is zero
+	 * differs by processor.  This space-optimized code should be
+	 * acceptable on all, especially since we don't expect it to
+	 * be run frequently,
+	 */
+
+	testb	%cl,%cl		/* 1st byte == 0? */
+	jne	1f
+	subl	$4,%eax
+	jmp	.Ldone
+
+1:	testb	%ch,%ch		/* 2nd byte == 0? */
+	jne	1f
+	subl	$3,%eax
+	jmp	.Ldone
+
+1:	shrl	$16,%ecx
+	testb	%cl,%cl		/* 3rd byte == 0? */
+	jne	1f
+	subl	$2,%eax
+	jmp	.Ldone
+
+1:	testb	%ch,%ch		/* 4th byte == 0? */
+	jne	.Lloop
+	decl	%eax
+
+.Ldone:
+	subl	4(%esp),%eax
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/i386/string/strrchr.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,98 @@
+/*
+ * Written by J.T. Conklin <jtc@acorntoolworks.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: strrchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+
+#ifdef RINDEX
+ENTRY(rindex)
+#else
+ENTRY(strrchr)
+#endif
+	pushl	%esi
+	pushl	%edi
+	pushl	%ebx
+	movl	16(%esp),%edx
+	movzbl	20(%esp),%ecx
+
+	/* zero return value */
+	xorl	%eax,%eax
+
+	/*
+	 * Align to word boundary.
+	 * Consider unrolling loop?
+	 */
+.Lalign:
+	testb	$3,%dl
+	je	.Lword_aligned
+	movb	(%edx),%bl
+	cmpb	%cl,%bl
+	jne	1f
+	movl	%edx,%eax
+1:	testb	%bl,%bl
+	je	.Ldone
+	incl	%edx
+	jmp	.Lalign
+
+.Lword_aligned:
+	/* copy char to all bytes in word */
+	movb	%cl,%ch
+	movl	%ecx,%edi
+	sall	$16,%ecx
+	orl	%edi,%ecx
+
+	/* Check whether any byte in the word is equal to ch or 0.  */
+	_ALIGN_TEXT
+.Lloop:
+	movl	(%edx),%ebx
+	addl	$4,%edx
+	movl	%ebx,%esi
+	leal	-0x01010101(%ebx),%edi
+	xorl	%ecx,%esi
+	subl	$0x01010101,%esi
+	orl	%esi,%edi
+	testl	$0x80808080,%edi
+	je	.Lloop
+
+	/*
+	 * In rare cases, the above loop may exit prematurely. We must
+	 * return to the loop if none of the bytes in the word match
+	 * ch or are equal to 0.
+	 */
+
+	_ALIGN_TEXT
+	cmpb	%cl,%bl		/* 1st byte == ch? */
+	jne	1f
+	leal	-4(%edx),%eax
+1:	testb	%bl,%bl		/* 1st byte == 0? */
+	je	.Ldone
+
+	cmpb	%cl,%bh		/* 2nd byte == ch? */
+	jne	1f
+	leal	-3(%edx),%eax
+1:	testb	%bh,%bh		/* 2nd byte == 0? */
+	je	.Ldone
+
+	shrl	$16,%ebx
+	cmpb	%cl,%bl		/* 3rd byte == ch? */
+	jne	1f
+	leal	-2(%edx),%eax
+1:	testb	%bl,%bl		/* 3rd byte == 0? */
+	je	.Ldone
+
+	cmpb	%cl,%bh		/* 4th byte == ch? */
+	jne	1f
+	leal	-1(%edx),%eax
+1:	testb	%bh,%bh		/* 4th byte == 0? */
+	jne	.Lloop
+
+.Ldone:
+	popl	%ebx
+	popl	%edi
+	popl	%esi
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/gen/bswap16.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,34 @@
+/*	$NetBSD: bswap16.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*
+ * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(bswap16)
+	movl	%sp@(4),%d0
+	rolw	#8,%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/gen/bswap32.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,36 @@
+/*	$NetBSD: bswap32.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*
+ * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(bswap32)
+	movl	%sp@(4),%d0
+	rolw	#8,%d0
+	swap	%d0
+	rolw	#8,%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/gen/bswap64.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,40 @@
+/*	$NetBSD: bswap64.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*
+ * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(bswap64)
+	movl	%sp@(4),%d1
+	movl	%sp@(8),%d0
+	rolw	#8,%d1
+	rolw	#8,%d0
+	swap	%d1
+	swap	%d0
+	rolw	#8,%d0
+	rolw	#8,%d1
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/gen/divsi3.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,50 @@
+/*	$NetBSD: divsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)divsi3.s	5.1 (Berkeley) 6/7/90")
+#else
+	RCSID("$NetBSD: divsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* int / int */
+ENTRY(__divsi3)
+	movel	%sp@(4),%d0
+	divsl	%sp@(8),%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/gen/modsi3.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,50 @@
+/*	$NetBSD: modsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)modsi3.s	5.1 (Berkeley) 6/7/90")
+#else
+	RCSID("$NetBSD: modsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* int % int */
+ENTRY(__modsi3)
+	movel	%sp@(4),%d1
+	divsll	%sp@(8),%d0:%d1
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/gen/mulsi3.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,50 @@
+/*	$NetBSD: mulsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)mulsi3.s	5.1 (Berkeley) 6/7/90")
+#else
+	RCSID("$NetBSD: mulsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* int * int */
+ENTRY(__mulsi3)
+	movel	%sp@(4),%d0
+	mulsl	%sp@(8),%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/gen/udivsi3.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,50 @@
+/*	$NetBSD: udivsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)udivsi3.s	5.1 (Berkeley) 6/7/90")
+#else
+	RCSID("$NetBSD: udivsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* unsigned / unsigned */
+ENTRY(__udivsi3)
+	movel	%sp@(4),%d0
+	divul	%sp@(8),%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/gen/umodsi3.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,50 @@
+/*	$NetBSD: umodsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)umodsi3.s	5.1 (Berkeley) 6/7/90")(
+#else
+	RCSID("$NetBSD: umodsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* unsigned % unsigned */
+ENTRY(__umodsi3)
+	movel	%sp@(4),%d1
+	divull	%sp@(8),%d0:%d1
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/net/htonl.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,50 @@
+/*	$NetBSD: htonl.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)htonl.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: htonl.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* netorder = htonl(hostorder) */
+
+ENTRY(htonl)
+	movl	%sp@(4),%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/net/htons.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,51 @@
+/*	$NetBSD: htons.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)htons.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: htons.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* hostorder = htons(netorder) */
+
+ENTRY(htons)
+	clrl	%d0
+	movw	%sp@(6),%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/net/ntohl.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,50 @@
+/*	$NetBSD: ntohl.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)ntohl.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: ntohl.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* hostorder = ntohl(netorder) */
+
+ENTRY(ntohl)
+	movl	%sp@(4),%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/net/ntohs.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,51 @@
+/*	$NetBSD: ntohs.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)ntohs.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: ntohs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* hostorder = ntohs(netorder) */
+
+ENTRY(ntohs)
+	clrl	%d0
+	movw	%sp@(6),%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/bcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,174 @@
+/*	$NetBSD: bcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by J.T. Conklin.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)bcmp.s 5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: bcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(bcmp)
+	movl	%sp@(4),%a0		| string 1
+	movl	%sp@(8),%a1		| string 2
+	movl	%sp@(12),%d1		| length
+
+	/*
+	 * It isn't worth the overhead of aligning to {long}word boundries
+	 * if the string is too short.
+	 */
+	cmpl	#8,%d1
+	jlt	Lbcbyte			
+
+#ifdef	__mc68010__
+	/*
+	 * The 68010 cannot access a word or long on an odd boundary,
+	 * period.  If the source and the destination addresses aren't
+	 * of the same evenness, we're forced to do a bytewise compare.
+	 */
+	movl	%a0,%d0
+	addl	%a1,%d0
+	btst	#0,%d0
+	jne	Lbcbyte
+#endif	/* __mc68010__ */
+	
+	/* word align */
+	movl	%a0,%d0
+	btst	#0,%d0
+	jeq	Lbcalgndw
+	cmpmb	%a0@+,%a1@+
+	jne	Lbcnoteq
+	subql	#1,%d1
+Lbcalgndw:
+	/* long word align */
+	btst	#1,%d0
+	jeq	Lbcalgndl
+	cmpmw	%a0@+,%a1@+
+	jne	Lbcnoteq
+	subql	#2,%d1
+Lbcalgndl:
+	/* compare by 8 longwords */
+	movl	%d1,%d0
+	lsrl	#5,%d0			| cnt = len / 32
+	jeq	Lbclong			| if (cnt)
+	andl	#31,%d1			|	len %= 32
+	subql	#1,%d0			|	set up for dbf
+Lbc32loop:
+	cmpml	%a0@+,%a1@+		|	compare 8 longwords
+	jne	Lbcnoteq		|	not equal, return non-zero
+	cmpml	%a0@+,%a1@+
+	jne	Lbcnoteq
+	cmpml	%a0@+,%a1@+
+	jne	Lbcnoteq
+	cmpml	%a0@+,%a1@+
+	jne	Lbcnoteq
+	cmpml	%a0@+,%a1@+
+	jne	Lbcnoteq
+	cmpml	%a0@+,%a1@+
+	jne	Lbcnoteq
+	cmpml	%a0@+,%a1@+
+	jne	Lbcnoteq
+	cmpml	%a0@+,%a1@+
+	jne	Lbcnoteq
+	dbf	%d0,Lbc32loop		|	till done
+	clrw	%d0
+	subql	#1,%d0
+	jcc	Lbc32loop
+
+Lbclong:
+	/* compare by longwords */
+	movl	%d1,%d0
+	lsrl	#2,%d0			| cnt = len / 4
+	jeq	Lbcbyte			| if (cnt)
+	subql	#1,%d0			|	set up for dbf
+Lbclloop:
+	cmpml	%a0@+,%a1@+		|	compare a longword
+	jne	Lbcnoteq		|	not equal, return non-zero
+	dbf	%d0,Lbclloop		|	till done
+	andl	#3,%d1			|	len %= 4
+	jeq	Lbcdone 
+
+	subql	#1,%d1			| set up for dbf
+Lbcbloop:
+	cmpmb	%a0@+,%a1@+		| compare a byte
+	jne	Lbcnoteq		| not equal, return non-zero
+Lbcbyte:
+	dbf	%d1,Lbcbloop
+Lbcdone:
+	movql	#0,%d0
+	rts
+
+Lbcnoteq:
+	movql	#1,%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/bcopy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,263 @@
+/*	$NetBSD: bcopy.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by J.T. Conklin.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)bcopy.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: bcopy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+
+#ifdef MEMCOPY
+ENTRY(memcpy)
+#else
+#ifdef MEMMOVE
+ENTRY(memmove)
+#else
+ENTRY(bcopy)
+#endif
+#endif
+#if defined(MEMCOPY) || defined(MEMMOVE)
+	movl	%sp@(4),%a1		| dest address
+	movl	%sp@(8),%a0		| src address
+#else
+	movl	%sp@(4),%a0		| src address
+	movl	%sp@(8),%a1		| dest address
+#endif
+	movl	%sp@(12),%d1		| count
+
+	cmpl	%a1,%a0			| src after dest?
+	jlt	Lbcback			| yes, must copy backwards
+
+	/* 
+	 * It isn't worth the overhead of aligning to {long}word boundries
+	 * if the string is too short.
+	 */
+	cmpl	#8,%d1
+	jlt	Lbcfbyte
+
+#ifdef	__mc68010__
+	/*
+	 * The 68010 cannot access a word or long on an odd boundary,
+	 * period.  If the source and the destination addresses aren't
+	 * of the same evenness, we're forced to do a bytewise copy.
+	 */
+	movl	%a0,%d0
+	addl	%a1,%d0
+	btst	#0,%d0
+	jne	Lbcfbyte
+#endif	/* __mc68010__ */
+	
+	/* word align */
+	movl	%a1,%d0
+	btst	#0,%d0		| if (dst & 1)
+	jeq	Lbcfalgndw	| 
+	movb	%a0@+,%a1@+	|	*(char *)dst++ = *(char *) src++
+	subql	#1,%d1		|	len--
+Lbcfalgndw:
+	/* long word align */
+	btst	#1,%d0		| if (dst & 2)
+	jeq	Lbcfalgndl
+	movw	%a0@+,%a1@+	|	*(short *)dst++ = *(short *) dst++
+	subql	#2,%d1		|	len -= 2
+Lbcfalgndl:
+	/* copy by 8 longwords */
+	movel	%d1,%d0
+	lsrl	#5,%d0		| cnt = len / 32
+	jeq	Lbcflong	| if (cnt)
+	andl	#31,%d1		|	len %= 32
+	subql	#1,%d0		|	set up for dbf
+Lbcf32loop:
+	movl	%a0@+,%a1@+	|	copy 8 long words
+	movl	%a0@+,%a1@+
+	movl	%a0@+,%a1@+
+	movl	%a0@+,%a1@+
+	movl	%a0@+,%a1@+
+	movl	%a0@+,%a1@+
+	movl	%a0@+,%a1@+
+	movl	%a0@+,%a1@+
+	dbf	%d0,Lbcf32loop	|	till done
+	clrw	%d0
+	subql	#1,%d0
+	jcc	Lbcf32loop
+
+Lbcflong:
+	/* copy by longwords */
+	movel	%d1,%d0
+	lsrl	#2,%d0		| cnt = len / 4
+	jeq	Lbcfbyte	| if (cnt)
+	subql	#1,%d0		|	set up for dbf
+Lbcflloop:
+	movl	%a0@+,%a1@+	|	copy longwords
+	dbf	%d0,Lbcflloop	|	til done
+	andl	#3,%d1		|	len %= 4
+	jeq	Lbcdone
+
+	subql	#1,%d1		| set up for dbf
+Lbcfbloop:
+	movb	%a0@+,%a1@+	| copy bytes
+Lbcfbyte:
+	dbf	%d1,Lbcfbloop	| till done
+Lbcdone:
+#if defined(MEMCOPY) || defined(MEMMOVE)
+	movl	%sp@(4),%d0	| dest address
+#if defined(__SVR4_ABI__)
+	moveal	%d0,%a0
+#endif
+#endif
+	rts
+
+
+Lbcback:
+	addl	%d1,%a0		| src pointer to end
+	addl	%d1,%a1		| dest pointer to end
+
+	/* 
+	 * It isn't worth the overhead of aligning to {long}word boundries
+	 * if the string is too short.
+	 */
+	cmpl	#8,%d1
+	jlt	Lbcbbyte
+
+#ifdef	__mc68010__
+	/*
+	 * The 68010 cannot access a word or long on an odd boundary,
+	 * period.  If the source and the destination addresses aren't
+	 * of the same evenness, we're forced to do a bytewise copy.
+	 */
+	movl	%a0,%d0
+	addl	%a1,%d0
+	btst	#0,%d0
+	jne	Lbcbbyte
+#endif	/* __mc68010__ */
+	
+	/* word align */
+	movl	%a1,%d0
+	btst	#0,%d0		| if (dst & 1)
+	jeq	Lbcbalgndw	| 
+	movb	%a0@-,%a1@-	|	*(char *)dst-- = *(char *) src--
+	subql	#1,%d1		|	len--
+Lbcbalgndw:
+	/* long word align */
+	btst	#1,%d0		| if (dst & 2)
+	jeq	Lbcbalgndl
+	movw	%a0@-,%a1@-	|	*(short *)dst-- = *(short *) dst--
+	subql	#2,%d1		|	len -= 2
+Lbcbalgndl:
+	/* copy by 8 longwords */
+	movel	%d1,%d0
+	lsrl	#5,%d0		| cnt = len / 32
+	jeq	Lbcblong	| if (cnt)
+	andl	#31,%d1		|	len %= 32
+	subql	#1,%d0		|	set up for dbf
+Lbcb32loop:
+	movl	%a0@-,%a1@-	|	copy 8 long words
+	movl	%a0@-,%a1@-
+	movl	%a0@-,%a1@-
+	movl	%a0@-,%a1@-
+	movl	%a0@-,%a1@-
+	movl	%a0@-,%a1@-
+	movl	%a0@-,%a1@-
+	movl	%a0@-,%a1@-
+	dbf	%d0,Lbcb32loop	|	till done
+	clrw	%d0
+	subql	#1,%d0
+	jcc	Lbcb32loop
+	
+Lbcblong:
+	/* copy by longwords */
+	movel	%d1,%d0
+	lsrl	#2,%d0		| cnt = len / 4
+	jeq	Lbcbbyte	| if (cnt)
+	subql	#1,%d0		|	set up for dbf
+Lbcblloop:
+	movl	%a0@-,%a1@-	|	copy longwords
+	dbf	%d0,Lbcblloop	|	til done
+	andl	#3,%d1		|	len %= 4
+	jeq	Lbcdone
+
+	subql	#1,%d1		| set up for dbf
+Lbcbbloop:
+	movb	%a0@-,%a1@-	| copy bytes
+Lbcbbyte:
+	dbf	%d1,Lbcbbloop	| till done
+
+#if defined(MEMCOPY) || defined(MEMMOVE)
+	movl	%sp@(4),%d0	| dest address
+#if defined(__SVR4_ABI__)
+	moveal	%d0,%a0
+#endif
+#endif
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/bzero.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,148 @@
+/*	$NetBSD: bzero.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by J.T. Conklin.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)bzero.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: bzero.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(bzero)
+	movl	%d2,%sp@-
+	movl	%sp@(8),%a0		| destination
+	movl	%sp@(12),%d1		| count
+
+	movql	#0,%d2
+
+	/* 
+	 * It isn't worth the overhead of aligning to {long}word boundries
+	 * if the string is too short.
+	 */
+	cmpl	#8,%d1
+	jlt	Lbzbyte
+
+	/* word align */
+	movl	%a0,%d0
+	btst	#0,%d0			| if (dst & 1)
+	jeq	Lbzalgndw		| 
+	movb	%d2,%a0@+		| 	*(char *)dst++ = 0
+	subql	#1,%d1			|	len--
+Lbzalgndw:
+	/* long word align */
+	btst	#1,%d0			| if (dst & 2)
+	jeq	Lbzalgndl		|
+	movw	%d2,%a0@+		|	*(short *)dst++ = 0
+	subql	#2,%d1			|	len -= 2
+Lbzalgndl:
+	/* zero by 8 longwords */
+	movel	%d1,%d0
+	lsrl	#5,%d0			| cnt = len / 32
+	jeq	Lbzlong			| if (cnt)
+	andl	#31,%d1			|	len %= 32
+	subql	#1,%d0			|	set up for dbf
+Lbz32loop:
+	movl	%d2,%a0@+		|	zero 8 long words
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	dbf	%d0,Lbz32loop		|	till done
+	clrw	%d0
+	subql	#1,%d0
+	jcc	Lbz32loop
+
+Lbzlong:
+	/* copy by longwords */
+	movel	%d1,%d0
+	lsrl	#2,%d0			| cnt = len / 4
+	jeq	Lbzbyte			| if (cnt)
+	subql	#1,%d0			|	set up for dbf
+Lbzlloop:
+	movl	%d2,%a0@+		|	clear longwords
+	dbf	%d0,Lbzlloop		|	till done
+	andl	#3,%d1			|	len %= 4
+	jeq	Lbzdone
+
+	subql	#1,%d1			| set up for dbf
+Lbzbloop:
+	movb	%d2,%a0@+		| zero bytes
+Lbzbyte:
+	dbf	%d1,Lbzbloop		| till done
+Lbzdone:
+	movl	%sp@+,%d2
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/ffs.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,74 @@
+/*	$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)ffs.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* bit = ffs(value) */
+
+#ifndef	__mc68010__
+
+ENTRY(ffs)
+	movl	%sp@(4),%d0
+	movl	%d0,%d1
+	negl	%d0
+	andl	%d0,%d1
+	movql	#32,%d0
+	bfffo	%d1{#0:#32},%d1
+	subl	%d1,%d0
+	rts
+
+#else	/* __mc68010__ */
+
+ENTRY(ffs)
+	movl	%sp@(4),%d0
+	jeq	L2
+	movql	#31,%d1
+L1:	
+	lsrl	#1,%d0
+	dbcs	%d1,L1
+	movql	#32,%d0
+	subl	%d1,%d0
+L2:
+	rts
+
+#endif	/* __mc68010__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/index.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,65 @@
+/*	$NetBSD: index.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)index.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: index.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef STRCHR
+ENTRY(strchr)
+#else
+ENTRY(index)
+#endif
+	movl	%sp@(4),%a0		| string
+	movb	%sp@(11),%d0		| char to look for
+ixloop:
+	cmpb	%a0@,%d0		| found our char?
+	jeq	ixfound			| yes, break out
+	tstb	%a0@+			| null?
+	jne	ixloop			| no, keep going
+	moveq	#0,%d0			| not found, return null
+#ifdef __SVR4_ABI__
+	moveal	%d0,%a0
+#endif
+	rts
+ixfound:
+	movl	%a0,%d0			| found, return pointer
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/memcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,100 @@
+/*	$NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)bcmp.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* memcmp(s1, s2, n) */
+
+/*
+ * 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.
+ *
+ * Things that might help:
+ *	- longword align when possible (only on the 68020)
+ *	- use nested DBcc instructions or use one and limit size to 64K
+ */
+ENTRY(memcmp)
+	movl	%sp@(4),%a0		| string 1
+	movl	%sp@(8),%a1		| string 2
+	movl	%sp@(12),%d0		| length
+	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
+	jne	bcnoteq			| not equal, return non-zero
+	subql	#1,%d0			| adjust count
+	jeq	bcdone			| count 0, reutrn zero
+bceven:
+	movl	%a1,%d1
+	btst	#0,%d1			| string 2 address odd?
+	jne	bcbloop			| yes, no hope for alignment, compare bytes
+	movl	%d0,%d1			| no, both even
+	lsrl	#2,%d1			| convert count to longword count
+	jeq	bcbloop			| count 0, skip longword loop
+bclloop:
+	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
+	jne	bcnoteq			| not equal, return non-zero
+	subql	#1,%d0			| adjust count
+	jne	bcbloop			| still more, keep going
+	rts
+bcnoteql:
+	subql	#4,%a0
+	subql	#4,%a1
+	movl	#4,%d0
+	jra	bcbloop
+bcnoteq:
+	clrl	%d0
+	clrl	%d1
+	movb	%a0@-,%d0
+	movb	%a1@-,%d1
+	subl	%d1,%d0
+bcdone:
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/memcpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+#define MEMCOPY
+#include "bcopy.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/memmove.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: memmove.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+#define MEMMOVE
+#include "bcopy.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/memset.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,169 @@
+/*	$NetBSD: memset.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by J.T. Conklin.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)bzero.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: memset.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(memset)
+	movl	%d2,%sp@-
+	movl	%sp@(8),%a0		| destination
+	movl	%sp@(16),%d1		| count
+	movb	%sp@(15),%d2		| character
+
+	/* 
+	 * It isn't worth the overhead of aligning to {long}word boundries
+	 * if the string is too short.
+	 */
+	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
+
+	/* word align */
+	movl	%a0,%d0
+	btst	#0,%d0			| if (dst & 1)
+	jeq	Lbzalgndw		| 
+	movb	%d2,%a0@+		|	*(char *)dst++ = X
+	subql	#1,%d1			|	len--
+	addql	#1,%d0
+Lbzalgndw:
+#ifndef	__mc68010__
+	/* long word align */
+	btst	#1,%d0			| if (dst & 2)
+	jeq	Lbzalgndl		|
+	movw	%d2,%a0@+		|	*(short *)dst++ = X
+	subql	#2,%d1			|	len -= 2
+Lbzalgndl:
+	/* set by 8 longwords */
+	movel	%d1,%d0
+	lsrl	#5,%d0			| cnt = len / 32
+	jeq	Lbzlong			| if (cnt)
+	andl	#31,%d1			|	len %= 32
+	subql	#1,%d0			|	set up for dbf
+Lbz32loop:
+	movl	%d2,%a0@+		|	set 8 long words
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	movl	%d2,%a0@+
+	dbf	%d0,Lbz32loop		|	till done
+	clrw	%d0
+	subql	#1,%d0
+	jcc	Lbz32loop
+#endif	/* !__mc68010__ */
+
+Lbzlong:
+	/* set by longwords */
+	movel	%d1,%d0
+	lsrl	#2,%d0			| cnt = len / 4
+	jeq	Lbzbyte			| if (cnt)
+	subql	#1,%d0			|	set up for dbf
+Lbzlloop:
+	movl	%d2,%a0@+		|	clear longwords
+	dbf	%d0,Lbzlloop		|	till done
+#ifdef	__mc68010__
+	clrw	%d0
+	subql	#1,%d0
+	jcc	Lbzlloop
+#endif	/* __mc68010__ */
+	andl	#3,%d1			|	len %= 4
+	jeq	Lbzdone
+
+	subql	#1,%d1			| set up for dbf
+Lbzbloop:
+	movb	%d2,%a0@+		| set bytes
+Lbzbyte:
+	dbf	%d1,Lbzbloop		| till done
+Lbzdone:
+	movl	%sp@(8),%d0		| return destination
+#ifdef __SVR4_ABI__
+	moveal	%d0,%a0
+#endif
+	movl	%sp@+,%d2
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/rindex.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,62 @@
+/*	$NetBSD: rindex.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)rindex.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: rindex.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef STRRCHR
+ENTRY(strrchr)
+#else
+ENTRY(rindex)
+#endif
+	movl	%sp@(4),%a1		| string
+	movb	%sp@(11),%d0		| char to look for
+	subl	%a0,%a0			| clear rindex pointer
+rixloop:
+	cmpb	%a1@,%d0		| found our char?
+	jne	rixnope			| no, check for null
+	movl	%a1,%a0			| yes, remember location
+rixnope:
+	tstb	%a1@+			| null?
+	jne	rixloop			| no, keep going
+	movl	%a0,%d0			| return value
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/strcat.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,60 @@
+/*	$NetBSD: strcat.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)strcpy.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: strcat.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(strcat)
+	movl	%sp@(8),%a0		| a0 = fromaddr
+	movl	%sp@(4),%d0		| return value is toaddr
+	movl	%d0,%a1			| a1 = toaddr
+Lslloop:
+	tstb	%a1@+			| null?
+	jne	Lslloop			| no, keep going
+	subql	#1,%a1
+Lscloop:
+	movb	%a0@+,%a1@+		| copy a byte
+	jne	Lscloop			| copied non-null, keep going
+#ifdef __SVR4_ABI__
+	moveal	%d0,%a0
+#endif
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/strchr.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: strchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+#define STRCHR
+#include "index.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/strcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,78 @@
+/*	$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Hiroshi Horimoto <horimoto@cs-aoi.cs.sist.ac.jp> and
+ * by J.T. Conklin <jtc@NetBSD.org>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+	RCSID("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(strcmp)
+	movl	%sp@(4),%a0
+	movl	%sp@(8),%a1
+L1:				/* unrolled by 4 for 680[23]0's */
+	movb	%a0@+,%d1
+	jeq	L2
+	subb	%a1@+,%d1
+	jne	L3
+
+	movb	%a0@+,%d1
+	jeq	L2
+	subb	%a1@+,%d1
+	jne	L3
+
+	movb	%a0@+,%d1
+	jeq	L2
+	subb	%a1@+,%d1
+	jne	L3
+
+	movb	%a0@+,%d1
+	jeq	L2
+	subb	%a1@+,%d1
+	jeq	L1
+
+L3:	scs	%d0
+	EXTBL(%d0)
+	movb	%d1,%d0
+	rts
+
+L2:	movq	#0,%d0
+	movb	%a1@,%d0
+	negl	%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/strcpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,56 @@
+/*	$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)strcpy.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(strcpy)
+	movl	%sp@(8),%a0		| a0 = fromaddr
+	movl	%sp@(4),%d0		| return value is toaddr
+	movl	%d0,%a1			| a1 = toaddr
+Lscloop:
+	movb	%a0@+,%a1@+		| copy a byte
+	jne	Lscloop			| copied non-null, keep going
+#ifdef __SVR4_ABI__
+	moveal	%d0,%a0
+#endif
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/strlen.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,54 @@
+/*	$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)strlen.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(strlen)
+	movl	%sp@(4),%a0		| string
+	movl	%a0,%d0
+	notl	%d0
+Lslloop:
+	tstb	%a0@+			| null?
+	jne	Lslloop			| no, keep going
+	addl	%a0,%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/strncmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,85 @@
+/*	$NetBSD: strncmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Hiroshi Horimoto <horimoto@cs-aoi.cs.sist.ac.jp> and
+ * by J.T. Conklin <jtc@NetBSD.org>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+	RCSID("$NetBSD: strncmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(strncmp)
+	movl	%sp@(12),%d0
+	jeq	L4
+	movl	%sp@(4),%a0
+	movl	%sp@(8),%a1
+L1:				/* unroll by 4 for m680[23]0's */
+	movb	%a0@+,%d1
+	jeq	L2
+	subb	%a1@+,%d1
+	jne	L3
+	subql	#1,%d0
+	jeq	L4
+
+	movb	%a0@+,%d1
+	jeq	L2
+	subb	%a1@+,%d1
+	jne	L3
+	subql	#1,%d0
+	jeq	L4
+
+	movb	%a0@+,%d1
+	jeq	L2
+	subb	%a1@+,%d1
+	jne	L3
+	subql	#1,%d0
+	jeq	L4
+
+	movb	%a0@+,%d1
+	jeq	L2
+	subb	%a1@+,%d1
+	jne	L3
+	subql	#1,%d0
+	jne	L1
+L4:	rts
+
+L2:	subb	%a1@,%d1
+L3:	scs	%d0
+	EXTBL(%d0)
+	movb	%d1,%d0
+	rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/strncpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,73 @@
+/*	$NetBSD: strncpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)strncpy.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: strncpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(strncpy)
+	movl	%sp@(4),%d0		| return value is toaddr
+	movl	%sp@(12),%d1		| count
+	jeq	Lscdone			| nothing to do
+	movl	%sp@(8),%a0		| a0 = fromaddr
+	movl	%d0,%a1			| a1 = toaddr
+	subql	#1,%d1
+Lscloop:
+	movb	%a0@+,%a1@+		| copy a byte
+	dbeq	%d1,Lscloop		| loop through low word of d1
+	jeq	Lscpadding		| copied null, padding if necessary
+	clrw	%d1			| clear low word of d1
+	subql	#1,%d1			| adjust count for long copies
+	jcc	Lscloop			| more room, keep going
+Lscdone:
+#ifdef __SVR4_ABI__
+	moveal	%d0,%a0
+#endif
+	rts
+
+Lscploop:
+	clrb	%a1@+			| clear a byte
+	dbra	%d1,Lscploop		| keep going
+	clrw	%d1
+Lscpadding:
+	subql	#1,%d1
+	jcc	Lscploop
+	jra	Lscdone
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/m68k/string/strrchr.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: strrchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+#define STRRCHR
+#include "rindex.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/mips/gen/byte_swap_2.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,74 @@
+/*	$NetBSD: byte_swap_2.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <mips/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+	ASMSTR("from: @(#)htons.s	8.1 (Berkeley) 6/4/93")
+	ASMSTR("$NetBSD: byte_swap_2.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif /* LIBC_SCCS and not lint */
+
+#undef _LOCORE
+#define _LOCORE		/* XXX not really, just assembly-code source */
+#include <machine/endian.h>
+
+#ifdef _KERNEL
+#define	BSWAP16_NAME	bswap16
+#else
+#ifdef __ABICALLS__
+	.abicalls
+#endif
+#define	BSWAP16_NAME	__bswap16
+#endif
+
+NLEAF(BSWAP16_NAME)
+#if BYTE_ORDER == LITTLE_ENDIAN
+ALEAF(htons)
+ALEAF(ntohs)
+#endif
+	srl	v0, a0, 8
+	and	v0, v0, 0xff
+	sll	v1, a0, 8
+	and	v1, v1, 0xff00
+	or	v0, v0, v1
+	j	ra
+END(BSWAP16_NAME)
+
+#if BYTE_ORDER == BIG_ENDIAN
+NLEAF(htons)
+ALEAF(ntohs)
+	move	v0, a0
+	j	ra
+END(htons)
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/mips/gen/byte_swap_4.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,78 @@
+/*	$NetBSD: byte_swap_4.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <mips/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+	ASMSTR("from: @(#)htonl.s	8.1 (Berkeley) 6/4/93")
+	ASMSTR("$NetBSD: byte_swap_4.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif /* LIBC_SCCS and not lint */
+
+#undef _LOCORE
+#define _LOCORE		/* XXX not really, just assembly-code source */
+#include <machine/endian.h>
+
+#ifdef _KERNEL
+#define	BSWAP32_NAME	bswap32
+#else
+#ifdef __ABICALLS__
+	.abicalls
+#endif
+#define	BSWAP32_NAME	__bswap32
+#endif
+
+NLEAF(BSWAP32_NAME)			# a0 = 0x11223344, return 0x44332211
+#if BYTE_ORDER == LITTLE_ENDIAN
+ALEAF(htonl)				# a0 = 0x11223344, return 0x44332211
+ALEAF(ntohl)
+#endif
+	srl	v1, a0, 24		# v1 = 0x00000011
+	sll	v0, a0, 24		# v0 = 0x44000000
+	or	v0, v0, v1
+	and	v1, a0, 0xff00
+	sll	v1, v1, 8		# v1 = 0x00330000
+	or	v0, v0, v1
+	srl	v1, a0, 8
+	and	v1, v1, 0xff00		# v1 = 0x00002200
+	or	v0, v0, v1
+	j	ra
+END(BSWAP32_NAME)
+
+#if BYTE_ORDER == BIG_ENDIAN
+NLEAF(htonl)				# a0 = 0x11223344, return 0x44332211
+ALEAF(ntohl)
+	move	v0, a0
+	j	ra
+END(htonl)
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/mips/string/ffs.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,58 @@
+/*	$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <mips/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+	ASMSTR("from: @(#)ffs.s	8.1 (Berkeley) 6/4/93")
+	ASMSTR("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef __ABICALLS__
+	.abicalls
+#endif
+
+/* bit = ffs(value) */
+
+LEAF(ffs)
+	move	v0, zero
+	beq	a0, zero, done
+1:
+	and	v1, a0, 1		# bit set?
+	addu	v0, v0, 1
+	srl	a0, a0, 1
+	beq	v1, zero, 1b		# no, continue
+done:
+	j	ra
+END(ffs)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/mips/string/memcpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,5 @@
+/*	$NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+
+#define MEMCOPY
+#include "bcopy.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/mips/string/memmove.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,5 @@
+/*	$NetBSD: memmove.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+
+#define MEMMOVE
+#include "bcopy.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/mips/string/memset.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,51 @@
+/*	$NetBSD: memset.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+#include <machine/cdefs.h>
+#include <mips/asm.h>
+
+#ifndef _LOCORE		/* avoid tripping over __RENAME() */
+#define _LOCORE		/* XXX not really, just assembly-code source */
+#endif
+
+#include <machine/endian.h>
+
+	.set	noreorder
+
+/*
+ * memset(void *s1, int c, int len)
+ */
+LEAF(memset)
+	blt	a2, 12, smallclr	# small amount to clear?
+	move	v0, a0			# save s1 for result
+
+	sll	t1, a1, 8		# compute  c << 8 in t1
+	or	t1, t1, a1		# compute c << 8 | c in 11
+	sll	t2, t1, 16		# shift that left 16
+	or	t1, t2, t1		# or together
+
+	subu	t0, zero, a0		# compute # bytes to word align address
+	and	t0, t0, 3
+	beq	t0, zero, 1f		# skip if word aligned
+	subu	a2, a2, t0		# subtract from remaining count
+	SWHI	t1, 0(a0)		# store 1, 2, or 3 bytes to align
+	addu	a0, a0, t0
+1:
+	and	v1, a2, 3		# compute number of whole words left
+	subu	t0, a2, v1
+	subu	a2, a2, t0 
+	addu	t0, t0, a0		# compute ending address
+2:
+	addu	a0, a0, 4		# clear words
+	bne	a0, t0, 2b		#  unrolling loop does not help
+	sw	t1, -4(a0)		#  since we are limited by memory speed
+
+smallclr:
+	ble	a2, zero, 2f
+	addu	t0, a2, a0		# compute ending address
+1:
+	addu	a0, a0, 1		# clear bytes
+	bne	a0, t0, 1b
+	sb	a1, -1(a0)
+2:
+	j	ra
+	nop
+END(memset)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/mips/string/strcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,67 @@
+/*	$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <mips/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+	ASMSTR("from: @(#)strcmp.s	8.1 (Berkeley) 6/4/93")
+	ASMSTR("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef __ABICALLS__
+	.abicalls
+#endif
+
+/*
+ * NOTE: this version assumes unsigned chars in order to be "8 bit clean".
+ */
+LEAF(strcmp)
+1:
+	lbu	t0, 0(a0)		# get two bytes and compare them
+	lbu	t1, 0(a1)
+	beq	t0, zero, LessOrEq	# end of first string?
+	bne	t0, t1, NotEq
+	lbu	t0, 1(a0)		# unroll loop
+	lbu	t1, 1(a1)
+	add	a0, a0, 2
+	beq	t0, zero, LessOrEq	# end of first string?
+	add	a1, a1, 2
+	beq	t0, t1, 1b
+NotEq:
+	subu	v0, t0, t1
+	j	ra
+LessOrEq:
+	subu	v0, zero, t1
+	j	ra
+END(strcmp)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/mips/string/strlen.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,54 @@
+/*	$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <mips/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+	ASMSTR("from: @(#)strlen.s	8.1 (Berkeley) 6/4/93")
+	ASMSTR("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef __ABICALLS__
+	.abicalls
+#endif
+
+LEAF(strlen)
+	addu	v1, a0, 1
+1:
+	lb	v0, 0(a0)		# get byte from string
+	addu	a0, a0, 1		# increment pointer
+	bne	v0, zero, 1b		# continue if not end
+	subu	v0, a0, v1		# compute length - 1 for '\0' char
+	j	ra
+END(strlen)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/gen/byte_swap_2.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,47 @@
+/*	$NetBSD: byte_swap_2.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Mach Operating System
+ * Copyright (c) 1992 Carnegie Mellon University
+ * Copyright (c) 1992 Helsinki University of Technology
+ * All Rights Reserved.
+ * 
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ * 
+ * CARNEGIE MELLON AND HELSINKI UNIVERSITY OF TECHNOLOGY ALLOW FREE USE
+ * OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  CARNEGIE MELLON AND
+ * HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIM ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ * 
+ * Carnegie Mellon requests users of this software to return to
+ * 
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ * 
+ * any improvements or extensions that they make and grant Carnegie Mellon 
+ * the rights to redistribute these changes.
+ */
+/*
+ * HISTORY
+ * 11-May-92  Johannes Helander (jvh) at Helsinki University of Technology
+ *	Created.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: byte_swap_2.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif
+
+KENTRY(__bswap16, 4)
+	movzwd	S_ARG0,r0
+	rotw	8,r0
+	ret	ARGS
+ALTENTRY(ntohs,__bswap16)
+ALTENTRY(htons,__bswap16)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/gen/byte_swap_4.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,49 @@
+/*	$NetBSD: byte_swap_4.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Mach Operating System
+ * Copyright (c) 1992 Carnegie Mellon University
+ * Copyright (c) 1992 Helsinki University of Technology
+ * All Rights Reserved.
+ * 
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ * 
+ * CARNEGIE MELLON AND HELSINKI UNIVERSITY OF TECHNOLOGY ALLOW FREE USE
+ * OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  CARNEGIE MELLON AND
+ * HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIM ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ * 
+ * Carnegie Mellon requests users of this software to return to
+ * 
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ * 
+ * any improvements or extensions that they make and grant Carnegie Mellon 
+ * the rights to redistribute these changes.
+ */
+/*
+ * HISTORY
+ * 11-May-92  Johannes Helander (jvh) at Helsinki University of Technology
+ *	Created.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: byte_swap_4.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif
+
+KENTRY(__bswap32, 4)
+	movd	S_ARG0,r0
+	rotw	8,r0
+	rotd	16,r0
+	rotw	8,r0
+	ret	ARGS
+ALTENTRY(ntohl,__bswap32)
+ALTENTRY(htonl,__bswap32)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/bcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,30 @@
+/*	$NetBSD: bcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Written by Matthias Pfaller, 1996
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: bcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif
+
+/*
+ * int
+ * bcmp (const void *b1, const void *b2, size_t len)
+ */
+KENTRY(bcmp, 12)
+	enter	[],0
+	movd	B_ARG2,r0
+	movd	B_ARG0,r1
+	movd	B_ARG1,r2
+	lshd	-2,r0
+	cmpsd
+	bne	0f
+	movqd	3,r0
+	andd	B_ARG2,r0
+	cmpsb
+0:	exit	[]
+	ret	ARGS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/bcopy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: bcopy.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+#define BCOPY
+#include "memcpy.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/bzero.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: bzero.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+#define BZERO
+#include "memset.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/ffs.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,21 @@
+/*	$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Written by Matthias Pfaller, 1996
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif
+
+KENTRY(ffs, 4)
+	enter	[],0
+	movqd	0,r0
+	ffsd	B_ARG0,r0
+	bfs	1f
+	addqd	1,r0
+1:	exit	[]
+	ret	ARGS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/memchr.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,29 @@
+/*	$NetBSD: memchr.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Written by Matthias Pfaller, 1996
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: memchr.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif
+
+/*
+ * void *
+ * memchr (const void *b, int c, size_t len)
+ *	locate the first occurrence of c in string b.
+ */
+
+KENTRY(memchr, 12)
+	enter	[r4],0
+	movd	B_ARG2,r0
+	movb	B_ARG1,r4
+	movd	B_ARG0,r1
+	skpsb	u
+	bfc	0f
+	movd	r1,r0
+0:	exit	[r4]
+	ret	ARGS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/memcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,39 @@
+/*	$NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Written by Matthias Pfaller, 1996
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif
+
+/*
+ * int
+ * memcmp (const void *b1, const void *b2, size_t len)
+ */
+KENTRY(memcmp, 12)
+	enter	[],0
+	movd	B_ARG2,r0
+	movd	B_ARG0,r1
+	movd	B_ARG1,r2
+
+	lshd	-2,r0
+	cmpsd
+	movqd	4,r0
+	bne	1f
+	movqd	3,r0
+	andd	B_ARG2,r0
+1:	cmpsb
+	bne	3f
+2:	exit	[]
+	ret	ARGS
+
+3:	movzbd	0(r1),r0
+	movzbd	0(r2),r1
+	subd	r1,r0
+	exit	[]
+	ret	ARGS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/memcpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,140 @@
+/*	$NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Written by Matthias Pfaller, 1996
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+# if defined(BCOPY)
+	RCSID("$Masqueraded: as bcopy $")
+# endif
+# if defined(MEMMOVE)
+	RCSID("$Masqueraded: as memmove $")
+# endif
+#endif
+
+#if !defined(BCOPY) && !defined(MEMMOVE)
+/*
+ * void *
+ * memcpy (void *d, const void *s, size_t len)
+ *	copy len bytes from the string s to d.
+ */
+
+KENTRY(memcpy, 12)
+#elif defined(BCOPY)
+/*
+ * void
+ * bcopy (void *s, const void *d, size_t len)
+ *	copy len bytes from the string s to d.
+ *	s and d may overlap.
+ */
+
+# if defined(_KERNEL)
+ALTENTRY(ovbcopy,bcopy)
+# endif
+
+KENTRY(bcopy, 12)
+#else
+/*
+ * void *
+ * memmove (void *d, const void *s, size_t len)
+ *	copy len bytes from the string s to d.
+ *	s and d may overlap.
+ */
+
+KENTRY(memmove, 12)
+#endif
+	enter	[r3],0
+	movd	B_ARG2,r0
+#if defined(BCOPY)
+	movd	B_ARG0,r1
+	movd	B_ARG1,r2
+#else
+	movd	B_ARG1,r1
+	movd	B_ARG0,r2
+#endif
+#if defined(MEMMOVE) || defined(BCOPY)
+	cmpd	r2,r1
+	bls	0f
+	movd	r1,r3
+	addd	r0,r3
+	cmpd	r2,r3
+	bls	2f
+#endif
+0:	cmpqd	4,r0
+	bhi	1f
+
+	/*
+	 * Align destination address.
+	 */
+	movd	3,r3
+	andd	r2,r3
+	movd	0(r1),tos	/* Delay write in case src-dst < 4 */
+	negd	r3,r3
+	addqd	4,r3
+	addd	r3,r1
+	addd	r3,r2
+	subd	r3,r0
+
+	movqd	3,r3
+	andd	r0,r3
+	lshd	-2,r0
+	movsd
+
+	movd	r3,r0
+	movsb
+#if !defined(BCOPY)
+	movd	B_ARG0,r0
+	movd	tos,0(r0)
+#else
+	movd	tos,0(B_ARG1)
+#endif
+	exit	[r3]
+	ret	ARGS
+
+1:	movsb
+#if !defined(BCOPY)
+	movd	B_ARG0,r0
+#endif
+	exit	[r3]
+	ret	ARGS
+
+#if defined(MEMMOVE) || defined(BCOPY)
+2:	addd	r0,r1
+	addd	r0,r2
+	addqd	-1,r1
+	addqd	-1,r2
+	cmpqd	4,r0
+	bhi	0f
+
+	/*
+	 * Align destination address.
+	 */
+	movd	r0,r3
+	movqd	1,r0
+	addd	r2,r0
+	andd	3,r0
+	subd	r0,r3
+	movsb	b
+	movd	r3,r0
+	andd	3,r3
+
+	addqd	-3,r1
+	addqd	-3,r2
+	lshd	-2,r0
+	movsd	b
+
+	movd	r3,r0
+	addqd	3,r1
+	addqd	3,r2
+0:	movsb	b
+#if !defined(BCOPY)
+	movd	B_ARG0,r0
+#endif
+	exit	[r3]
+	ret	ARGS
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/memmove.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: memmove.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+#define MEMMOVE
+#include "memcpy.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/memset.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,141 @@
+/*	$NetBSD: memset.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Written by Matthias Pfaller, 1996
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: memset.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+# if defined(BZERO)
+	RCSID("$Masqueraded: as bzero $")
+# endif
+#endif
+
+#if !defined(BZERO)
+/*
+ * void *
+ * memset (void *b, int c, size_t len)
+ *	write len bytes of value c to the string b.
+ */
+#define SETMEMB(d)	movb	r4,d
+#define SETMEMD(d)	movd	r4,d
+KENTRY(memset, 12)
+	enter	[r3,r4],0
+
+	movd	B_ARG0,r1		/* b */
+	movzbd	B_ARG1,r0		/* c */
+	movd	0x01010101,r4
+	muld	r0,r4
+	movd	B_ARG2,r2		/* len */
+#else
+/*
+ * void
+ * bzero (void *b, size_t len)
+ *	write len zero bytes to the string b.
+ */
+#define SETMEMB(d)	movqb	0,d
+#define SETMEMD(d)	movqd	0,d
+KENTRY(bzero, 8)
+	enter	[r3],0
+
+	movd	B_ARG0,r1		/* b */
+	movd	B_ARG1,r2		/* len */
+#endif
+	cmpd	19,r2
+	bhs	6f			/* Not worth the trouble. */
+
+	/*
+	 * Is address aligned?
+	 */
+	movqd	3,r0
+	andd	r1,r0			/* r0 = b & 3 */
+	cmpqd	0,r0
+	beq	0f
+
+	/*
+	 * Align address (if necessary).
+	 */
+	SETMEMD(0(r1))
+	addr	-4(r0)[r2:b],r2		/* len = len + (r0 - 4) */
+	negd	r0,r0
+	addr	4(r0)[r1:b],r1		/* b = b + (-r0 + 4) */
+
+0:	/*
+	 * Compute loop start address.
+	 */
+	movd	r2,r0
+	addr	60(r2),r3
+	andd	60,r0			/* r0 = len & 60 */
+	lshd	-6,r3			/* r3 = (len + 60) >> 6 */
+	andd	3,r2			/* len &= 3 */
+
+	cmpqd	0,r0
+	beq	1f
+
+	addr	-64(r1)[r0:b],r1	/* b = b - 64 + r0 */
+	lshd	-2,r0
+	addr	0(r0)[r0:w],r0
+	negd	r0,r0			/* r0 = -3 * r0 / 4 */
+
+	jump	2f(pc)[r0:b]		/* Now enter the loop */
+
+	/*
+	 * Zero 64 bytes per loop iteration.
+	 */
+	.align	2
+1:	SETMEMD(0(r1))
+	SETMEMD(4(r1))
+	SETMEMD(8(r1))
+	SETMEMD(12(r1))
+	SETMEMD(16(r1))
+	SETMEMD(20(r1))
+	SETMEMD(24(r1))
+	SETMEMD(28(r1))
+	SETMEMD(32(r1))
+	SETMEMD(36(r1))
+	SETMEMD(40(r1))
+	SETMEMD(44(r1))
+	SETMEMD(48(r1))
+	SETMEMD(52(r1))
+	SETMEMD(56(r1))
+	SETMEMD(60(r1))
+2:	addd	64,r1
+	acbd	-1,r3,1b
+
+3:	cmpqd	0,r2
+	beq	5f
+
+	/*
+	 * Zero out blocks shorter than four bytes.
+	 */
+4:	SETMEMB(-1(r1)[r2:b])
+	acbd	-1,r2,4b
+
+#ifndef	BZERO
+5:	movd	B_ARG0,r0
+	exit	[r3,r4]
+	ret	ARGS
+#else
+5:	exit	[r3]
+	ret	ARGS
+#endif
+
+	/*
+	 * For blocks smaller than 20 bytes
+	 * this is faster.
+	 */
+	.align	2
+6:	cmpqd	3,r2
+	bhs	3b
+
+	movd	r2,r0
+	andd	3,r2
+	lshd	-2,r0
+
+7:	SETMEMD(0(r1))
+	addqd	4,r1
+	acbd	-1,r0,7b
+	br	3b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/strcat.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,33 @@
+/*	$NetBSD: strcat.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Written by Matthias Pfaller, 1996
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: strcat.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif
+
+/*
+ * char *
+ * strcat (char *d, const char *s)
+ *	append string s to d.
+ */
+
+KENTRY(strcat, 8)
+	enter	[],0
+	movd	B_ARG0,tos
+	bsr	_C_LABEL(strlen)
+	addd	B_ARG0,r0
+	movd	B_ARG1,0(sp)
+	movd	r0,tos
+	bsr	_C_LABEL(strcpy)
+#if !defined(MRTD)
+	adjspd	-8
+#endif
+	movd	B_ARG0,r0
+	exit	[]
+	ret	ARGS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/strchr.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,141 @@
+/*	$NetBSD: strchr.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Written by Matthias Pfaller, 1996
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: strchr.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+# if defined(INDEX)
+	RCSID("$Masqueraded: as index $")
+# endif
+#endif
+
+#if !defined(INDEX)
+/*
+ * char *
+ * strchr (const char *s, int c)
+ *	locate the first occurrence of c in the string s.
+ */
+KENTRY(strchr, 8)
+#else
+/*
+ * char *
+ * index (const char *s, int c)
+ *	locate the first occurrence of c in the string s.
+ */
+KENTRY(index, 8)
+#endif
+	enter	[r3,r4,r5],0
+	movd	B_ARG0,r0
+	movzbd	B_ARG1,r1
+	movd	0x01010101,r5
+	muld	r1,r5
+
+	/*
+	 * First begin by seeing if we can doubleword align the
+	 * pointer. The following code only aligns the pointer in r0.
+	 */
+
+	movqd	3,r3
+	andd	r0,r3
+
+0:	casew	1f(pc)[r3:w]
+1:	.word	5f-0b
+	.word	2f-0b
+	.word	3f-0b
+	.word	4f-0b
+
+	.align	2,0xa2
+2:	cmpb	r5,0(r0) ; beq 6f ; cmpqb 0,0(r0) ; beq notfound
+	cmpb	r5,1(r0) ; beq 7f ; cmpqb 0,1(r0) ; beq notfound
+	cmpb	r5,2(r0) ; beq 8f ; cmpqb 0,2(r0) ; beq notfound
+	addqd	3,r0
+	br	5f
+
+	.align	2,0xa2
+3:	cmpb	r5,0(r0) ; beq 6f ; cmpqb 0,0(r0) ; beq notfound
+	cmpb	r5,1(r0) ; beq 7f ; cmpqb 0,1(r0) ; beq notfound
+	addqd	2,r0
+	br	5f
+
+	.align	2,0xa2
+4:	cmpb	r5,0(r0) ; beq 6f ; cmpqb 0,0(r0) ; beq notfound
+	addqd	1,r0
+
+	/*
+	 * Okay, when we get down here R0 points at a double word
+	 * algined source block of bytes.
+	 * This guy processes four bytes at a time and checks for the
+	 * zero terminating byte amongst the bytes in the double word.
+	 * This algorithm is de to Dave Rand.
+	 *
+	 * Sneaky test for zero amongst four bytes:
+	 *
+	 *	 xxyyzztt
+	 *	-01010101
+	 *	---------
+	 *	 aabbccdd
+	 *  bic  xxyyzztt
+	 *	---------
+	 *       eeffgghh   ee=0x80 if xx=0, ff=0x80 if yy=0, etc. 
+	 *
+	 *		This whole result will be zero if there
+	 *		was no zero byte, it will be non-zero if
+	 *		there is a zero byte present.
+	 */
+   
+5:	movd	0x01010101,r2		/* Magic number to use */
+	movd	0x80808080,r3		/* Another magic number. */
+
+	addqd	-4,r0
+
+	.align	2,0xa2
+0:	movd	4(r0),r1		/* Get next double word. */
+	addd	4,r0			/* Advance pointer */
+	movd	r1,r4			/* Save for storage later. */
+	subd	r2,r1			/* Gets borrow if byte = 0. */
+	bicd	r4,r1			/* Clear original bits. */
+	andd	r3,r1			/* See if borrow occurred. */
+	cmpqd	0,r1
+	bne	1f			/* See if this DWORD contained a 0. */
+	xord	r5,r4			/* Convert any 'c' to 0. */
+	movd	r4,r1
+	subd	r2,r1
+	bicd	r4,r1
+	andd	r3,r1
+	cmpqd	0,r1
+	beq	0b
+
+	/*
+	 * At this point, r0 points at a double word which
+	 * contains a zero byte or c.
+	 */
+
+1:	cmpb	r5,0(r0) ; beq 6f ; cmpqb 0,0(r0) ; beq notfound
+	cmpb	r5,1(r0) ; beq 7f ; cmpqb 0,1(r0) ; beq notfound
+	cmpb	r5,2(r0) ; beq 8f ; cmpqb 0,2(r0) ; beq notfound
+	cmpb	r5,3(r0) ; beq 9f
+
+notfound:
+	movqd	0,r0
+	exit	[r3,r4,r5]
+	ret	ARGS
+	
+6:	exit	[r3,r4,r5]
+	ret	ARGS
+
+7:	addqd	1,r0
+	exit	[r3,r4,r5]
+	ret	ARGS
+
+8:	addqd	2,r0
+	exit	[r3,r4,r5]
+	ret	ARGS
+
+9:	addqd	3,r0
+	exit	[r3,r4,r5]
+	ret	ARGS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/strcmp.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,4 @@
+/*	$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+#define STRCMP
+#include "strncmp.S"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/lib/libc/arch/ns32k/string/strcpy.S	Tue Dec 20 19:28:49 2005 +0000
@@ -0,0 +1,121 @@
+/*	$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:50 christos Exp $	*/
+
+/* 
+ * Written by Randy Hyde, 1993
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+	RCSID("$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
+#endif
+
+/*
+ * char *
+ * strcpy (char *d, const char *s)
+ *	copy string s to d.
+ */
+
+KENTRY(strcpy, 8)
+	enter	[r3,r4,r5],0
+	movd	B_ARG1,r1
+	movd	B_ARG0,r2
+
+	/*
+	 * We need to double word align the src (R1). When we read
+	 * by double words we can read potentially up to 3 bytes
+	 * past the null terminating byte. We can avoid spurious page
+	 * faults by double word aligning the source. It also runs
+	 * faster.  IWD
+	 */
+
+	movqd	3,r3
+	andd	r1,r3
+
+0:	casew	1f(pc)[r3:w]
+1:	.word	5f-0b
+	.word	2f-0b
+	.word	3f-0b
+	.word	4f-0b
+
+	.align	2,0xa2
+2:	movb	0(r1),0(r2) ; cmpqb 0,0(r1) ; beq 9f
+	movb 	1(r1),1(r2) ; cmpqb 0,1(r1) ; beq 9f
+	movb	2(r1),2(r2) ; cmpqb 0,2(r1) ; beq 9f
+	addqd	3,r1
+	addqd	3,r2
+	br	5f
+
+	.align	2,0xa2
+3:	movb	0(r1),0(r2) ; cmpqb 0,0(r1) ; beq 9f
+	movb 	1(r1),1(r2) ; cmpqb 0,1(r1) ; beq 9f
+	addqd	2,r1
+	addqd	2,r2
+	br	5f
+
+	.align	2,0xa2
+4:	movb	0(r1),0(r2) ; cmpqb 0,0(r1) ; beq 9f
+	addqd	1,r1
+	addqd	1,r2
+
+	/*
+	 * Okay, when we get down here R1 points at a double word
+	 * aligned source block of bytes, R2 points at the destination
+	 * block of bytes (typically, though not always double word
+	 * aligned).
+	 * This guy processes four bytes at a time and checks for the
+	 * zero terminating byte amongst the bytes in the double word.
+	 * This algorithm is due to Dave Rand.
+	 *
+	 * Sneaky test for zero amongst four bytes:
+	 *
+	 *	 xxyyzztt
+	 *	-01010101
+	 *	---------
+	 *	 aabbccdd
+	 *  bic  xxyyzztt
+	 *	---------
+	 *       eeffgghh   ee=0x80 if xx=0, ff=0x80 if yy=0, etc. 
+	 *
+	 *		This whole result will be zero if there