bzero.S revision 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> 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) 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 */ 23 cmpq $16,%rsi 24 jb L1 25 26 movq %rdi,%rcx /* compute misalignment */ 27 negq %rcx 28 andq $7,%rcx 29 subq %rcx,%rsi 30 rep /* zero until word aligned */ 31 stosb 32 33 movq %rsi,%rcx /* zero by words */ 34 shrq $3,%rcx 35 andq $7,%rsi 36 rep 37 stosq 38 39L1: movq %rsi,%rcx /* zero remainder by bytes */ 40 rep 41 stosb 42 43 ret 44