root/lib/libkern/arch/i386/strlen.S

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. strlen

    1 /*      $OpenBSD: strlen.S,v 1.2 1996/09/27 06:47:51 mickey Exp $       */
    2 
    3 /*
    4  * Written by J.T. Conklin <jtc@netbsd.org>.
    5  * Public domain.
    6  */
    7 
    8 #include <machine/asm.h>
    9 
   10 ENTRY(strlen)
   11         pushl   %edi
   12         movl    8(%esp),%edi            /* string address */
   13         cld                             /* set search forward */
   14         xorl    %eax,%eax               /* set search for null terminator */
   15         movl    $-1,%ecx                /* set search for lots of characters */
   16         repne                           /* search! */
   17         scasb
   18         notl    %ecx                    /* get length by taking complement */
   19         leal    -1(%ecx),%eax           /* and subtracting one */
   20         popl    %edi
   21         ret

/* [<][>][^][v][top][bottom][index][help] */