1 /* $NetBSD: bzero.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
4 * Copyright (c) 1995 Carnegie-Mellon University.
7 * Author: Trevor Blackwell
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 * Carnegie Mellon requests users of this software to return to
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
30 #include <machine/asm.h>
34 bic a1,63,t3 /* t3 is # bytes to do 64 bytes at a time */
36 /* If nothing in first word, ignore it */
38 and t0,7,t0 /* t0 = (0-size)%8 */
41 cmpult a1,t0,t1 /* if size > size%8 goto noshort */
45 * The whole thing is less than a word.
46 * Mask off 1..7 bytes, and finish.
49 lda t0,-1(zero) /* t0=-1 */
50 mskql t0,a1,t0 /* Get ff in bytes (a0%8)..((a0+a1-1)%8) */
52 bic t2,t0,t2 /* zero those bytes in word */
57 /* Handle the first partial word */
60 mskql t2,a0,t2 /* zero bytes (a0%8)..7 in word */
63 addq a0,t0,a0 /* round a0 up to next word */
64 bic a1,63,t3 /* recalc t3 (# bytes to do 64 bytes at a
69 * Loop, zeroing 64 bytes at a time
87 * Handle the last 0..7 words.
88 * We mask off the low bits, so we don't need an extra
89 * compare instruction for the loop (just a bne. heh-heh)
92 beq t4,bzero_finish_lp_done
97 bne t4,bzero_finish_lp
99 /* Do the last partial word */
100 bzero_finish_lp_done:
101 and a1,7,t5 /* 0..7 bytes left */
102 beq t5,bzero_done /* mskqh won't change t0 if t5==0, but I
103 don't want to touch, say, a new VM page */