Add assembly language versions of string and memory functions.
authorJ.T. Conklin <jtc@FreeBSD.org>
Mon, 16 Aug 1993 18:40:50 +0000 (18:40 +0000)
committerJ.T. Conklin <jtc@FreeBSD.org>
Mon, 16 Aug 1993 18:40:50 +0000 (18:40 +0000)
18 files changed:
lib/libc/i386/string/bcmp.s [new file with mode: 0644]
lib/libc/i386/string/bcopy.s
lib/libc/i386/string/bzero.s
lib/libc/i386/string/ffs.s [new file with mode: 0644]
lib/libc/i386/string/index.s [new file with mode: 0644]
lib/libc/i386/string/memchr.s [new file with mode: 0644]
lib/libc/i386/string/memcmp.s [new file with mode: 0644]
lib/libc/i386/string/memcpy.s [new file with mode: 0644]
lib/libc/i386/string/memmove.s [new file with mode: 0644]
lib/libc/i386/string/memset.s [new file with mode: 0644]
lib/libc/i386/string/rindex.s [new file with mode: 0644]
lib/libc/i386/string/strcat.s [new file with mode: 0644]
lib/libc/i386/string/strchr.s [new file with mode: 0644]
lib/libc/i386/string/strcmp.s [new file with mode: 0644]
lib/libc/i386/string/strcpy.s [new file with mode: 0644]
lib/libc/i386/string/strlen.s [new file with mode: 0644]
lib/libc/i386/string/strncmp.s [new file with mode: 0644]
lib/libc/i386/string/strrchr.s [new file with mode: 0644]

diff --git a/lib/libc/i386/string/bcmp.s b/lib/libc/i386/string/bcmp.s
new file mode 100644 (file)
index 0000000..ff46706
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: bcmp.s,v 1.3 1993/08/16 17:06:27 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: bcmp.s,v 1.3 1993/08/16 17:06:27 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * bcmp (void *b1, void *b2, size_t len)
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+/*
+ * XXX should compare by words
+ */
+
+ENTRY(bcmp)
+       pushl   %edi
+       pushl   %esi
+       movl    12(%esp),%edi
+       movl    16(%esp),%esi
+       movl    20(%esp),%ecx
+       xorl    %eax,%eax               /* clear return value */
+       cld                             /* set compare direction forward */
+       repe                            /* compare! */
+       cmpsb
+       je      L1                      /* matches! */
+       incl    %eax
+L1:    popl    %esi
+       popl    %edi
+       ret
index 0ee464b..06a74e2 100644 (file)
  * 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.
  * 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: bcopy.s,v 1.6 1993/08/16 17:06:29 jtc Exp $
  */
 
 #if defined(LIBC_RCS) && !defined(lint)
  */
 
 #if defined(LIBC_RCS) && !defined(lint)
-       .asciz "$ID$"
+       .asciz "$Id: bcopy.s,v 1.6 1993/08/16 17:06:29 jtc Exp $"
 #endif /* LIBC_RCS and not lint */
 
 #endif /* LIBC_RCS and not lint */
 
+#include "DEFS.h"
+
        /*
         * (ov)bcopy (src,dst,cnt)
         *  ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
         */
 
        /*
         * (ov)bcopy (src,dst,cnt)
         *  ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
         */
 
-       .globl  _bcopy
-_bcopy:
+ENTRY(bcopy)
        pushl   %esi
        pushl   %edi
        movl    12(%esp),%esi
        pushl   %esi
        pushl   %edi
        movl    12(%esp),%esi
index d876e69..9881d30 100644 (file)
@@ -1,10 +1,7 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
  * All rights reserved.
  *
  * 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:
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *    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:
  *    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 product includes software developed by Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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.
  *
  *
- * 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.
+ *     $Id: bzero.s,v 1.6 1993/08/16 17:06:29 jtc Exp $
  */
 
  */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-       .asciz "@(#)bzero.s     5.1 (Berkeley) 4/23/90"
