strcmp.c /* strcmp: return <0 if s0 if s>t */ int strcmp(char *s, char *t) { for (; *s == *t ; s++, t++) if (*s == '\0') return 0; return *s - *t; } strcmp.s (gcc-3.3.3) .file "strcmp.c" .text .globl strcmp .type strcmp, @function strcmp: pushl %ebp movl %esp, %ebp subl $4, %esp nop .L2: movl 8(%ebp), %eax movl 12(%ebp), %edx movb (%eax), %al cmpb (%edx), %al je .L5 jmp .L3 .L5: movl 8(%ebp), %eax cmpb $0, (%eax) jne .L4 movl $0, -4(%ebp) jmp .L1 .L4: incl 8(%ebp) leal 12(%ebp), %eax incl (%eax) jmp .L2 .L3: movl 8(%ebp), %eax movsbl (%eax),%eax movl 12(%ebp), %edx movsbl (%edx),%edx subl %edx, %eax movl %eax, -4(%ebp) .L1: movl -4(%ebp), %eax leave ret .size strcmp, .-strcmp .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)" strcmp.s (gcc-4.4.5) .file "strcmp.c" .text .globl strcmp .type strcmp, @function strcmp: pushl %ebp movl %esp, %ebp jmp .L2 .L5: movl 8(%ebp), %eax movzbl (%eax), %eax testb %al, %al jne .L3 movl $0, %eax jmp .L4 .L3: addl $1, 8(%ebp) addl $1, 12(%ebp) .L2: movl 8(%ebp), %eax movzbl (%eax), %edx movl 12(%ebp), %eax movzbl (%eax), %eax cmpb %al, %dl je .L5 movl 8(%ebp), %eax movzbl (%eax), %eax movsbl %al,%edx movl 12(%ebp), %eax movzbl (%eax), %eax movsbl %al,%eax movl %edx, %ecx subl %eax, %ecx movl %ecx, %eax .L4: popl %ebp ret .size strcmp, .-strcmp .ident "GCC: (Debian 4.4.5-8) 4.4.5" .section .note.GNU-stack,"",@progbits