15b859c19Sderaadt/* 25b859c19Sderaadt * Written by J.T. Conklin <jtc@netbsd.org>. 35b859c19Sderaadt * Public domain. 45b859c19Sderaadt * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> 55b859c19Sderaadt */ 65b859c19Sderaadt 7b4551fdeSguenther#include "DEFS.h" 85b859c19Sderaadt 9*ec0f1ad6SguentherENTRY_NB(bzero) 10631951aaSmortimer RETGUARD_SETUP(bzero, r11) 115b859c19Sderaadt movq %rsi,%rdx 125b859c19Sderaadt 135b859c19Sderaadt cld /* set fill direction forward */ 145b859c19Sderaadt xorq %rax,%rax /* set fill data to 0 */ 155b859c19Sderaadt 165b859c19Sderaadt /* 175b859c19Sderaadt * if the string is too short, it's really not worth the overhead 185b859c19Sderaadt * of aligning to word boundaries, etc. So we jump to a plain 195b859c19Sderaadt * unaligned set. 205b859c19Sderaadt */ 215b859c19Sderaadt cmpq $16,%rdx 225b859c19Sderaadt jb L1 235b859c19Sderaadt 245b859c19Sderaadt movq %rdi,%rcx /* compute misalignment */ 255b859c19Sderaadt negq %rcx 265b859c19Sderaadt andq $7,%rcx 275b859c19Sderaadt subq %rcx,%rdx 285b859c19Sderaadt rep /* zero until word aligned */ 295b859c19Sderaadt stosb 305b859c19Sderaadt 315b859c19Sderaadt movq %rdx,%rcx /* zero by words */ 325b859c19Sderaadt shrq $3,%rcx 335b859c19Sderaadt andq $7,%rdx 345b859c19Sderaadt rep 355b859c19Sderaadt stosq 365b859c19Sderaadt 375b859c19SderaadtL1: movq %rdx,%rcx /* zero remainder by bytes */ 385b859c19Sderaadt rep 395b859c19Sderaadt stosb 405b859c19Sderaadt 41631951aaSmortimer RETGUARD_CHECK(bzero, r11) 425b859c19Sderaadt ret 439b9d2a55SguentherEND_WEAK(bzero) 44