bzero.S revision 144730
1144730Salc/*
2144730Salc * Written by J.T. Conklin <jtc@NetBSD.org>.
3144730Salc * Public domain.
4144730Salc * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
5144730Salc */
6144730Salc
7144730Salc#include <machine/asm.h>
8144730Salc__FBSDID("$FreeBSD: head/lib/libc/amd64/string/bzero.S 144730 2005-04-07 03:56:03Z alc $");
9144730Salc
10144730Salc#if 0
11144730Salc	RCSID("$NetBSD: bzero.S,v 1.2 2003/07/26 19:24:38 salo Exp $")
12144730Salc#endif
13144730Salc
14144730SalcENTRY(bzero)
15144730Salc	movq	%rsi,%rdx
16144730Salc
17144730Salc	cld				/* set fill direction forward */
18144730Salc	xorq	%rax,%rax		/* set fill data to 0 */
19144730Salc
20144730Salc	/*
21144730Salc	 * if the string is too short, it's really not worth the overhead
22144730Salc	 * of aligning to word boundries, etc.  So we jump to a plain
23144730Salc	 * unaligned set.
24144730Salc	 */
25144730Salc	cmpq	$16,%rdx
26144730Salc	jb	L1
27144730Salc
28144730Salc	movq	%rdi,%rcx		/* compute misalignment */
29144730Salc	negq	%rcx
30144730Salc	andq	$7,%rcx
31144730Salc	subq	%rcx,%rdx
32144730Salc	rep				/* zero until word aligned */
33144730Salc	stosb
34144730Salc
35144730Salc	movq	%rdx,%rcx		/* zero by words */
36144730Salc	shrq	$3,%rcx
37144730Salc	andq	$7,%rdx
38144730Salc	rep
39144730Salc	stosq
40144730Salc
41144730SalcL1:	movq	%rdx,%rcx		/* zero remainder by bytes */
42144730Salc	rep
43144730Salc	stosb
44144730Salc
45144730Salc	ret
46