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

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

DEFINITIONS

This source file includes following definitions.
  1. strcmp

    1 /*      $OpenBSD: strcmp.S,v 1.2 1996/09/27 06:47:49 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 /*
   11  * NOTE: I've unrolled the loop eight times: large enough to make a
   12  * significant difference, and small enough not to totally trash the
   13  * cache.
   14  */
   15 
   16 ENTRY(strcmp)
   17         movl    0x04(%esp),%eax
   18         movl    0x08(%esp),%edx
   19         jmp     L2                      /* Jump into the loop! */
   20 
   21         .align  2,0x90
   22 L1:     incl    %eax
   23         incl    %edx
   24 L2:     movb    (%eax),%cl
   25         testb   %cl,%cl                 /* null terminator??? */
   26         jz      L3
   27         cmpb    %cl,(%edx)              /* chars match??? */
   28         jne     L3
   29         incl    %eax
   30         incl    %edx
   31         movb    (%eax),%cl
   32         testb   %cl,%cl
   33         jz      L3
   34         cmpb    %cl,(%edx)
   35         jne     L3
   36         incl    %eax
   37         incl    %edx
   38         movb    (%eax),%cl
   39         testb   %cl,%cl
   40         jz      L3
   41         cmpb    %cl,(%edx)
   42         jne     L3
   43         incl    %eax
   44         incl    %edx
   45         movb    (%eax),%cl
   46         testb   %cl,%cl
   47         jz      L3
   48         cmpb    %cl,(%edx)
   49         jne     L3
   50         incl    %eax
   51         incl    %edx
   52         movb    (%eax),%cl
   53         testb   %cl,%cl
   54         jz      L3
   55         cmpb    %cl,(%edx)
   56         jne     L3
   57         incl    %eax
   58         incl    %edx
   59         movb    (%eax),%cl
   60         testb   %cl,%cl
   61         jz      L3
   62         cmpb    %cl,(%edx)
   63         jne     L3
   64         incl    %eax
   65         incl    %edx
   66         movb    (%eax),%cl
   67         testb   %cl,%cl
   68         jz      L3
   69         cmpb    %cl,(%edx)
   70         jne     L3
   71         incl    %eax
   72         incl    %edx
   73         movb    (%eax),%cl
   74         testb   %cl,%cl
   75         jz      L3
   76         cmpb    %cl,(%edx)
   77         je      L1
   78         .align 2, 0x90
   79 L3:     movzbl  (%eax),%eax             /* unsigned comparison */
   80         movzbl  (%edx),%edx
   81         subl    %edx,%eax
   82         ret

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