[BACK]Return to bzero.S CVS log [TXT][DIR] Up to [local] / sys / lib / libkern / arch / amd64

Annotation of sys/lib/libkern/arch/amd64/bzero.S, Revision 1.1.1.1

1.1       nbrk        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:
                      9: #if defined(LIBC_SCCS)
                     10:        RCSID("$NetBSD: bzero.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $")
                     11: #endif
                     12:
                     13: ENTRY(bzero)
                     14:        movq    %rsi,%rdx
                     15:
                     16:        cld                             /* set fill direction forward */
                     17:        xorq    %rax,%rax               /* set fill data to 0 */
                     18:
                     19:        /*
                     20:         * if the string is too short, it's really not worth the overhead
                     21:         * of aligning to word boundaries, etc.  So we jump to a plain
                     22:         * unaligned set.
                     23:         */
                     24:        cmpq    $16,%rdx
                     25:        jb      L1
                     26:
                     27:        movq    %rdi,%rcx               /* compute misalignment */
                     28:        negq    %rcx
                     29:        andq    $7,%rcx
                     30:        subq    %rcx,%rdx
                     31:        rep                             /* zero until word aligned */
                     32:        stosb
                     33:
                     34:        movq    %rdx,%rcx               /* zero by words */
                     35:        shrq    $3,%rcx
                     36:        andq    $7,%rdx
                     37:        rep
                     38:        stosq
                     39:
                     40: L1:    movq    %rdx,%rcx               /* zero remainder by bytes */
                     41:        rep
                     42:        stosb
                     43:
                     44:        ret

CVSweb