/*1* Copyright (c) 1993 Winning Strategies, Inc.2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. All advertising materials mentioning features or use of this software13* must display the following acknowledgement:14* This product includes software developed by Winning Strategies, Inc.15* 4. The name of the author may not be used to endorse or promote products16* derived from this software without specific prior written permission17*18* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR19* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES20* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.21* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,22* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT23* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF27* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28*/2930#include <machine/asm.h>31/*32* memcmp (void *b1, void *b2, size_t len)33*34* Written by:35* J.T. Conklin ([email protected]), Winning Strategies, Inc.36*/3738ENTRY(memcmp)39pushl %edi40pushl %esi41movl 12(%esp),%edi42movl 16(%esp),%esi43cld /* set compare direction forward */4445movl 20(%esp),%ecx /* compare by words */46shrl $2,%ecx47repe48cmpsl49jne L5 /* do we match so far? */5051movl 20(%esp),%ecx /* compare remainder by bytes */52andl $3,%ecx53repe54cmpsb55jne L6 /* do we match? */5657xorl %eax,%eax /* we match, return zero */58popl %esi59popl %edi60ret6162L5: movl $4,%ecx /* We know that one of the next */63subl %ecx,%edi /* four pairs of bytes do not */64subl %ecx,%esi /* match. */65repe66cmpsb67L6: movzbl -1(%edi),%eax /* Perform unsigned comparison */68movzbl -1(%esi),%edx69subl %edx,%eax70popl %esi71popl %edi72ret73END(memcmp)7475.section .note.GNU-stack,"",%progbits767778