-#endif /* LIBC_SCCS and not lint */
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: bzero.s,v 1.6 1993/08/16 17:06:29 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
 
 
-/* bzero (base,cnt) */
+#include "DEFS.h"
 
 
-       .globl _bzero
-_bzero:
+/*
+ * bzero (void *b, size_t len)
+ *     write len zero bytes to the string b.
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+ENTRY(bzero)
        pushl   %edi
        pushl   %edi
-       movl    8(%esp),%edi
-       movl    12(%esp),%ecx
-       movb    $0x00,%al
-       cld
+       pushl   %ebx
+       movl    12(%esp),%edi
+       movl    16(%esp),%ecx
+
+       cld                             /* set fill direction forward */
+       xorl    %eax,%eax               /* set fill data to 0 */
+
+       /*
+        * 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.
+        */
+       cmpl    $0x0f,%ecx
+       jle     L1
+
+       movl    %edi,%edx               /* compute misalignment */
+       negl    %edx
+       andl    $3,%edx
+       movl    %ecx,%ebx
+       subl    %edx,%ebx
+
+       movl    %edx,%ecx               /* zero until word aligned */
        rep
        stosb
        rep
        stosb
+
+       movl    %ebx,%ecx               /* zero by words */
+       shrl    $2,%ecx
+       rep
+       stosl
+
+       movl    %ebx,%ecx
+       andl    $3,%ecx                 /* zero remainder by bytes */
+L1:    rep
+       stosb
+
+       popl    %ebx
        popl    %edi
        ret
        popl    %edi
        ret
