1 /* $NetBSD: bzero.S,v 1.1 2002/06/06 20:31:22 fredette Exp $ */
3 /* $OpenBSD: bzero.S,v 1.3 2001/06/04 23:14:02 mickey Exp $ */
6 * (c) Copyright 1988 HEWLETT-PACKARD COMPANY
8 * To anyone who acknowledges that this file is provided "AS IS"
9 * without any express or implied warranty:
10 * permission to use, copy, modify, and distribute this file
11 * for any purpose is hereby granted without fee, provided that
12 * the above copyright notice and this notice appears in all
13 * copies, and that the name of Hewlett-Packard Company not be
14 * used in advertising or publicity pertaining to distribution
15 * of the software without specific, written prior permission.
16 * Hewlett-Packard Company makes no representations about the
17 * suitability of this software for any purpose.
20 * Copyright (c) 1990,1994 The University of Utah and
21 * the Computer Systems Laboratory (CSL). All rights reserved.
23 * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS"
24 * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
25 * WHATSOEVER RESULTING FROM ITS USE.
27 * CSL requests users of this software to return to csl-dist@cs.utah.edu any
28 * improvements that they make and grant CSL redistribution rights.
30 * Utah $Hdr: bzero.s 1.9 94/12/14$
31 * Author: Bob Wheeler, University of Utah CSL
34 #include <machine/asm.h>
38 .asciz "$OpenBSD: bzero.S,v 1.3 2001/06/04 23:14:02 mickey Exp $"
49 comb,>=,n %r0,%arg1,$bzero_exit
52 * If we need to clear less than a word do it a byte at a time
55 comib,>>,n 4,%arg1,$bzero_bytes
58 * Since we are only clearing memory the alignment restrictions
59 * are simplified. Figure out how many "extra" bytes we need to
67 * We will zero the destination in blocks of 16 bytes as long as we
68 * can and then we'll go to the 4 byte moves.
71 comib,>>= 15, %arg1, $bzero_word
72 addi -16, %arg1, %arg1
75 stbys,b,m %r0,4(%arg0)
79 comib,<< 15, %arg1, $bzero_loop_16
80 addi -16, %arg1, %arg1
83 * see if there is anything left that needs to be zeroed in a word
84 * move. Since the count was decremented by 16, add 12 to test if
85 * there are any full word moves left to do.
89 addib,<,n 12,%arg1,$bzero_cleanup
92 addib,>= -4,%arg1,$bzero_loop_4
93 stbys,b,m %r0,4(%arg0)
96 * zero the last bytes that may be unaligned on a word boundary
100 addib,=,n 4,%arg1,$bzero_exit
101 add %arg0,%arg1,%arg0
112 addib,> -1,%arg1,$bzero_bytes