2005-04-07 03:56:03 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
RCSID("$NetBSD: bzero.S,v 1.2 2003/07/26 19:24:38 salo Exp $")
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ENTRY(bzero)
|
|
|
|
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 boundries, etc. So we jump to a plain
|
|
|
|
* unaligned set.
|
|
|
|
*/
|
2005-04-07 05:46:46 +00:00
|
|
|
cmpq $16,%rsi
|
2005-04-07 03:56:03 +00:00
|
|
|
jb L1
|
|
|
|
|
|
|
|
movq %rdi,%rcx /* compute misalignment */
|
|
|
|
negq %rcx
|
|
|
|
andq $7,%rcx
|
2005-04-07 05:46:46 +00:00
|
|
|
subq %rcx,%rsi
|
2005-04-07 03:56:03 +00:00
|
|
|
rep /* zero until word aligned */
|
|
|
|
stosb
|
|
|
|
|
2005-04-07 05:46:46 +00:00
|
|
|
movq %rsi,%rcx /* zero by words */
|
2005-04-07 03:56:03 +00:00
|
|
|
shrq $3,%rcx
|
2005-04-07 05:46:46 +00:00
|
|
|
andq $7,%rsi
|
2005-04-07 03:56:03 +00:00
|
|
|
rep
|
|
|
|
stosq
|
|
|
|
|
2005-04-07 05:46:46 +00:00
|
|
|
L1: movq %rsi,%rcx /* zero remainder by bytes */
|
2005-04-07 03:56:03 +00:00
|
|
|
rep
|
|
|
|
stosb
|
|
|
|
|
|
|
|
ret
|
2008-11-02 01:10:54 +00:00
|
|
|
END(bzero)
|
2011-01-07 16:08:40 +00:00
|
|
|
|
|
|
|
.section .note.GNU-stack,"",%progbits
|