diff --git a/lib/libc/i386/string/ffs.s b/lib/libc/i386/string/ffs.s
new file mode 100644 (file)
index 0000000..cd0322c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: ffs.s,v 1.4 1993/08/16 17:06:30 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: ffs.s,v 1.4 1993/08/16 17:06:30 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * ffs(value)
+ *     finds the first bit set in value and returns the index of 
+ *     that bit.  Bits are numbered starting from 1, starting at the
+ *     rightmost bit.  A return value of 0 means that the argument
+ *     was zero.
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+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 2
+L1:    xorl    %eax,%eax               /* clear result */
+       ret
diff --git a/lib/libc/i386/string/index.s b/lib/libc/i386/string/index.s
new file mode 100644 (file)
index 0000000..585e8a1
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: index.s,v 1.4 1993/08/16 17:06:31 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: index.s,v 1.4 1993/08/16 17:06:31 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * index(s, c)
+ *     return a pointer to the first occurance of the character c in
+ *     string s, or NULL if c does not occur in the string.
+ *
+ * %edx - pointer iterating through string
+ * %eax - pointer to first occurance of 'c'
+ * %cl  - character we're comparing against
+ * %bl  - character at %edx
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+ENTRY(index)
+       pushl   %ebx
+       movl    8(%esp),%eax
+       movb    12(%esp),%cl
+       .align 2,0x90
+L1:
+       movb    (%eax),%bl
+       cmpb    %bl,%cl                 /* found char??? */
+       je      L2
+       incl    %eax
+       testb   %bl,%bl                 /* null terminator??? */
+       jne     L1
+       xorl    %eax,%eax
+L2:
+       popl    %ebx
+       ret
diff --git a/lib/libc/i386/string/memchr.s b/lib/libc/i386/string/memchr.s
new file mode 100644 (file)
index 0000000..0e3b1c4
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: memchr.s,v 1.3 1993/08/16 17:06:32 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: memchr.s,v 1.3 1993/08/16 17:06:32 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * memchr (b, c, len)
+ *     locates the first occurance of c in string b.
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+ENTRY(memchr)
+       pushl   %edi
+       movl    8(%esp),%edi            /* string address */
+       movl    12(%esp),%eax           /* set character to search for */
+       movl    16(%esp),%ecx           /* set length of search */
+       testl   %eax,%eax               /* clear Z flag, for len == 0 */
+       cld                             /* set search forward */
+       repne                           /* search! */
+       scasb
+       jnz     L1                      /* scan failed, return null */
+       leal    -1(%edi),%eax           /* adjust result of scan */
+       popl    %edi
+       ret
+       .align 2,0x90
+L1:    xorl    %eax,%eax
+       popl    %edi
+       ret
diff --git a/lib/libc/i386/string/memcmp.s b/lib/libc/i386/string/memcmp.s
new file mode 100644 (file)
index 0000000..6aef30f
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: memcmp.s,v 1.3 1993/08/16 17:06:33 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: memcmp.s,v 1.3 1993/08/16 17:06:33 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * memcmp (void *b1, void *b2, size_t len)
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+/*
+ * XXX should compare by words
+ */
+
+ENTRY(memcmp)
+       pushl   %edi
+       pushl   %esi
+       movl    12(%esp),%edi
+       movl    16(%esp),%esi
+       movl    20(%esp),%ecx
+       xorl    %eax,%eax               /* clear return value */
+       cld                             /* set compare direction forward */
+       repe                            /* compare! */
+       cmpsb
+       je      L1                      /* matches! */
+       movsbl  -1(%edi),%eax           /* unsigned comparison */
+        movsbl  -1(%esi),%edx
+        subl    %edx,%eax
+L1:    popl    %esi
+       popl    %edi
+       ret
+
diff --git a/lib/libc/i386/string/memcpy.s b/lib/libc/i386/string/memcpy.s
new file mode 100644 (file)
index 0000000..fb9a547
--- /dev/null
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ *
+ * 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.
+ *
+ *     $Id: memmove.s,v 1.7 1993/08/16 17:06:34 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: memmove.s,v 1.7 1993/08/16 17:06:34 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+       /*
+        * (ov)bcopy (src,dst,cnt)
+        *  ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
+        */
+
+ENTRY(memcpy)
+       pushl   %esi
+       pushl   %edi
+       movl    12(%esp),%edi
+       pushl   %edi
+       movl    20(%esp),%esi
+       movl    24(%esp),%ecx
+       cmpl    %esi,%edi       /* potentially overlapping? */
+       jnb     1f
+       cld                     /* nope, copy forwards. */
+       shrl    $2,%ecx         /* copy by words */
+       rep
+       movsl
+       movl    24(%esp),%ecx
+       andl    $3,%ecx         /* any bytes left? */
+       rep
+       movsb
+       popl    %eax
+       popl    %edi
+       popl    %esi
+       ret
+1:
+       addl    %ecx,%edi       /* copy backwards. */
+       addl    %ecx,%esi
+       std
+       andl    $3,%ecx         /* any fractional bytes? */
+       decl    %edi
+       decl    %esi
+       rep
+       movsb
+       movl    24(%esp),%ecx   /* copy remainder by words */
+       shrl    $2,%ecx
+       subl    $3,%esi
+       subl    $3,%edi
+       rep
+       movsl
+       popl    %eax
+       popl    %edi
+       popl    %esi
+       cld
+       ret
diff --git a/lib/libc/i386/string/memmove.s b/lib/libc/i386/string/memmove.s
new file mode 100644 (file)
index 0000000..6477069
--- /dev/null
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ *
+ * 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.
+ *
+ *     $Id: memmove.s,v 1.7 1993/08/16 17:06:34 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: memmove.s,v 1.7 1993/08/16 17:06:34 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+       /*
+        * (ov)bcopy (src,dst,cnt)
+        *  ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
+        */
+
+ENTRY(memmove)
+       pushl   %esi
+       pushl   %edi
+       movl    12(%esp),%edi
+       pushl   %edi
+       movl    20(%esp),%esi
+       movl    24(%esp),%ecx
+       cmpl    %esi,%edi       /* potentially overlapping? */
+       jnb     1f
+       cld                     /* nope, copy forwards. */
+       shrl    $2,%ecx         /* copy by words */
+       rep
+       movsl
+       movl    24(%esp),%ecx
+       andl    $3,%ecx         /* any bytes left? */
+       rep
+       movsb
+       popl    %eax
+       popl    %edi
+       popl    %esi
+       ret
+1:
+       addl    %ecx,%edi       /* copy backwards. */
+       addl    %ecx,%esi
+       std
+       andl    $3,%ecx         /* any fractional bytes? */
+       decl    %edi
+       decl    %esi
+       rep
+       movsb
+       movl    24(%esp),%ecx   /* copy remainder by words */
+       shrl    $2,%ecx
+       subl    $3,%esi
+       subl    $3,%edi
+       rep
+       movsl
+       popl    %eax
+       popl    %edi
+       popl    %esi
+       cld
+       ret
diff --git a/lib/libc/i386/string/memset.s b/lib/libc/i386/string/memset.s
new file mode 100644 (file)
index 0000000..9def702
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: memset.s,v 1.3 1993/08/16 17:06:35 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: memset.s,v 1.3 1993/08/16 17:06:35 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * memset(void *b, int c, size_t len)
+ *     write len bytes of value c (converted to an unsigned char) to 
+ *     the string b.
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+ENTRY(memset)
+       pushl   %edi
+       pushl   %ebx
+       movl    12(%esp),%edi
+       movzbl  16(%esp),%eax           /* unsigned char, zero extend */
+       movl    20(%esp),%ecx
+       pushl   %edi                    /* push address of buffer */
+
+       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.
+        */
+       cmpl    $0x0f,%ecx
+       jle     L1
+
+       movl    %eax,%edx               /* copy value to all bytes in word */
+       sall    $8,%edx                 /* XXX is there a better way? */
+       orl     %edx,%eax
+       movl    %eax,%edx
+       sall    $16,%edx
+       orl     %edx,%eax
+
+       movl    %edi,%edx               /* compute misalignment */
+       negl    %edx
+       andl    $3,%edx
+       movl    %ecx,%ebx
+       subl    %edx,%ebx
+       
+       movl    %edx,%ecx               /* set until word aligned */
+       rep
+       stosb
+
+       movl    %ebx,%ecx
+       shrl    $2,%ecx                 /* set by words */
+       rep
+       stosl
+
+       movl    %ebx,%ecx               /* set remainder by bytes */
+       andl    $3,%ecx
+L1:    rep
+       stosb
+
+       popl    %eax                    /* pop address of buffer */
+       popl    %ebx
+       popl    %edi
+       ret
diff --git a/lib/libc/i386/string/rindex.s b/lib/libc/i386/string/rindex.s
new file mode 100644 (file)
index 0000000..7646fbf
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: rindex.s,v 1.4 1993/08/16 17:06:36 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: rindex.s,v 1.4 1993/08/16 17:06:36 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * rindex(s, c)
+ *     return a pointer to the last occurance of the character c in
+ *     string s, or NULL if c does not occur in the string.
+ *
+ * %edx - pointer iterating through string
+ * %eax - pointer to last occurance of 'c'
+ * %cl  - character we're comparing against
+ * %bl  - character at %edx
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+ENTRY(rindex)
+       pushl   %ebx
+       movl    8(%esp),%edx
+       movb    12(%esp),%cl
+       xorl    %eax,%eax               /* init pointer to null */
+       .align 2,0x90
+L1:
+       movb    (%edx),%bl
+       cmpb    %bl,%cl
+       jne     L2
+       movl    %edx,%eax
+L2:    
+       incl    %edx
+       testb   %bl,%bl                 /* null terminator??? */
+       jne     L1
+       popl    %ebx
+       ret
diff --git a/lib/libc/i386/string/strcat.s b/lib/libc/i386/string/strcat.s
new file mode 100644 (file)
index 0000000..7966b3d
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: strcat.s,v 1.5 1993/08/16 17:06:37 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: strcat.s,v 1.5 1993/08/16 17:06:37 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * strcat(s, append)
+ *     append a copy of the null-terminated string "append" to the end
+ *     of the null-terminated string s, then add a terminating `\0'.
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+/*
+ * I've unrolled the loop eight times: large enough to make a
+ * significant difference, and small enough not to totally trash the
+ * cashe.
+ */
+
+ENTRY(strcat)
+       pushl   %edi                    /* save edi */
+       movl    8(%esp),%edi            /* dst address */
+       movl    12(%esp),%edx           /* src address */
+       pushl   %edi                    /* push destination address */
+
+       cld                             /* set search forward */
+       xorl    %eax,%eax               /* set search for null terminator */
+       movl    $-1,%ecx                /* set search for lots of characters */
+       repne                           /* search! */
+       scasb
+
+       leal    -1(%edi),%ecx           /* correct dst address */
+
+       .align 2,0x90
+L1:    movb    (%edx),%al              /* unroll loop, but not too much */
+       movb    %al,(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    1(%edx),%al
+       movb    %al,1(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    2(%edx),%al
+       movb    %al,2(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    3(%edx),%al
+       movb    %al,3(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    4(%edx),%al
+       movb    %al,4(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    5(%edx),%al
+       movb    %al,5(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    6(%edx),%al
+       movb    %al,6(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    7(%edx),%al
+       movb    %al,7(%ecx)
+       addl    $8,%edx
+       addl    $8,%ecx
+       testb   %al,%al
+       jne     L1
+L2:    popl    %eax                    /* pop destination address */
+       popl    %edi                    /* restore edi */
+       ret
diff --git a/lib/libc/i386/string/strchr.s b/lib/libc/i386/string/strchr.s
new file mode 100644 (file)
index 0000000..471e8b8
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: strchr.s,v 1.4 1993/08/16 17:06:38 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: strchr.s,v 1.4 1993/08/16 17:06:38 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * strchr(s, c)
+ *     return a pointer to the first occurance of the character c in
+ *     string s, or NULL if c does not occur in the string.
+ *
+ * %edx - pointer iterating through string
+ * %eax - pointer to first occurance of 'c'
+ * %cl  - character we're comparing against
+ * %bl  - character at %edx
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+ENTRY(strchr)
+       pushl   %ebx
+       movl    8(%esp),%eax
+       movb    12(%esp),%cl
+       .align 2,0x90
+L1:
+       movb    (%eax),%bl
+       cmpb    %bl,%cl                 /* found char??? */
+       je      L2
+       incl    %eax
+       testb   %bl,%bl                 /* null terminator??? */
+       jne     L1
+       xorl    %eax,%eax
+L2:
+       popl    %ebx
+       ret
diff --git a/lib/libc/i386/string/strcmp.s b/lib/libc/i386/string/strcmp.s
new file mode 100644 (file)
index 0000000..d79ab98
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: strcmp.s,v 1.4 1993/08/16 17:06:39 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: strcmp.s,v 1.4 1993/08/16 17:06:39 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * strcmp(s1, s2)
+ *     return an integer greater than, equal to, or less than 0, 
+ *     according as string s1 is greater than, equal to, or less
+ *     than the string s2.  
+ *
+ * %eax - pointer to s1
+ * %edx - pointer to s2
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+/*
+ * I've unrolled the loop eight times: large enough to make a
+ * significant difference, and small enough not to totally trash the
+ * cashe.
+ */
+
+ENTRY(strcmp)
+       movl    0x04(%esp),%eax 
+       movl    0x08(%esp),%edx 
+       jmp     L2                      /* Jump into the loop! */
+
+       .align  2,0x90
+L1:    incl    %eax
+       incl    %edx                    
+L2:    movb    (%eax),%cl
+       cmpb    $0,%cl
+       je      L3
+       cmpb    %cl,(%edx)
+       jne     L3
+       incl    %eax
+       incl    %edx
+       movb    (%eax),%cl
+       cmpb    $0,%cl
+       je      L3
+       cmpb    %cl,(%edx)
+       jne     L3
+       incl    %eax
+       incl    %edx
+       movb    (%eax),%cl
+       cmpb    $0,%cl
+       je      L3
+       cmpb    %cl,(%edx)
+       jne     L3
+       incl    %eax
+       incl    %edx
+       movb    (%eax),%cl
+       cmpb    $0,%cl
+       je      L3
+       cmpb    %cl,(%edx)
+       jne     L3
+       incl    %eax
+       incl    %edx
+       movb    (%eax),%cl
+       cmpb    $0,%cl
+       je      L3
+       cmpb    %cl,(%edx)
+       jne     L3
+       incl    %eax
+       incl    %edx
+       movb    (%eax),%cl
+       cmpb    $0,%cl
+       je      L3
+       cmpb    %cl,(%edx)
+       jne     L3
+       incl    %eax
+       incl    %edx
+       movb    (%eax),%cl
+       cmpb    $0,%cl
+       je      L3
+       cmpb    %cl,(%edx)
+       jne     L3
+       incl    %eax
+       incl    %edx
+       movb    (%eax),%cl
+       cmpb    $0,%cl
+       je      L3
+       cmpb    %cl,(%edx)
+       je      L1
+       .align 2, 0x90
+L3:    movsbl  (%eax),%eax             /* unsigned comparison */
+       movsbl  (%edx),%edx
+       subl    %edx,%eax
+       ret
diff --git a/lib/libc/i386/string/strcpy.s b/lib/libc/i386/string/strcpy.s
new file mode 100644 (file)
index 0000000..3bcc90e
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: strcpy.s,v 1.4 1993/08/16 17:06:40 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: strcpy.s,v 1.4 1993/08/16 17:06:40 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * strcpy (dst, src)
+ *     copy the string src to dst.
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+/*
+ * I've unrolled the loop eight times: large enough to make a
+ * significant difference, and small enough not to totally trash the
+ * cashe.
+ */
+
+ENTRY(strcpy)
+       movl    4(%esp),%ecx            /* dst address */
+       movl    8(%esp),%edx            /* src address */
+       pushl   %ecx                    /* push dst address */
+
+       .align 2,0x90
+L1:    movb    (%edx),%al              /* unroll loop, but not too much */
+       movb    %al,(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    1(%edx),%al
+       movb    %al,1(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    2(%edx),%al
+       movb    %al,2(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    3(%edx),%al
+       movb    %al,3(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    4(%edx),%al
+       movb    %al,4(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    5(%edx),%al
+       movb    %al,5(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    6(%edx),%al
+       movb    %al,6(%ecx)
+       testb   %al,%al
+       je      L2
+       movb    7(%edx),%al
+       movb    %al,7(%ecx)
+       addl    $8,%edx
+       addl    $8,%ecx
+       testb   %al,%al
+       jne     L1
+L2:    popl    %eax                    /* pop dst address */
+       ret
diff --git a/lib/libc/i386/string/strlen.s b/lib/libc/i386/string/strlen.s
new file mode 100644 (file)
index 0000000..b1a267a
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: strlen.s,v 1.3 1993/08/16 17:06:41 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: strlen.s,v 1.3 1993/08/16 17:06:41 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * strlen (s)
+ *     compute the length of the string s.
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+ENTRY(strlen)
+       pushl   %edi
+       movl    8(%esp),%edi            /* string address */
+       cld                             /* set search forward */
+       xorl    %eax,%eax               /* set search for null terminator */
+       movl    $-1,%ecx                /* set search for lots of characters */
+       repne                           /* search! */
+       scasb
+       movl    %ecx,%eax               /* get length by taking twos-   */
+       notl    %eax                    /* complement and subtracting   */
+       decl    %eax                    /* one */
+       popl    %edi
+       ret
diff --git a/lib/libc/i386/string/strncmp.s b/lib/libc/i386/string/strncmp.s
new file mode 100644 (file)
index 0000000..fc27050
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: strncmp.s,v 1.4 1993/08/16 17:06:42 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: strncmp.s,v 1.4 1993/08/16 17:06:42 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * strncmp(s1, s2, n) 
+ *     return an integer greater than, equal to, or less than 0, 
+ *     according as the first n characters of string s1 is greater
+ *     than, equal to, or less than the string s2.  
+ *
+ * %eax - pointer to s1
+ * %ecx - pointer to s2
+ * %edx - length
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+/*
+ * I've unrolled the loop eight times: large enough to make a
+ * significant difference, and small enough not to totally trash the
+ * cashe.
+ */
+
+ENTRY(strncmp)
+       pushl   %ebx
+       movl    8(%esp),%eax
+       movl    12(%esp),%ecx
+       movl    16(%esp),%edx
+       jmp     L2                      /* Jump into the loop! */
+
+       .align 2,0x90
+L1:    incl    %eax
+       incl    %ecx
+       decl    %edx
+L2:    testl   %edx,%edx               /* Have we compared n chars yet? */
+       jle     L4                      /* Yes, strings are equal */
+       movb    (%eax),%bl
+       cmpb    $0,%bl
+       je      L3
+       cmpb    %bl,(%ecx)
+       jne     L3
+       incl    %eax
+       incl    %ecx
+       decl    %edx
+       testl   %edx,%edx
+       jle     L4
+       movb    (%eax),%bl
+       cmpb    $0,%bl
+       je      L3
+       cmpb    %bl,(%ecx)
+       jne     L3
+       incl    %eax
+       incl    %ecx
+       decl    %edx
+       testl   %edx,%edx
+       jle     L4
+       movb    (%eax),%bl
+       cmpb    $0,%bl
+       je      L3
+       cmpb    %bl,(%ecx)
+       jne     L3
+       incl    %eax
+       incl    %ecx
+       decl    %edx
+       testl   %edx,%edx
+       jle     L4
+       movb    (%eax),%bl
+       cmpb    $0,%bl
+       je      L3
+       cmpb    %bl,(%ecx)
+       jne     L3
+       incl    %eax
+       incl    %ecx
+       decl    %edx
+       testl   %edx,%edx
+       jle     L4
+       movb    (%eax),%bl
+       cmpb    $0,%bl
+       je      L3
+       cmpb    %bl,(%ecx)
+       jne     L3
+       incl    %eax
+       incl    %ecx
+       decl    %edx
+       testl   %edx,%edx
+       jle     L4
+       movb    (%eax),%bl
+       cmpb    $0,%bl
+       je      L3
+       cmpb    %bl,(%ecx)
+       jne     L3
+       incl    %eax
+       incl    %ecx
+       decl    %edx
+       testl   %edx,%edx
+       jle     L4
+       movb    (%eax),%bl
+       cmpb    $0,%bl
+       je      L3
+       cmpb    %bl,(%ecx)
+       jne     L3
+       incl    %eax
+       incl    %ecx
+       decl    %edx
+       testl   %edx,%edx
+       jle     L4
+       movb    (%eax),%bl
+       cmpb    $0,%bl
+       je      L3
+       cmpb    %bl,(%ecx)
+       je      L1
+       .align 2,0x90
+L3:    movsbl  (%eax),%eax             /* unsigned comparision */
+       movsbl  (%ecx),%ecx
+       subl    %ecx,%eax
+       popl    %ebx
+       ret
+       .align 2,0x90
+L4:    xorl    %eax,%eax
+       popl    %ebx
+       ret
diff --git a/lib/libc/i386/string/strrchr.s b/lib/libc/i386/string/strrchr.s
new file mode 100644 (file)
index 0000000..bdb9c0e
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1993 Winning Strategies, Inc.
+ * 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 Winning Strategies, Inc.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software withough 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: strrchr.s,v 1.4 1993/08/16 17:06:43 jtc Exp $
+ */
+
+#if defined(LIBC_RCS) && !defined(lint)
+        .asciz "$Id: strrchr.s,v 1.4 1993/08/16 17:06:43 jtc Exp $"
+#endif /* LIBC_RCS and not lint */
+
+#include "DEFS.h"
+
+/*
+ * strrchr(s, c)
+ *     return a pointer to the last occurance of the character c in
+ *     string s, or NULL if c does not occur in the string.
+ *
+ * %edx - pointer iterating through string
+ * %eax - pointer to last occurance of 'c'
+ * %cl  - character we're comparing against
+ * %bl  - character at %edx
+ *
+ * Written by:
+ *     J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
+ */
+
+ENTRY(strrchr)
+       pushl   %ebx
+       movl    8(%esp),%edx
+       movb    12(%esp),%cl
+       xorl    %eax,%eax               /* init pointer to null */
+       .align 2,0x90
+L1:
+       movb    (%edx),%bl
+       cmpb    %bl,%cl
+       jne     L2
+       movl    %edx,%eax
+L2:    
+       incl    %edx
+       testb   %bl,%bl                 /* null terminator??? */
+       jne     L1
+       popl    %ebx
+       ret