blob: 76adafc20ab79ebaf3e2ec8afcc3fe8a127bc17d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
* Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
*/
#include <machine/asm.h>
ENTRY(bzero)
movq %rsi,%rdx
cld /* set fill direction forward */
xorq %rax,%rax /* set fill data to 0 */
/*
* if the string is too short, it's really not worth the overhead
* of aligning to word boundaries, etc. So we jump to a plain
* unaligned set.
*/
cmpq $16,%rdx
jb L1
movq %rdi,%rcx /* compute misalignment */
negq %rcx
andq $7,%rcx
subq %rcx,%rdx
rep /* zero until word aligned */
stosb
movq %rdx,%rcx /* zero by words */
shrq $3,%rcx
andq $7,%rdx
rep
stosq
L1: movq %rdx,%rcx /* zero remainder by bytes */
rep
stosb
ret
|