1993-10-07 03:17:24 +03:00
|
|
|
/*
|
1995-04-29 02:53:59 +04:00
|
|
|
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
|
|
* Public domain.
|
1993-10-07 03:17:24 +03:00
|
|
|
*/
|
|
|
|
|
1994-03-12 04:39:55 +03:00
|
|
|
#include <machine/asm.h>
|
|
|
|
|
1993-10-21 04:39:55 +03:00
|
|
|
#if defined(LIBC_SCCS)
|
1995-04-29 02:53:59 +04:00
|
|
|
RCSID("$Id: strcmp.S,v 1.10 1995/04/28 22:54:29 jtc Exp $")
|
1993-10-21 04:39:55 +03:00
|
|
|
#endif
|
1993-10-07 03:17:24 +03:00
|
|
|
|
|
|
|
/*
|
1995-04-29 02:53:59 +04:00
|
|
|
* NOTE: I've unrolled the loop eight times: large enough to make a
|
1993-10-07 03:17:24 +03:00
|
|
|
* significant difference, and small enough not to totally trash the
|
1994-02-14 20:45:16 +03:00
|
|
|
* cache.
|
1993-10-07 03:17:24 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
ENTRY(strcmp)
|
1993-10-21 04:48:14 +03:00
|
|
|
movl 0x04(%esp),%eax
|
|
|
|
movl 0x08(%esp),%edx
|
1993-10-07 03:17:24 +03:00
|
|
|
jmp L2 /* Jump into the loop! */
|
|
|
|
|
|
|
|
.align 2,0x90
|
|
|
|
L1: incl %eax
|
1993-10-21 04:48:14 +03:00
|
|
|
incl %edx
|
1993-10-07 03:17:24 +03:00
|
|
|
L2: movb (%eax),%cl
|
1993-10-08 04:25:51 +03:00
|
|
|
testb %cl,%cl /* null terminator??? */
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L3
|
1993-10-08 04:25:51 +03:00
|
|
|
cmpb %cl,(%edx) /* chars match??? */
|
1993-10-07 03:17:24 +03:00
|
|
|
jne L3
|
|
|
|
incl %eax
|
|
|
|
incl %edx
|
|
|
|
movb (%eax),%cl
|
1993-10-08 04:25:51 +03:00
|
|
|
testb %cl,%cl
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L3
|
1993-10-07 03:17:24 +03:00
|
|
|
cmpb %cl,(%edx)
|
|
|
|
jne L3
|
|
|
|
incl %eax
|
|
|
|
incl %edx
|
|
|
|
movb (%eax),%cl
|
1993-10-08 04:25:51 +03:00
|
|
|
testb %cl,%cl
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L3
|
1993-10-07 03:17:24 +03:00
|
|
|
cmpb %cl,(%edx)
|
|
|
|
jne L3
|
|
|
|
incl %eax
|
|
|
|
incl %edx
|
|
|
|
movb (%eax),%cl
|
1993-10-08 04:25:51 +03:00
|
|
|
testb %cl,%cl
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L3
|
1993-10-07 03:17:24 +03:00
|
|
|
cmpb %cl,(%edx)
|
|
|
|
jne L3
|
|
|
|
incl %eax
|
|
|
|
incl %edx
|
|
|
|
movb (%eax),%cl
|
1993-10-08 04:25:51 +03:00
|
|
|
testb %cl,%cl
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L3
|
1993-10-07 03:17:24 +03:00
|
|
|
cmpb %cl,(%edx)
|
|
|
|
jne L3
|
|
|
|
incl %eax
|
|
|
|
incl %edx
|
|
|
|
movb (%eax),%cl
|
1993-10-08 04:25:51 +03:00
|
|
|
testb %cl,%cl
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L3
|
1993-10-07 03:17:24 +03:00
|
|
|
cmpb %cl,(%edx)
|
|
|
|
jne L3
|
|
|
|
incl %eax
|
|
|
|
incl %edx
|
|
|
|
movb (%eax),%cl
|
1993-10-08 04:25:51 +03:00
|
|
|
testb %cl,%cl
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L3
|
1993-10-07 03:17:24 +03:00
|
|
|
cmpb %cl,(%edx)
|
|
|
|
jne L3
|
|
|
|
incl %eax
|
|
|
|
incl %edx
|
|
|
|
movb (%eax),%cl
|
1993-10-08 04:25:51 +03:00
|
|
|
testb %cl,%cl
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L3
|
1993-10-07 03:17:24 +03:00
|
|
|
cmpb %cl,(%edx)
|
|
|
|
je L1
|
|
|
|
.align 2, 0x90
|
1994-02-07 23:57:05 +03:00
|
|
|
L3: movzbl (%eax),%eax /* unsigned comparison */
|
|
|
|
movzbl (%edx),%edx
|
1993-10-07 03:17:24 +03:00
|
|
|
subl %edx,%eax
|
|
|
|
ret
|