change to use MACHINE_ARCH and update from libc
This commit is contained in:
parent
75fe89c2ef
commit
879130b794
71
sys/lib/libkern/arch/i386/bcmp.S
Normal file
71
sys/lib/libkern/arch/i386/bcmp.S
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.1 1993/12/04 03:05:16 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: bcmp.S,v 1.1 1993/12/04 03:05:16 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
/*
|
||||
* bcmp (void *b1, void *b2, size_t len)
|
||||
*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
|
||||
*/
|
||||
|
||||
ENTRY(bcmp)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
movl 12(%esp),%edi
|
||||
movl 16(%esp),%esi
|
||||
movl 20(%esp),%edx
|
||||
xorl %eax,%eax /* clear return value */
|
||||
cld /* set compare direction forward */
|
||||
|
||||
movl %edx,%ecx /* compare by words */
|
||||
shrl $2,%ecx
|
||||
repe
|
||||
cmpsl
|
||||
jne L1
|
||||
|
||||
movl %edx,%ecx /* compare remainder by bytes */
|
||||
andl $3,%ecx
|
||||
repe
|
||||
cmpsb
|
||||
je L2
|
||||
|
||||
L1: incl %eax
|
||||
L2: popl %esi
|
||||
popl %edi
|
||||
ret
|
87
sys/lib/libkern/arch/i386/bzero.S
Normal file
87
sys/lib/libkern/arch/i386/bzero.S
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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: bzero.S,v 1.1 1993/12/04 03:05:44 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: bzero.S,v 1.1 1993/12/04 03:05:44 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
/*
|
||||
* 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 %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
|
||||
|
||||
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
|
59
sys/lib/libkern/arch/i386/ffs.S
Normal file
59
sys/lib/libkern/arch/i386/ffs.S
Normal file
@ -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: ffs.S,v 1.1 1993/12/04 03:06:03 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: ffs.S,v 1.1 1993/12/04 03:06:03 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
54
sys/lib/libkern/arch/i386/htonl.S
Normal file
54
sys/lib/libkern/arch/i386/htonl.S
Normal file
@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*
|
||||
* from: @(#)htonl.s 5.3 (Berkeley) 12/17/90
|
||||
* $Id: htonl.S,v 1.1 1993/12/04 03:06:12 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: htonl.S,v 1.1 1993/12/04 03:06:12 cgd Exp $"
|
||||
#endif
|
||||
|
||||
/* netorder = htonl(hostorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(htonl)
|
||||
movl 4(%esp),%eax
|
||||
xchgb %al,%ah
|
||||
roll $16,%eax
|
||||
xchgb %al,%ah
|
||||
ret
|
52
sys/lib/libkern/arch/i386/htons.S
Normal file
52
sys/lib/libkern/arch/i386/htons.S
Normal file
@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*
|
||||
* from: @(#)htons.s 5.2 (Berkeley) 12/17/90
|
||||
* $Id: htons.S,v 1.1 1993/12/04 03:06:22 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: htons.S,v 1.1 1993/12/04 03:06:22 cgd Exp $"
|
||||
#endif
|
||||
|
||||
/* netorder = htons(hostorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(htons)
|
||||
movzwl 4(%esp),%eax
|
||||
xchgb %al,%ah
|
||||
ret
|
54
sys/lib/libkern/arch/i386/ntohl.S
Normal file
54
sys/lib/libkern/arch/i386/ntohl.S
Normal file
@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*
|
||||
* from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90
|
||||
* $Id: ntohl.S,v 1.1 1993/12/04 03:06:32 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: ntohl.S,v 1.1 1993/12/04 03:06:32 cgd Exp $"
|
||||
#endif
|
||||
|
||||
/* hostorder = ntohl(netorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(ntohl)
|
||||
movl 4(%esp),%eax
|
||||
xchgb %al,%ah
|
||||
roll $16,%eax
|
||||
xchgb %al,%ah
|
||||
ret
|
52
sys/lib/libkern/arch/i386/ntohs.S
Normal file
52
sys/lib/libkern/arch/i386/ntohs.S
Normal file
@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*
|
||||
* from: @(#)ntohs.s 5.2 (Berkeley) 12/17/90
|
||||
* $Id: ntohs.S,v 1.1 1993/12/04 03:06:42 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: ntohs.S,v 1.1 1993/12/04 03:06:42 cgd Exp $"
|
||||
#endif
|
||||
|
||||
/* hostorder = ntohs(netorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(ntohs)
|
||||
movzwl 4(%esp),%eax
|
||||
xchgb %al,%ah
|
||||
ret
|
106
sys/lib/libkern/arch/i386/strcat.S
Normal file
106
sys/lib/libkern/arch/i386/strcat.S
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.1 1993/12/04 03:06:53 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: strcat.S,v 1.1 1993/12/04 03:06:53 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
125
sys/lib/libkern/arch/i386/strcmp.S
Normal file
125
sys/lib/libkern/arch/i386/strcmp.S
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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.1 1993/12/04 03:07:07 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: strcmp.S,v 1.1 1993/12/04 03:07:07 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
||||
testb %cl,%cl /* null terminator??? */
|
||||
je L3
|
||||
cmpb %cl,(%edx) /* chars match??? */
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
je L1
|
||||
.align 2, 0x90
|
||||
L3: movsbl (%eax),%eax /* unsigned comparison */
|
||||
movsbl (%edx),%edx
|
||||
subl %edx,%eax
|
||||
ret
|
95
sys/lib/libkern/arch/i386/strcpy.S
Normal file
95
sys/lib/libkern/arch/i386/strcpy.S
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.1 1993/12/04 03:07:21 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: strcpy.S,v 1.1 1993/12/04 03:07:21 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
59
sys/lib/libkern/arch/i386/strlen.S
Normal file
59
sys/lib/libkern/arch/i386/strlen.S
Normal file
@ -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.1 1993/12/04 03:07:39 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: strlen.S,v 1.1 1993/12/04 03:07:39 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
||||
notl %ecx /* get length by taking complement */
|
||||
leal -1(%ecx),%eax /* and subtracting one */
|
||||
popl %edi
|
||||
ret
|
71
sys/lib/libkern/i386/bcmp.S
Normal file
71
sys/lib/libkern/i386/bcmp.S
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.1 1993/12/04 03:05:16 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: bcmp.S,v 1.1 1993/12/04 03:05:16 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
/*
|
||||
* bcmp (void *b1, void *b2, size_t len)
|
||||
*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
|
||||
*/
|
||||
|
||||
ENTRY(bcmp)
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
movl 12(%esp),%edi
|
||||
movl 16(%esp),%esi
|
||||
movl 20(%esp),%edx
|
||||
xorl %eax,%eax /* clear return value */
|
||||
cld /* set compare direction forward */
|
||||
|
||||
movl %edx,%ecx /* compare by words */
|
||||
shrl $2,%ecx
|
||||
repe
|
||||
cmpsl
|
||||
jne L1
|
||||
|
||||
movl %edx,%ecx /* compare remainder by bytes */
|
||||
andl $3,%ecx
|
||||
repe
|
||||
cmpsb
|
||||
je L2
|
||||
|
||||
L1: incl %eax
|
||||
L2: popl %esi
|
||||
popl %edi
|
||||
ret
|
87
sys/lib/libkern/i386/bzero.S
Normal file
87
sys/lib/libkern/i386/bzero.S
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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: bzero.S,v 1.1 1993/12/04 03:05:44 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: bzero.S,v 1.1 1993/12/04 03:05:44 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
/*
|
||||
* 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 %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
|
||||
|
||||
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
|
59
sys/lib/libkern/i386/ffs.S
Normal file
59
sys/lib/libkern/i386/ffs.S
Normal file
@ -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: ffs.S,v 1.1 1993/12/04 03:06:03 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: ffs.S,v 1.1 1993/12/04 03:06:03 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
54
sys/lib/libkern/i386/htonl.S
Normal file
54
sys/lib/libkern/i386/htonl.S
Normal file
@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*
|
||||
* from: @(#)htonl.s 5.3 (Berkeley) 12/17/90
|
||||
* $Id: htonl.S,v 1.1 1993/12/04 03:06:12 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: htonl.S,v 1.1 1993/12/04 03:06:12 cgd Exp $"
|
||||
#endif
|
||||
|
||||
/* netorder = htonl(hostorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(htonl)
|
||||
movl 4(%esp),%eax
|
||||
xchgb %al,%ah
|
||||
roll $16,%eax
|
||||
xchgb %al,%ah
|
||||
ret
|
52
sys/lib/libkern/i386/htons.S
Normal file
52
sys/lib/libkern/i386/htons.S
Normal file
@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*
|
||||
* from: @(#)htons.s 5.2 (Berkeley) 12/17/90
|
||||
* $Id: htons.S,v 1.1 1993/12/04 03:06:22 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: htons.S,v 1.1 1993/12/04 03:06:22 cgd Exp $"
|
||||
#endif
|
||||
|
||||
/* netorder = htons(hostorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(htons)
|
||||
movzwl 4(%esp),%eax
|
||||
xchgb %al,%ah
|
||||
ret
|
54
sys/lib/libkern/i386/ntohl.S
Normal file
54
sys/lib/libkern/i386/ntohl.S
Normal file
@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*
|
||||
* from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90
|
||||
* $Id: ntohl.S,v 1.1 1993/12/04 03:06:32 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: ntohl.S,v 1.1 1993/12/04 03:06:32 cgd Exp $"
|
||||
#endif
|
||||
|
||||
/* hostorder = ntohl(netorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(ntohl)
|
||||
movl 4(%esp),%eax
|
||||
xchgb %al,%ah
|
||||
roll $16,%eax
|
||||
xchgb %al,%ah
|
||||
ret
|
52
sys/lib/libkern/i386/ntohs.S
Normal file
52
sys/lib/libkern/i386/ntohs.S
Normal file
@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*
|
||||
* from: @(#)ntohs.s 5.2 (Berkeley) 12/17/90
|
||||
* $Id: ntohs.S,v 1.1 1993/12/04 03:06:42 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: ntohs.S,v 1.1 1993/12/04 03:06:42 cgd Exp $"
|
||||
#endif
|
||||
|
||||
/* hostorder = ntohs(netorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(ntohs)
|
||||
movzwl 4(%esp),%eax
|
||||
xchgb %al,%ah
|
||||
ret
|
106
sys/lib/libkern/i386/strcat.S
Normal file
106
sys/lib/libkern/i386/strcat.S
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.1 1993/12/04 03:06:53 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: strcat.S,v 1.1 1993/12/04 03:06:53 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
125
sys/lib/libkern/i386/strcmp.S
Normal file
125
sys/lib/libkern/i386/strcmp.S
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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.1 1993/12/04 03:07:07 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: strcmp.S,v 1.1 1993/12/04 03:07:07 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
||||
testb %cl,%cl /* null terminator??? */
|
||||
je L3
|
||||
cmpb %cl,(%edx) /* chars match??? */
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
jne L3
|
||||
incl %eax
|
||||
incl %edx
|
||||
movb (%eax),%cl
|
||||
testb %cl,%cl
|
||||
je L3
|
||||
cmpb %cl,(%edx)
|
||||
je L1
|
||||
.align 2, 0x90
|
||||
L3: movsbl (%eax),%eax /* unsigned comparison */
|
||||
movsbl (%edx),%edx
|
||||
subl %edx,%eax
|
||||
ret
|
95
sys/lib/libkern/i386/strcpy.S
Normal file
95
sys/lib/libkern/i386/strcpy.S
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.1 1993/12/04 03:07:21 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: strcpy.S,v 1.1 1993/12/04 03:07:21 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
59
sys/lib/libkern/i386/strlen.S
Normal file
59
sys/lib/libkern/i386/strlen.S
Normal file
@ -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.1 1993/12/04 03:07:39 cgd Exp $
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS)
|
||||
.text
|
||||
.asciz "$Id: strlen.S,v 1.1 1993/12/04 03:07:39 cgd Exp $"
|
||||
#endif
|
||||
|
||||
#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
|
||||
notl %ecx /* get length by taking complement */
|
||||
leal -1(%ecx),%eax /* and subtracting one */
|
||||
popl %edi
|
||||
ret
|
Loading…
x
Reference in New Issue
Block a user