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

Annotation of sys/lib/libkern/arch/amd64/memset.S, Revision 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: memset.S,v 1.1 2001/06/19 00:22:46 fvdl Exp $")
        !            11: #endif
        !            12:
        !            13: ENTRY(memset)
        !            14:        movq    %rsi,%rax
        !            15:        movq    %rdx,%rcx
        !            16:        movq    %rdi,%r11
        !            17:
        !            18:        cld                             /* set fill direction forward */
        !            19:
        !            20:        /*
        !            21:         * if the string is too short, it's really not worth the overhead
        !            22:         * of aligning to word boundaries, etc.  So we jump to a plain
        !            23:         * unaligned set.
        !            24:         */
        !            25:        cmpq    $0x0f,%rcx
        !            26:        jle     L1
        !            27:
        !            28:        movb    %al,%ah                 /* copy char to all bytes in word */
        !            29:        movl    %eax,%edx
        !            30:        sall    $16,%eax
        !            31:        orl     %edx,%eax
        !            32:
        !            33:        movl    %eax,%edx
        !            34:        salq    $32,%rax
        !            35:        orq     %rdx,%rax
        !            36:
        !            37:        movq    %rdi,%rdx               /* compute misalignment */
        !            38:        negq    %rdx
        !            39:        andq    $7,%rdx
        !            40:        movq    %rcx,%r8
        !            41:        subq    %rdx,%r8
        !            42:
        !            43:        movq    %rdx,%rcx               /* set until word aligned */
        !            44:        rep
        !            45:        stosb
        !            46:
        !            47:        movq    %r8,%rcx
        !            48:        shrq    $3,%rcx                 /* set by words */
        !            49:        rep
        !            50:        stosq
        !            51:
        !            52:        movq    %r8,%rcx                /* set remainder by bytes */
        !            53:        andq    $7,%rcx
        !            54: L1:    rep
        !            55:        stosb
        !            56:        movq    %r11,%rax
        !            57:
        !            58:        ret

CVSweb