Home | History | Annotate | Line # | Download | only in string
      1  1.1  scole /*	$NetBSD: bzero.S,v 1.1 2016/08/05 15:06:02 scole Exp $	*/
      2  1.1  scole 
      3  1.1  scole /*-
      4  1.1  scole  * Copyright (c) 2000 Doug Rabson
      5  1.1  scole  * All rights reserved.
      6  1.1  scole  *
      7  1.1  scole  * Redistribution and use in source and binary forms, with or without
      8  1.1  scole  * modification, are permitted provided that the following conditions
      9  1.1  scole  * are met:
     10  1.1  scole  * 1. Redistributions of source code must retain the above copyright
     11  1.1  scole  *    notice, this list of conditions and the following disclaimer.
     12  1.1  scole  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  scole  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  scole  *    documentation and/or other materials provided with the distribution.
     15  1.1  scole  *
     16  1.1  scole  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17  1.1  scole  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  1.1  scole  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.1  scole  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20  1.1  scole  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  1.1  scole  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  1.1  scole  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1  scole  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  1.1  scole  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1  scole  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1  scole  * SUCH DAMAGE.
     27  1.1  scole  *
     28  1.1  scole  * __FBSDID("$FreeBSD: releng/10.1/lib/libc/ia64/string/bzero.S 125669 2004-02-10 20:45:28Z cperciva $");
     29  1.1  scole  */
     30  1.1  scole 
     31  1.1  scole #include <machine/asm.h>
     32  1.1  scole 
     33  1.1  scole /*
     34  1.1  scole  * void
     35  1.1  scole  * bzero(void *b, size_t len);
     36  1.1  scole  */
     37  1.1  scole ENTRY(bzero, 2)
     38  1.1  scole 
     39  1.1  scole 	cmp.le	p6,p0=in1,r0			// bail if len <= 0
     40  1.1  scole (p6)	br.ret.spnt.few rp
     41  1.1  scole 	;;
     42  1.1  scole 	mov	r14=ar.lc			// save ar.lc
     43  1.1  scole 
     44  1.1  scole 	cmp.ltu	p6,p0=17,in1			// check for small
     45  1.1  scole (p6)	br.dptk.few 3f
     46  1.1  scole 
     47  1.1  scole 1:	add	r15=-1,in1 ;;
     48  1.1  scole 	mov	ar.lc=r15 ;;
     49  1.1  scole 2:	st1	[in0]=r0,1			// zero one byte
     50  1.1  scole 	br.cloop.sptk.few 2b			// loop
     51  1.1  scole 
     52  1.1  scole 	;;
     53  1.1  scole 	mov	ar.lc=r14			// done
     54  1.1  scole 	br.ret.sptk.few rp
     55  1.1  scole 
     56  1.1  scole 	// Zero up to 8byte alignment
     57  1.1  scole 
     58  1.1  scole 3:	tbit.nz	p6,p0=in0,0 ;;
     59  1.1  scole (p6)	st1	[in0]=r0,1
     60  1.1  scole (p6)	add	in1=-1,in1 ;;
     61  1.1  scole 
     62  1.1  scole 	tbit.nz	p6,p0=in0,1 ;;
     63  1.1  scole (p6)	st2	[in0]=r0,2
     64  1.1  scole (p6)	add	in1=-2,in1 ;;
     65  1.1  scole 
     66  1.1  scole 	tbit.nz	p6,p0=in0,2 ;;
     67  1.1  scole (p6)	st4	[in0]=r0,4
     68  1.1  scole (p6)	add	in1=-4,in1
     69  1.1  scole 
     70  1.1  scole 	;;
     71  1.1  scole 	shr.u	r15=in1,3			// word count
     72  1.1  scole 	extr.u	in1=in1,0,3 ;;			// trailing bytes
     73  1.1  scole 	cmp.eq	p6,p0=r15,r0			// check for zero
     74  1.1  scole 	cmp.ne	p7,p0=in1,r0
     75  1.1  scole (p6)	br.dpnt.few 1b				// zero last bytes
     76  1.1  scole 
     77  1.1  scole 	add	r15=-1,r15 ;;
     78  1.1  scole 	mov	ar.lc=r15 ;;
     79  1.1  scole 4:	st8	[in0]=r0,8
     80  1.1  scole 	br.cloop.sptk.few 4b
     81  1.1  scole 
     82  1.1  scole (p7)	br.dpnt.few 1b				// zero last bytes
     83  1.1  scole 
     84  1.1  scole 	;;
     85  1.1  scole 	mov	ar.lc=r14			// done
     86  1.1  scole 	br.ret.sptk.few rp
     87  1.1  scole 
     88  1.1  scole END(bzero)
     89