Sync with libc, and add random.S.
This commit is contained in:
parent
0b15d23837
commit
799bd513de
|
@ -1,3 +1,3 @@
|
|||
/* $NetBSD: DEFS.h,v 1.2 1994/10/26 06:39:21 cgd Exp $ */
|
||||
/* $NetBSD: DEFS.h,v 1.3 1998/02/22 08:43:27 mycroft Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
# $NetBSD: Makefile.inc,v 1.16 1998/01/21 21:23:24 cgd Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.17 1998/02/22 08:43:27 mycroft Exp $
|
||||
|
||||
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.S bswap32.S bswap64.S memchr.c \
|
||||
bcmp.S bzero.S ffs.S strcat.S strcmp.S strcpy.S strlen.S strncmp.S \
|
||||
strncpy.S htonl.S htons.S ntohl.S ntohs.S scanc.S skpc.S \
|
||||
strncasecmp.c __assert.c
|
||||
SRCS+= __main.c __assert.c \
|
||||
imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.S bswap32.S bswap64.S \
|
||||
bcmp.S bzero.S ffs.S \
|
||||
memchr.c \
|
||||
strcat.S strcmp.S strcpy.S strlen.S strncmp.S strncasecmp.c strncpy.S \
|
||||
scanc.S skpc.S \
|
||||
htonl.S htons.S ntohl.S ntohs.S \
|
||||
random.S
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: SYS.h,v 1.2 1994/10/26 06:39:23 cgd Exp $ */
|
||||
/* $NetBSD: SYS.h,v 1.3 1998/02/22 08:43:27 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -36,44 +36,50 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)SYS.h 5.5 (Berkeley) 5/7/91
|
||||
* from: @(#)SYS.h 5.5 (Berkeley) 5/7/91
|
||||
*/
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
#ifdef __STDC__
|
||||
#define IMMEDIATE #
|
||||
#define SYSTRAP(x) movl IMMEDIATE SYS_ ## x ## ,d0; trap IMMEDIATE 0
|
||||
#else
|
||||
#define SYSTRAP(x) movl #SYS_/**/x,d0; trap #0
|
||||
#endif
|
||||
|
||||
#ifdef PIC
|
||||
/* With PIC code, we can't pass the error to cerror in d0,
|
||||
because the jump might go via the binder. */
|
||||
#define SYSCALL(x) .even; err: movl d0,sp@-; jra cerror; ENTRY(x); \
|
||||
movl \#SYS_ ## x,d0; trap \#0; jcs err
|
||||
#else /* !PIC */
|
||||
#define SYSCALL(x) .even; err: jra cerror; ENTRY(x); \
|
||||
movl \#SYS_ ## x,d0; trap \#0; jcs err
|
||||
#endif /* !PIC */
|
||||
|
||||
#define RSYSCALL(x) SYSCALL(x); rts
|
||||
#define PSEUDO(x,y) ENTRY(x); movl \#SYS_ ## y,d0; trap \#0; rts
|
||||
#define _SYSCALL_NOERROR(x,y) \
|
||||
ENTRY(x); \
|
||||
SYSTRAP(y)
|
||||
|
||||
#else /* !__STDC__ */
|
||||
#define _SYSCALL(x,y) \
|
||||
.even; \
|
||||
err: jra cerror; \
|
||||
_SYSCALL_NOERROR(x,y); \
|
||||
jcs err
|
||||
|
||||
#ifdef PIC
|
||||
/* With PIC code, we can't pass the error to cerror in d0,
|
||||
because the jump might go via the binder. */
|
||||
#define SYSCALL(x) .even; err: movl d0,sp@-; jra cerror; ENTRY(x); \
|
||||
movl #SYS_/**/x,d0; trap #0; jcs err
|
||||
#else /* !PIC */
|
||||
#define SYSCALL(x) .even; err: jra cerror; ENTRY(x); \
|
||||
movl #SYS_/**/x,d0; trap #0; jcs err
|
||||
#endif /* !PIC */
|
||||
#define SYSCALL_NOERROR(x) \
|
||||
_SYSCALL_NOERROR(x,x)
|
||||
|
||||
#define RSYSCALL(x) SYSCALL(x); rts
|
||||
#define PSEUDO(x,y) ENTRY(x); movl #SYS_/**/y,d0; trap #0; rts
|
||||
#define SYSCALL(x) \
|
||||
_SYSCALL(x,x)
|
||||
|
||||
#endif /* !__STDC__ */
|
||||
#define PSEUDO_NOERROR(x,y) \
|
||||
_SYSCALL_NOERROR(x,y); \
|
||||
rts
|
||||
|
||||
#define PSEUDO(x,y) \
|
||||
_SYSCALL(x,y); \
|
||||
rts
|
||||
|
||||
#define RSYSCALL_NOERROR(x) \
|
||||
PSEUDO_NOERROR(x,x)
|
||||
|
||||
#define RSYSCALL(x) \
|
||||
PSEUDO(x,x)
|
||||
|
||||
#define ASMSTR .asciz
|
||||
|
||||
.globl cerror
|
||||
|
|
|
@ -0,0 +1,237 @@
|
|||
/* $NetBSD: bcopy.S,v 1.1 1998/02/22 08:43:27 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by J.T. Conklin.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)bcopy.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: bcopy.S,v 1.1 1998/02/22 08:43:27 mycroft Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
||||
#ifdef MEMCOPY
|
||||
ENTRY(memcpy)
|
||||
#else
|
||||
#ifdef MEMMOVE
|
||||
ENTRY(memmove)
|
||||
#else
|
||||
ENTRY(bcopy)
|
||||
#endif
|
||||
#endif
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
movl sp@(4),a1 | dest address
|
||||
movl sp@(8),a0 | src address
|
||||
#else
|
||||
movl sp@(4),a0 | src address
|
||||
movl sp@(8),a1 | dest address
|
||||
#endif
|
||||
movl sp@(12),d1 | count
|
||||
|
||||
cmpl a1,a0 | src after dest?
|
||||
jlt Lbcback | yes, must copy backwards
|
||||
|
||||
/*
|
||||
* It isn't worth the overhead of aligning to {long}word boundries
|
||||
* if the string is too short.
|
||||
*/
|
||||
cmpl #8,d1
|
||||
jlt Lbcfbyte
|
||||
|
||||
/* word align */
|
||||
movl a1,d0
|
||||
btst #0,d0 | if (dst & 1)
|
||||
jeq Lbcfalgndw |
|
||||
movb a0@+,a1@+ | *(char *)dst++ = *(char *) src++
|
||||
subql #1,d1 | len--
|
||||
Lbcfalgndw:
|
||||
/* long word align */
|
||||
btst #1,d0 | if (dst & 2)
|
||||
jeq Lbcfalgndl
|
||||
movw a0@+,a1@+ | *(short *)dst++ = *(short *) dst++
|
||||
subql #2,d1 | len -= 2
|
||||
Lbcfalgndl:
|
||||
/* copy by 8 longwords */
|
||||
movel d1,d0
|
||||
lsrl #5,d0 | cnt = len / 32
|
||||
jeq Lbcflong | if (cnt)
|
||||
andl #31,d1 | len %= 32
|
||||
subql #1,d0 | set up for dbf
|
||||
Lbcf32loop:
|
||||
movl a0@+,a1@+ | copy 8 long words
|
||||
movl a0@+,a1@+
|
||||
movl a0@+,a1@+
|
||||
movl a0@+,a1@+
|
||||
movl a0@+,a1@+
|
||||
movl a0@+,a1@+
|
||||
movl a0@+,a1@+
|
||||
movl a0@+,a1@+
|
||||
dbf d0,Lbcf32loop | till done
|
||||
clrw d0
|
||||
subql #1,d0
|
||||
jcc Lbcf32loop
|
||||
|
||||
Lbcflong:
|
||||
/* copy by longwords */
|
||||
movel d1,d0
|
||||
lsrl #2,d0 | cnt = len / 4
|
||||
jeq Lbcfbyte | if (cnt)
|
||||
subql #1,d0 | set up for dbf
|
||||
Lbcflloop:
|
||||
movl a0@+,a1@+ | copy longwords
|
||||
dbf d0,Lbcflloop | til done
|
||||
andl #3,d1 | len %= 4
|
||||
jeq Lbcdone
|
||||
|
||||
subql #1,d1 | set up for dbf
|
||||
Lbcfbloop:
|
||||
movb a0@+,a1@+ | copy bytes
|
||||
Lbcfbyte:
|
||||
dbf d1,Lbcfbloop | till done
|
||||
Lbcdone:
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
movl sp@(4),d0 | dest address
|
||||
#endif
|
||||
rts
|
||||
|
||||
|
||||
Lbcback:
|
||||
addl d1,a0 | src pointer to end
|
||||
addl d1,a1 | dest pointer to end
|
||||
|
||||
/*
|
||||
* It isn't worth the overhead of aligning to {long}word boundries
|
||||
* if the string is too short.
|
||||
*/
|
||||
cmpl #8,d1
|
||||
jlt Lbcbbyte
|
||||
|
||||
/* word align */
|
||||
movl a1,d0
|
||||
btst #0,d0 | if (dst & 1)
|
||||
jeq Lbcbalgndw |
|
||||
movb a0@-,a1@- | *(char *)dst-- = *(char *) src--
|
||||
subql #1,d1 | len--
|
||||
Lbcbalgndw:
|
||||
/* long word align */
|
||||
btst #1,d0 | if (dst & 2)
|
||||
jeq Lbcbalgndl
|
||||
movw a0@-,a1@- | *(short *)dst-- = *(short *) dst--
|
||||
subql #2,d1 | len -= 2
|
||||
Lbcbalgndl:
|
||||
/* copy by 8 longwords */
|
||||
movel d1,d0
|
||||
lsrl #5,d0 | cnt = len / 32
|
||||
jeq Lbcblong | if (cnt)
|
||||
andl #31,d1 | len %= 32
|
||||
subql #1,d0 | set up for dbf
|
||||
Lbcb32loop:
|
||||
movl a0@-,a1@- | copy 8 long words
|
||||
movl a0@-,a1@-
|
||||
movl a0@-,a1@-
|
||||
movl a0@-,a1@-
|
||||
movl a0@-,a1@-
|
||||
movl a0@-,a1@-
|
||||
movl a0@-,a1@-
|
||||
movl a0@-,a1@-
|
||||
dbf d0,Lbcb32loop | till done
|
||||
clrw d0
|
||||
subql #1,d0
|
||||
jcc Lbcb32loop
|
||||
|
||||
Lbcblong:
|
||||
/* copy by longwords */
|
||||
movel d1,d0
|
||||
lsrl #2,d0 | cnt = len / 4
|
||||
jeq Lbcbbyte | if (cnt)
|
||||
subql #1,d0 | set up for dbf
|
||||
Lbcblloop:
|
||||
movl a0@-,a1@- | copy longwords
|
||||
dbf d0,Lbcblloop | til done
|
||||
andl #3,d1 | len %= 4
|
||||
jeq Lbcdone
|
||||
|
||||
subql #1,d1 | set up for dbf
|
||||
Lbcbbloop:
|
||||
movb a0@-,a1@- | copy bytes
|
||||
Lbcbbyte:
|
||||
dbf d1,Lbcbbloop | till done
|
||||
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
movl sp@(4),d0 | dest address
|
||||
#endif
|
||||
rts
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: htonl.S,v 1.2 1994/10/26 06:39:27 cgd Exp $ */
|
||||
/* $NetBSD: htonl.S,v 1.3 1998/02/22 08:43:27 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -37,18 +37,18 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
.text
|
||||
#ifdef notdef
|
||||
.asciz "@(#)htonl.s 5.1 (Berkeley) 5/12/90"
|
||||
#if 0
|
||||
RCSID("from: @(#)htonl.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: htonl.S,v 1.3 1998/02/22 08:43:27 mycroft Exp $")
|
||||
#endif
|
||||
.asciz "$NetBSD: htonl.S,v 1.2 1994/10/26 06:39:27 cgd Exp $"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* netorder = htonl(hostorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(htonl)
|
||||
movl sp@(4),d0
|
||||
rts
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: htons.S,v 1.2 1994/10/26 06:39:27 cgd Exp $ */
|
||||
/* $NetBSD: htons.S,v 1.3 1998/02/22 08:43:27 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -37,18 +37,18 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
.text
|
||||
#ifdef notdef
|
||||
.asciz "@(#)htons.s 5.1 (Berkeley) 5/12/90"
|
||||
#if 0
|
||||
RCSID("from: @(#)htons.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: htons.S,v 1.3 1998/02/22 08:43:27 mycroft Exp $")
|
||||
#endif
|
||||
.asciz "$NetBSD: htons.S,v 1.2 1994/10/26 06:39:27 cgd Exp $"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* hostorder = htons(netorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(htons)
|
||||
clrl d0
|
||||
movw sp@(6),d0
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/* $NetBSD: index.S,v 1.1 1998/02/22 08:43:27 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)index.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: index.S,v 1.1 1998/02/22 08:43:27 mycroft Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef STRCHR
|
||||
ENTRY(strchr)
|
||||
#else
|
||||
ENTRY(index)
|
||||
#endif
|
||||
movl sp@(4),a0 | string
|
||||
movb sp@(11),d0 | char to look for
|
||||
ixloop:
|
||||
cmpb a0@,d0 | found our char?
|
||||
jeq ixfound | yes, break out
|
||||
tstb a0@+ | null?
|
||||
jne ixloop | no, keep going
|
||||
moveq #0,d0 | not found, return null
|
||||
rts
|
||||
ixfound:
|
||||
movl a0,d0 | found, return pointer
|
||||
rts
|
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: memcpy.S,v 1.1 1998/02/22 08:43:27 mycroft Exp $ */
|
||||
|
||||
#define MEMCOPY
|
||||
#include "bcopy.S"
|
|
@ -0,0 +1,162 @@
|
|||
/* $NetBSD: memset.S,v 1.1 1998/02/22 08:43:27 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by J.T. Conklin.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)bzero.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: memset.S,v 1.1 1998/02/22 08:43:27 mycroft Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
ENTRY(memset)
|
||||
movl d2,sp@-
|
||||
movl sp@(8),a0 | destination
|
||||
movl sp@(16),d1 | count
|
||||
movb sp@(15),d2 | character
|
||||
|
||||
/*
|
||||
* It isn't worth the overhead of aligning to {long}word boundries
|
||||
* if the string is too short.
|
||||
*/
|
||||
cmpl #15,d1
|
||||
jlt Lbzbyte
|
||||
|
||||
clrl d0 | replicate byte to fill longword
|
||||
movb d2,d0
|
||||
movl d0,d2
|
||||
lsll #8,d0
|
||||
orl d0,d2
|
||||
lsll #8,d0
|
||||
orl d0,d2
|
||||
lsll #8,d0
|
||||
orl d0,d2
|
||||
|
||||
/* word align */
|
||||
movl a0,d0
|
||||
btst #0,d0 | if (dst & 1)
|
||||
jeq Lbzalgndw |
|
||||
movb d2,a0@+ | *(char *)dst++ = X
|
||||
subql #1,d1 | len--
|
||||
Lbzalgndw:
|
||||
/* long word align */
|
||||
btst #1,d0 | if (dst & 2)
|
||||
jeq Lbzalgndl |
|
||||
movw d2,a0@+ | *(short *)dst++ = X
|
||||
subql #2,d1 | len -= 2
|
||||
Lbzalgndl:
|
||||
/* set by 8 longwords */
|
||||
movel d1,d0
|
||||
lsrl #5,d0 | cnt = len / 32
|
||||
jeq Lbzlong | if (cnt)
|
||||
andl #31,d1 | len %= 32
|
||||
subql #1,d0 | set up for dbf
|
||||
Lbz32loop:
|
||||
movl d2,a0@+ | set 8 long words
|
||||
movl d2,a0@+
|
||||
movl d2,a0@+
|
||||
movl d2,a0@+
|
||||
movl d2,a0@+
|
||||
movl d2,a0@+
|
||||
movl d2,a0@+
|
||||
movl d2,a0@+
|
||||
dbf d0,Lbz32loop | till done
|
||||
clrw d0
|
||||
subql #1,d0
|
||||
jcc Lbz32loop
|
||||
|
||||
Lbzlong:
|
||||
/* set by longwords */
|
||||
movel d1,d0
|
||||
lsrl #2,d0 | cnt = len / 4
|
||||
jeq Lbzbyte | if (cnt)
|
||||
subql #1,d0 | set up for dbf
|
||||
Lbzlloop:
|
||||
movl d2,a0@+ | clear longwords
|
||||
dbf d0,Lbzlloop | till done
|
||||
andl #3,d1 | len %= 4
|
||||
jeq Lbzdone
|
||||
|
||||
subql #1,d1 | set up for dbf
|
||||
Lbzbloop:
|
||||
movb d2,a0@+ | set bytes
|
||||
Lbzbyte:
|
||||
dbf d1,Lbzbloop | till done
|
||||
Lbzdone:
|
||||
movl sp@(8),d0 | return destination
|
||||
movl sp@+,d2
|
||||
rts
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntohl.S,v 1.2 1994/10/26 06:39:29 cgd Exp $ */
|
||||
/* $NetBSD: ntohl.S,v 1.3 1998/02/22 08:43:27 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -37,18 +37,18 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
.text
|
||||
#ifdef notdef
|
||||
.asciz "@(#)ntohl.s 5.1 (Berkeley) 5/12/90"
|
||||
#if 0
|
||||
RCSID("from: @(#)ntohl.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: ntohl.S,v 1.3 1998/02/22 08:43:27 mycroft Exp $")
|
||||
#endif
|
||||
.asciz "$NetBSD: ntohl.S,v 1.2 1994/10/26 06:39:29 cgd Exp $"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* hostorder = ntohl(netorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(ntohl)
|
||||
movl sp@(4),d0
|
||||
rts
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntohs.S,v 1.2 1994/10/26 06:39:30 cgd Exp $ */
|
||||
/* $NetBSD: ntohs.S,v 1.3 1998/02/22 08:43:28 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -37,18 +37,18 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
.text
|
||||
#ifdef notdef
|
||||
.asciz "@(#)ntohs.s 5.1 (Berkeley) 5/12/90"
|
||||
#if 0
|
||||
RCSID("from: @(#)ntohs.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: ntohs.S,v 1.3 1998/02/22 08:43:28 mycroft Exp $")
|
||||
#endif
|
||||
.asciz "$NetBSD: ntohs.S,v 1.2 1994/10/26 06:39:30 cgd Exp $"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* hostorder = ntohs(netorder) */
|
||||
|
||||
#include "DEFS.h"
|
||||
|
||||
ENTRY(ntohs)
|
||||
clrl d0
|
||||
movw sp@(6),d0
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/* $NetBSD: random.S,v 1.1 1998/02/22 08:43:28 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990,1993 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Here is a very good random number generator. This implementation is
|
||||
* based on ``Two Fast Implementations of the "Minimal Standard" Random
|
||||
* Number Generator'', David G. Carta, Communications of the ACM, Jan 1990,
|
||||
* Vol 33 No 1. Do NOT modify this code unless you have a very thorough
|
||||
* understanding of the algorithm. It's trickier than you think. If
|
||||
* you do change it, make sure that its 10,000'th invocation returns
|
||||
* 1043618065.
|
||||
*
|
||||
* Here is easier-to-decipher pseudocode:
|
||||
*
|
||||
* p = (16807*seed)<30:0> # e.g., the low 31 bits of the product
|
||||
* q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32
|
||||
* if (p + q < 2^31)
|
||||
* seed = p + q
|
||||
* else
|
||||
* seed = ((p + q) & (2^31 - 1)) + 1
|
||||
* return (seed);
|
||||
*
|
||||
* The result is in (0,2^31), e.g., it's always positive.
|
||||
*/
|
||||
#include <machine/asm.h>
|
||||
|
||||
.data
|
||||
ASLOCAL(randseed)
|
||||
.long 1
|
||||
|
||||
ENTRY(random)
|
||||
movl #16807, d0
|
||||
mulsl _ASM_LABEL(randseed), d1:d0
|
||||
lsll #1, d0
|
||||
roxll #2, d1
|
||||
addl d1, d0
|
||||
moveql #1, d1
|
||||
addxl d1, d0
|
||||
lsrl #1, d0
|
||||
movl d0, _ASM_LABEL(randseed)
|
||||
rts
|
|
@ -0,0 +1,66 @@
|
|||
/* $NetBSD: rindex.S,v 1.1 1998/02/22 08:43:28 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. 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.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
RCSID("from: @(#)rindex.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: rindex.S,v 1.1 1998/02/22 08:43:28 mycroft Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef STRRCHR
|
||||
ENTRY(strrchr)
|
||||
#else
|
||||
ENTRY(rindex)
|
||||
#endif
|
||||
movl sp@(4),a0 | string
|
||||
movb sp@(11),d0 | char to look for
|
||||
subl a1,a1 | clear rindex pointer
|
||||
rixloop:
|
||||
cmpb a0@,d0 | found our char?
|
||||
jne rixnope | no, check for null
|
||||
movl a0,a1 | yes, remember location
|
||||
rixnope:
|
||||
tstb a0@+ | null?
|
||||
jne rixloop | no, keep going
|
||||
movl a1,d0 | return value
|
||||
rts
|
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: strchr.S,v 1.1 1998/02/22 08:43:28 mycroft Exp $ */
|
||||
|
||||
#define STRCHR
|
||||
#include "index.S"
|
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: strrchr.S,v 1.1 1998/02/22 08:43:28 mycroft Exp $ */
|
||||
|
||||
#define STRRCHR
|
||||
#include "rindex.S"
|
Loading…
Reference in New Issue