summaryrefslogtreecommitdiff
path: root/lib/libc/arch/m68k/string
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
commitd6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch)
treeece253b876159b39c620e62b6c9b1174642e070e /lib/libc/arch/m68k/string
initial import of NetBSD tree
Diffstat (limited to 'lib/libc/arch/m68k/string')
-rw-r--r--lib/libc/arch/m68k/string/Makefile.inc7
-rw-r--r--lib/libc/arch/m68k/string/bcmp.S91
-rw-r--r--lib/libc/arch/m68k/string/bcopy.S132
-rw-r--r--lib/libc/arch/m68k/string/bzero.S80
-rw-r--r--lib/libc/arch/m68k/string/ffs.S56
-rw-r--r--lib/libc/arch/m68k/string/index.S62
-rw-r--r--lib/libc/arch/m68k/string/memcmp.S100
-rw-r--r--lib/libc/arch/m68k/string/memcpy.S2
-rw-r--r--lib/libc/arch/m68k/string/memmove.S2
-rw-r--r--lib/libc/arch/m68k/string/memset.S111
-rw-r--r--lib/libc/arch/m68k/string/rindex.S62
-rw-r--r--lib/libc/arch/m68k/string/strchr.S2
-rw-r--r--lib/libc/arch/m68k/string/strcmp.S66
-rw-r--r--lib/libc/arch/m68k/string/strcpy.S53
-rw-r--r--lib/libc/arch/m68k/string/strlen.S53
-rw-r--r--lib/libc/arch/m68k/string/strncmp.S71
-rw-r--r--lib/libc/arch/m68k/string/strncpy.S63
-rw-r--r--lib/libc/arch/m68k/string/strrchr.S2
-rw-r--r--lib/libc/arch/m68k/string/swab.S18
19 files changed, 1033 insertions, 0 deletions
diff --git a/lib/libc/arch/m68k/string/Makefile.inc b/lib/libc/arch/m68k/string/Makefile.inc
new file mode 100644
index 00000000000..8ed076485f3
--- /dev/null
+++ b/lib/libc/arch/m68k/string/Makefile.inc
@@ -0,0 +1,7 @@
+# $NetBSD: Makefile.inc,v 1.1 1995/03/20 14:45:45 mycroft Exp $
+
+SRCS+= bcmp.S bcopy.S bzero.S ffs.S index.S memchr.c memcmp.S memset.S \
+ rindex.S strcat.c strcmp.S strcpy.S strcspn.c strlen.S \
+ strncat.c strncmp.S strncpy.S strpbrk.c strsep.c \
+ strspn.c strstr.c swab.S
+SRCS+= memcpy.S memmove.S strchr.S strrchr.S
diff --git a/lib/libc/arch/m68k/string/bcmp.S b/lib/libc/arch/m68k/string/bcmp.S
new file mode 100644
index 00000000000..2cfae67e363
--- /dev/null
+++ b/lib/libc/arch/m68k/string/bcmp.S
@@ -0,0 +1,91 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)bcmp.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: bcmp.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+/* bcmp(s1, s2, n) */
+
+#include "DEFS.h"
+
+/*
+ * 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(bcmp)
+ movl sp@(4),a0 | string 1
+ movl sp@(8),a1 | string 2
+ movl sp@(12),d0 | length
+ beq bcdone | if zero, nothing to do
+ movl a0,d1
+ btst #0,d1 | string 1 address odd?
+ beq bceven | no, skip alignment
+ cmpmb a0@+,a1@+ | yes, compare a byte
+ bne bcnoteq | not equal, return non-zero
+ subql #1,d0 | adjust count
+ beq bcdone | count 0, reutrn zero
+bceven:
+ movl a1,d1
+ btst #0,d1 | string 2 address odd?
+ bne bcbloop | yes, no hope for alignment, compare bytes
+ movl d0,d1 | no, both even
+ lsrl #2,d1 | convert count to longword count
+ beq bcbloop | count 0, skip longword loop
+bclloop:
+ cmpml a0@+,a1@+ | compare a longword
+ bne bcnoteq | not equal, return non-zero
+ subql #1,d1 | adjust count
+ bne bclloop | still more, keep comparing
+ andl #3,d0 | what remains
+ beq bcdone | nothing, all done
+bcbloop:
+ cmpmb a0@+,a1@+ | compare a byte
+ bne bcnoteq | not equal, return non-zero
+ subql #1,d0 | adjust count
+ bne bcbloop | still more, keep going
+ rts
+bcnoteq:
+ moveq #1,d0
+bcdone:
+ rts
diff --git a/lib/libc/arch/m68k/string/bcopy.S b/lib/libc/arch/m68k/string/bcopy.S
new file mode 100644
index 00000000000..137c27db218
--- /dev/null
+++ b/lib/libc/arch/m68k/string/bcopy.S
@@ -0,0 +1,132 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)bcopy.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: bcopy.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * 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:
+ * - unroll the longword copy loop (might not be good for a 68020)
+ * - longword align when possible (only on the 68020)
+ * - use nested DBcc instructions or use one and limit size to 64K
+ */
+#ifdef MEMCOPY
+ENTRY(memcpy)
+#else
+#ifdef MEMMOVE
+ENTRY(memmove)
+#else
+ENTRY(bcopy)
+#endif
+#endif
+ movl sp@(12),d1 | check count
+ beq bcdone | == 0, do not do anything
+#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
+ cmpl a1,a0 | src after dest?
+ blt bcback | yes, must copy backwards
+ movl a0,d0
+ btst #0,d0 | src address odd?
+ beq bcfeven | no, skip alignment
+ movb a0@+,a1@+ | yes, copy a byte
+ subql #1,d1 | adjust count
+ beq bcdone | count 0, all done
+bcfeven:
+ movl a1,d0
+ btst #0,d0 | dest address odd?
+ bne bcfbloop | yes, no hope for alignment, copy bytes
+ movl d1,d0 | no, both even
+ lsrl #2,d0 | convert count to longword count
+ beq bcfbloop | count 0, skip longword loop
+bcflloop:
+ movl a0@+,a1@+ | copy a longword
+ subql #1,d0 | adjust count
+ bne bcflloop | still more, keep copying
+ andl #3,d1 | what remains
+ beq bcdone | nothing, all done
+bcfbloop:
+ movb a0@+,a1@+ | copy a byte
+ subql #1,d1 | adjust count
+ bne bcfbloop | still more, keep going
+bcdone:
+#if defined(MEMCOPY) || defined(MEMMOVE)
+ movl sp@(4),d0 | dest address
+#endif
+ rts
+bcback:
+ addl d1,a0 | src pointer to end
+ addl d1,a1 | dest pointer to end
+ movl a0,d0
+ btst #0,d0 | src address odd?
+ beq bcbeven | no, skip alignment
+ movb a0@-,a1@- | yes, copy a byte
+ subql #1,d1 | adjust count
+ beq bcdone | count 0, all done
+bcbeven:
+ movl a1,d0
+ btst #0,d0 | dest address odd?
+ bne bcbbloop | yes, no hope for alignment, copy bytes
+ movl d1,d0 | no, both even
+ lsrl #2,d0 | convert count to longword count
+ beq bcbbloop | count 0, skip longword loop
+bcblloop:
+ movl a0@-,a1@- | copy a longword
+ subql #1,d0 | adjust count
+ bne bcblloop | still more, keep copying
+ andl #3,d1 | what remains
+ beq bcdone | nothing, all done
+bcbbloop:
+ movb a0@-,a1@- | copy a byte
+ subql #1,d1 | adjust count
+ bne bcbbloop | still more, keep going
+#if defined(MEMCOPY) || defined(MEMMOVE)
+ movl sp@(4),d0 | dest address
+#endif
+ rts
diff --git a/lib/libc/arch/m68k/string/bzero.S b/lib/libc/arch/m68k/string/bzero.S
new file mode 100644
index 00000000000..c9822440bb2
--- /dev/null
+++ b/lib/libc/arch/m68k/string/bzero.S
@@ -0,0 +1,80 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)bzero.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: bzero.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * This is probably not the best we can do, but it is still much
+ * faster than the C version in the portable gen directory.
+ *
+ * Things that might help:
+ * - unroll the longword loop (might not be good for a 68020)
+ * - longword, as opposed to word, align when possible (only on the 68020)
+ * - use nested DBcc instructions or use one and limit size to 64K
+ */
+ENTRY(bzero)
+ movl sp@(4),a0 | destination
+ movl sp@(8),d0 | count
+ beq bzdone | nothing to do
+ movl a0,d1
+ btst #0,d1 | address odd?
+ beq bzeven | no, skip alignment
+ clrb a0@+ | yes, clear a byte
+ subql #1,d0 | adjust count
+ beq bzdone | if zero, all done
+bzeven:
+ movl d0,d1
+ lsrl #2,d1 | convert to longword count
+ beq bzbloop | no longwords, skip loop
+bzlloop:
+ clrl a0@+ | clear a longword
+ subql #1,d1 | adjust count
+ bne bzlloop | still more, keep going
+ andl #3,d0 | what remains
+ beq bzdone | nothing, all done
+bzbloop:
+ clrb a0@+ | clear a byte
+ subql #1,d0 | adjust count
+ bne bzbloop | still more, keep going
+bzdone:
+ rts
diff --git a/lib/libc/arch/m68k/string/ffs.S b/lib/libc/arch/m68k/string/ffs.S
new file mode 100644
index 00000000000..d35e3ffd291
--- /dev/null
+++ b/lib/libc/arch/m68k/string/ffs.S
@@ -0,0 +1,56 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)ffs.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: ffs.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+/* bit = ffs(value) */
+
+#include "DEFS.h"
+
+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
diff --git a/lib/libc/arch/m68k/string/index.S b/lib/libc/arch/m68k/string/index.S
new file mode 100644
index 00000000000..1d26bc4bc60
--- /dev/null
+++ b/lib/libc/arch/m68k/string/index.S
@@ -0,0 +1,62 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)index.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: index.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+#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?
+ beq ixfound | yes, break out
+ tstb a0@+ | null?
+ bne ixloop | no, keep going
+ moveq #0,d0 | not found, return null
+ rts
+ixfound:
+ movl a0,d0 | found, return pointer
+ rts
diff --git a/lib/libc/arch/m68k/string/memcmp.S b/lib/libc/arch/m68k/string/memcmp.S
new file mode 100644
index 00000000000..578c23308ba
--- /dev/null
+++ b/lib/libc/arch/m68k/string/memcmp.S
@@ -0,0 +1,100 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)bcmp.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: memcmp.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+/* memcmp(s1, s2, n) */
+
+#include "DEFS.h"
+
+/*
+ * 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
+ beq bcdone | if zero, nothing to do
+ movl a0,d1
+ btst #0,d1 | string 1 address odd?
+ beq bceven | no, skip alignment
+ cmpmb a0@+,a1@+ | yes, compare a byte
+ bne bcnoteq | not equal, return non-zero
+ subql #1,d0 | adjust count
+ beq bcdone | count 0, reutrn zero
+bceven:
+ movl a1,d1
+ btst #0,d1 | string 2 address odd?
+ bne bcbloop | yes, no hope for alignment, compare bytes
+ movl d0,d1 | no, both even
+ lsrl #2,d1 | convert count to longword count
+ beq bcbloop | count 0, skip longword loop
+bclloop:
+ cmpml a0@+,a1@+ | compare a longword
+ bne bcnoteql | not equal, return non-zero
+ subql #1,d1 | adjust count
+ bne bclloop | still more, keep comparing
+ andl #3,d0 | what remains
+ beq bcdone | nothing, all done
+bcbloop:
+ cmpmb a0@+,a1@+ | compare a byte
+ bne bcnoteq | not equal, return non-zero
+ subql #1,d0 | adjust count
+ bne 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
diff --git a/lib/libc/arch/m68k/string/memcpy.S b/lib/libc/arch/m68k/string/memcpy.S
new file mode 100644
index 00000000000..1617c7153aa
--- /dev/null
+++ b/lib/libc/arch/m68k/string/memcpy.S
@@ -0,0 +1,2 @@
+#define MEMCOPY
+#include "bcopy.S"
diff --git a/lib/libc/arch/m68k/string/memmove.S b/lib/libc/arch/m68k/string/memmove.S
new file mode 100644
index 00000000000..f5a94ed4937
--- /dev/null
+++ b/lib/libc/arch/m68k/string/memmove.S
@@ -0,0 +1,2 @@
+#define MEMMOVE
+#include "bcopy.S"
diff --git a/lib/libc/arch/m68k/string/memset.S b/lib/libc/arch/m68k/string/memset.S
new file mode 100644
index 00000000000..322abc10582
--- /dev/null
+++ b/lib/libc/arch/m68k/string/memset.S
@@ -0,0 +1,111 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)bzero.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: memset.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * This is probably not the best we can do, but it is still much
+ * faster than the C version in the portable gen directory.
+ *
+ * Things that might help:
+ * - unroll the longword loop (might not be good for a 68020)
+ * - longword, as opposed to word, align when possible (only on the 68020)
+ * - use nested DBcc instructions or use one and limit size to 64K
+ */
+ENTRY(memset)
+ movl d2,sp@-
+ movl sp@(8),a0 | destination
+ movl sp@(16),d0 | count
+ beq bzdone | nothing to do
+ movb sp@(15),d2 | character
+ movl a0,d1
+ btst #0,d1 | address odd?
+ beq bzeven | no, skip alignment
+ movb d2,a0@+ | set one byte
+ subql #1,d0 | adjust count
+ beq bzdone | if zero, all done
+bzeven:
+ cmpl #15,d0
+ ble bzbloop | too small to be worthwhile
+ clrl d1 | replicate byte to fill longword
+ movb d2,d1
+ movl d1,d2
+ lsll #8,d1
+ orl d1,d2
+ lsll #8,d1
+ orl d1,d2
+ lsll #8,d1
+ orl d1,d2
+ movl d0,d1 | convert to longword count
+ lsrl #2,d1
+#ifdef DEBUG
+ moveml #0xffff,sp@-
+ movl d2,sp@-
+ movl d1,sp@-
+ movl d0,sp@-
+ movl a0,sp@-
+ movl #foo,sp@-
+ jsr _printf
+ addl #20,sp
+ moveml sp@+,#0xffff
+#endif
+bzlloop:
+ movl d2,a0@+ | set one longword
+ subql #1,d1 | adjust count
+ bne bzlloop | still more, keep going
+ andl #3,d0 | what remains
+ beq bzdone | nothing, all done
+bzbloop:
+ movb d2,a0@+ | set one byte
+ subql #1,d0 | adjust count
+ bne bzbloop | still more, keep going
+bzdone:
+ movl sp@(8),d0 | return destination
+ movl sp@+,d2
+ rts
+
+#ifdef DEBUG
+ .globl _printf
+foo:
+ .asciz "a0=%08x d0=%08x d1=%08x d2=%08x\n"
+#endif
diff --git a/lib/libc/arch/m68k/string/rindex.S b/lib/libc/arch/m68k/string/rindex.S
new file mode 100644
index 00000000000..211654d34f6
--- /dev/null
+++ b/lib/libc/arch/m68k/string/rindex.S
@@ -0,0 +1,62 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)rindex.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: rindex.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+#ifdef STRRCHR
+ENTRY(strrchr)
+#else
+ENTRY(rindex)
+#endif
+ movl sp@(4),a0 | string
+ movb sp@(11),d0 | char to look for
+ subl a1,a1 | clear rindex pointer
+rixloop:
+ cmpb a0@,d0 | found our char?
+ bne rixnope | no, check for null
+ movl a0,a1 | yes, remember location
+rixnope:
+ tstb a0@+ | null?
+ bne rixloop | no, keep going
+ movl a1,d0 | return value
+ rts
diff --git a/lib/libc/arch/m68k/string/strchr.S b/lib/libc/arch/m68k/string/strchr.S
new file mode 100644
index 00000000000..e603668efe5
--- /dev/null
+++ b/lib/libc/arch/m68k/string/strchr.S
@@ -0,0 +1,2 @@
+#define STRCHR
+#include "index.S"
diff --git a/lib/libc/arch/m68k/string/strcmp.S b/lib/libc/arch/m68k/string/strcmp.S
new file mode 100644
index 00000000000..92dfd30c57b
--- /dev/null
+++ b/lib/libc/arch/m68k/string/strcmp.S
@@ -0,0 +1,66 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)strcmp.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: strcmp.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * NOTE: this guy returns result compatible with the VAX assembly version.
+ * The C version on the portable gen directory returns different results
+ * (different signs!) when comparing chars with the high bit on. Who is
+ * right??
+ */
+ENTRY(strcmp)
+ movl sp@(4),a0 | a0 = string1
+ movl sp@(8),a1 | a1 = string2
+scloop:
+ movb a0@+,d0 | get *string1
+ cmpb a1@+,d0 | compare a byte
+ bne scexit | not equal, break out
+ tstb d0 | at end of string1?
+ bne scloop | no, keep going
+ moveq #0,d0 | strings are equal
+ rts
+scexit:
+ subb a1@-,d0 | *string1 - *string2
+ extbl d0
+ rts
diff --git a/lib/libc/arch/m68k/string/strcpy.S b/lib/libc/arch/m68k/string/strcpy.S
new file mode 100644
index 00000000000..de1be32b574
--- /dev/null
+++ b/lib/libc/arch/m68k/string/strcpy.S
@@ -0,0 +1,53 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: strcpy.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+ENTRY(strcpy)
+ movl sp@(8),a0 | a0 = fromaddr
+ movl sp@(4),d0 | return value is toaddr
+ movl d0,a1 | a1 = toaddr
+scloop:
+ movb a0@+,a1@+ | copy a byte
+ bne scloop | copied non-null, keep going
+ rts
diff --git a/lib/libc/arch/m68k/string/strlen.S b/lib/libc/arch/m68k/string/strlen.S
new file mode 100644
index 00000000000..65c94469f92
--- /dev/null
+++ b/lib/libc/arch/m68k/string/strlen.S
@@ -0,0 +1,53 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)strlen.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: strlen.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+ENTRY(strlen)
+ moveq #-1,d0
+ movl sp@(4),a0 | string
+slloop:
+ addql #1,d0 | increment count
+ tstb a0@+ | null?
+ bne slloop | no, keep going
+ rts
diff --git a/lib/libc/arch/m68k/string/strncmp.S b/lib/libc/arch/m68k/string/strncmp.S
new file mode 100644
index 00000000000..7d06a8de187
--- /dev/null
+++ b/lib/libc/arch/m68k/string/strncmp.S
@@ -0,0 +1,71 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)strncmp.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: strncmp.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * NOTE: this guy returns result compatible with the VAX assembly version.
+ * The C version on the portable gen directory returns different results
+ * (different signs!) when comparing chars with the high bit on. Who is
+ * right??
+ */
+ENTRY(strncmp)
+ movl sp@(12),d1 | count
+ beq scdone | nothing to do
+ movl sp@(4),a0 | a0 = string1
+ movl sp@(8),a1 | a1 = string2
+scloop:
+ movb a0@+,d0 | get *string1
+ cmpb a1@+,d0 | compare a byte
+ bne scexit | not equal, break out
+ tstb d0 | at end of string1?
+ beq scdone | yes, all done
+ subql #1,d1 | no, adjust count
+ bne scloop | more to do, keep going
+scdone:
+ moveq #0,d0 | strings are equal
+ rts
+scexit:
+ subb a1@-,d0 | *string1 - *string2
+ extbl d0
+ rts
diff --git a/lib/libc/arch/m68k/string/strncpy.S b/lib/libc/arch/m68k/string/strncpy.S
new file mode 100644
index 00000000000..310614c3ac9
--- /dev/null
+++ b/lib/libc/arch/m68k/string/strncpy.S
@@ -0,0 +1,63 @@
+/*-
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .text
+ /*.asciz "from: @(#)strncpy.s 5.1 (Berkeley) 5/12/90"*/
+ .asciz "$Id: strncpy.S,v 1.1 1995/10/18 08:41:31 deraadt Exp $"
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+ENTRY(strncpy)
+ movl sp@(4),d0 | return value is toaddr
+ movl sp@(12),d1 | count
+ beq scdone | nothing to do
+ movl sp@(8),a0 | a0 = fromaddr
+ movl d0,a1 | a1 = toaddr
+scloop:
+ movb a0@+,a1@+ | copy a byte
+ beq scploop | copied null, go pad if necessary
+ subql #1,d1 | adjust count
+ bne scloop | more room, keep going
+scdone:
+ rts
+scploop:
+ subql #1,d1 | adjust count
+ beq scdone | no more room, all done
+ clrb a1@+ | clear a byte
+ jra scploop | keep going
diff --git a/lib/libc/arch/m68k/string/strrchr.S b/lib/libc/arch/m68k/string/strrchr.S
new file mode 100644
index 00000000000..f9deb5a826e
--- /dev/null
+++ b/lib/libc/arch/m68k/string/strrchr.S
@@ -0,0 +1,2 @@
+#define STRRCHR
+#include "rindex.S"
diff --git a/lib/libc/arch/m68k/string/swab.S b/lib/libc/arch/m68k/string/swab.S
new file mode 100644
index 00000000000..80d5d120535
--- /dev/null
+++ b/lib/libc/arch/m68k/string/swab.S
@@ -0,0 +1,18 @@
+#include "DEFS.h"
+
+ENTRY(swab)
+ movl sp@(4),a0 | source
+ movl sp@(8),a1 | destination
+ movl sp@(12),d0 | count
+ lsrl #1,d0 | count is in bytes; we need words
+ beq swdone
+
+swloop:
+ movw a0@+,d1
+ rorw #8,d1
+ movw d1,a1@+
+ subql #1,d0
+ bne swloop
+
+swdone:
+ rts