Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / i386 / i686 / strcmp.S
blob24ed78328f5bc72896f46db5bb61349fefb568e4
1 /* Highly optimized version for ix86, x>=6.
2    Copyright (C) 1999-2014 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <http://www.gnu.org/licenses/>.  */
20 #include <sysdep.h>
21 #include "asm-syntax.h"
23 #define PARMS   4               /* no space for saved regs */
24 #define STR1    PARMS
25 #define STR2    STR1+4
27         .text
28 ENTRY (strcmp)
30         movl    STR1(%esp), %ecx
31         movl    STR2(%esp), %edx
33 L(oop): movb    (%ecx), %al
34         cmpb    (%edx), %al
35         jne     L(neq)
36         incl    %ecx
37         incl    %edx
38         testb   %al, %al
39         jnz     L(oop)
41         xorl    %eax, %eax
42         /* when strings are equal, pointers rest one beyond
43            the end of the NUL terminators.  */
44         ret
46 L(neq): movl    $1, %eax
47         movl    $-1, %ecx
48         cmovbl  %ecx, %eax
50         ret
51 END (strcmp)
52 libc_hidden_builtin_def (strcmp)