]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/i686/strcmp.S
0507bc4214b154d5743d95acb389b03ecb9040bf
[thirdparty/glibc.git] / sysdeps / i386 / i686 / strcmp.S
1 /* Highly optimized version for ix86, x>=6.
2 Copyright (C) 1999-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
5
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.
10
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.
15
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/>. */
19
20 #include <sysdep.h>
21 #include "asm-syntax.h"
22
23 #define PARMS 4 /* no space for saved regs */
24 #define STR1 PARMS
25 #define STR2 STR1+4
26
27 .text
28 ENTRY (strcmp)
29
30 movl STR1(%esp), %ecx
31 movl STR2(%esp), %edx
32
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)
40
41 xorl %eax, %eax
42 /* when strings are equal, pointers rest one beyond
43 the end of the NUL terminators. */
44 ret
45
46 L(neq): movl $1, %eax
47 movl $-1, %ecx
48 cmovbl %ecx, %eax
49
50 ret
51 END (strcmp)
52 libc_hidden_builtin_def (strcmp)