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