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