Home | History | Annotate | Download | only in string
      1 /*	$OpenBSD: strcmp.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
      2 /*
      3  * Written by J.T. Conklin <jtc (at) netbsd.org>.
      4  * Public domain.
      5  */
      6 
      7 #include <private/bionic_asm.h>
      8 
      9 /*
     10  * NOTE: I've unrolled the loop eight times: large enough to make a
     11  * significant difference, and small enough not to totally trash the
     12  * cache.
     13  */
     14 
     15 ENTRY(strcmp)
     16 	movl	0x04(%esp),%eax
     17 	movl	0x08(%esp),%edx
     18 	jmp	L2			/* Jump into the loop! */
     19 
     20 	.align	2,0x90
     21 L1:	incl	%eax
     22 	incl	%edx
     23 L2:	movb	(%eax),%cl
     24 	testb	%cl,%cl			/* null terminator??? */
     25 	jz	L3
     26 	cmpb	%cl,(%edx)		/* chars match??? */
     27 	jne	L3
     28 	incl	%eax
     29 	incl	%edx
     30 	movb	(%eax),%cl
     31 	testb	%cl,%cl
     32 	jz	L3
     33 	cmpb	%cl,(%edx)
     34 	jne	L3
     35 	incl	%eax
     36 	incl	%edx
     37 	movb	(%eax),%cl
     38 	testb	%cl,%cl
     39 	jz	L3
     40 	cmpb	%cl,(%edx)
     41 	jne	L3
     42 	incl	%eax
     43 	incl	%edx
     44 	movb	(%eax),%cl
     45 	testb	%cl,%cl
     46 	jz	L3
     47 	cmpb	%cl,(%edx)
     48 	jne	L3
     49 	incl	%eax
     50 	incl	%edx
     51 	movb	(%eax),%cl
     52 	testb	%cl,%cl
     53 	jz	L3
     54 	cmpb	%cl,(%edx)
     55 	jne	L3
     56 	incl	%eax
     57 	incl	%edx
     58 	movb	(%eax),%cl
     59 	testb	%cl,%cl
     60 	jz	L3
     61 	cmpb	%cl,(%edx)
     62 	jne	L3
     63 	incl	%eax
     64 	incl	%edx
     65 	movb	(%eax),%cl
     66 	testb	%cl,%cl
     67 	jz	L3
     68 	cmpb	%cl,(%edx)
     69 	jne	L3
     70 	incl	%eax
     71 	incl	%edx
     72 	movb	(%eax),%cl
     73 	testb	%cl,%cl
     74 	jz	L3
     75 	cmpb	%cl,(%edx)
     76 	je	L1
     77 	.align 2, 0x90
     78 L3:	movzbl	(%eax),%eax		/* unsigned comparison */
     79 	movzbl	(%edx),%edx
     80 	subl	%edx,%eax
     81 	ret
     82 END(strcmp)
     83