Deleted Added
full compact
bzero.S (144730) bzero.S (144733)
1/*
2 * Written by J.T. Conklin <jtc@NetBSD.org>.
3 * Public domain.
4 * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
5 */
6
7#include <machine/asm.h>
1/*
2 * Written by J.T. Conklin <jtc@NetBSD.org>.
3 * Public domain.
4 * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
5 */
6
7#include <machine/asm.h>
8__FBSDID("$FreeBSD: head/lib/libc/amd64/string/bzero.S 144730 2005-04-07 03:56:03Z alc $");
8__FBSDID("$FreeBSD: head/lib/libc/amd64/string/bzero.S 144733 2005-04-07 05:46:46Z alc $");
9
10#if 0
11 RCSID("$NetBSD: bzero.S,v 1.2 2003/07/26 19:24:38 salo Exp $")
12#endif
13
14ENTRY(bzero)
9
10#if 0
11 RCSID("$NetBSD: bzero.S,v 1.2 2003/07/26 19:24:38 salo Exp $")
12#endif
13
14ENTRY(bzero)
15 movq %rsi,%rdx
16
17 cld /* set fill direction forward */
18 xorq %rax,%rax /* set fill data to 0 */
19
20 /*
21 * if the string is too short, it's really not worth the overhead
22 * of aligning to word boundries, etc. So we jump to a plain
23 * unaligned set.
24 */
15 cld /* set fill direction forward */
16 xorq %rax,%rax /* set fill data to 0 */
17
18 /*
19 * if the string is too short, it's really not worth the overhead
20 * of aligning to word boundries, etc. So we jump to a plain
21 * unaligned set.
22 */
25 cmpq $16,%rdx
23 cmpq $16,%rsi
26 jb L1
27
28 movq %rdi,%rcx /* compute misalignment */
29 negq %rcx
30 andq $7,%rcx
24 jb L1
25
26 movq %rdi,%rcx /* compute misalignment */
27 negq %rcx
28 andq $7,%rcx
31 subq %rcx,%rdx
29 subq %rcx,%rsi
32 rep /* zero until word aligned */
33 stosb
34
30 rep /* zero until word aligned */
31 stosb
32
35 movq %rdx,%rcx /* zero by words */
33 movq %rsi,%rcx /* zero by words */
36 shrq $3,%rcx
34 shrq $3,%rcx
37 andq $7,%rdx
35 andq $7,%rsi
38 rep
39 stosq
40
36 rep
37 stosq
38
41L1: movq %rdx,%rcx /* zero remainder by bytes */
39L1: movq %rsi,%rcx /* zero remainder by bytes */
42 rep
43 stosb
44
45 ret
40 rep
41 stosb
42
43 ret