scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

strcmp.s (378B)


      1 	.file "strcmp.s"
      2 
      3 	.text
      4 	.globl	strcmp,_strcmp
      5 _strcmp:
      6 strcmp:
      7 	movq	%rdi,%r8
      8 	movb	$0,%al
      9 	movq	$-1,%rcx
     10 	cld
     11 	repne
     12 	scasb
     13 
     14 	leaq	-1(%rdi),%rcx
     15 	subq	%r8,%rcx
     16 	movq	%r8,%rdi
     17 
     18 	xor	%rax,%rax	/* set ZF to 1 */
     19 
     20 	movq	%rdi,%r8
     21 	movq	%rsi,%rdi
     22 	movq	%r8,%rsi
     23 	rep
     24 	cmpsb
     25 	je	equa
     26 	jb	less
     27 	ja	grea
     28 
     29 grea:
     30 	movq	$1,%rax
     31 	ret
     32 
     33 less:
     34 	movq	$-1,%rax
     35 	ret
     36 
     37 equa:
     38 	movq	$0,%rax
     39 	ret