2010-03-03 15:27:30 +01:00
|
|
|
/* bcmp() Author: Kees J. Bot */
|
|
|
|
/* 2 Jan 1994 */
|
|
|
|
|
|
|
|
/* int bcmp(const void *s1, const void *s2, size_t n) */
|
|
|
|
/* Compare two chunks of memory. */
|
|
|
|
/* This is a BSD routine that escaped from the kernel. Don't use. */
|
|
|
|
/* (Alas it is not without some use, it reports the number of bytes */
|
|
|
|
/* after the bytes that are equal. So it can't be simply replaced.) */
|
|
|
|
/* */
|
2010-08-17 18:44:07 +02:00
|
|
|
#include <machine/asm.h>
|
|
|
|
|
|
|
|
ENTRY(bcmp)
|
2010-03-03 15:27:30 +01:00
|
|
|
push %ebp
|
|
|
|
movl %esp, %ebp
|
|
|
|
push 16(%ebp)
|
|
|
|
push 12(%ebp)
|
|
|
|
push 8(%ebp)
|
2010-08-17 18:44:07 +02:00
|
|
|
call _C_LABEL(memcmp) /* Let memcmp do the work */
|
2010-03-03 15:27:30 +01:00
|
|
|
testl %eax, %eax
|
|
|
|
je equal
|
|
|
|
subl 8(%ebp), %edx /* Memcmp was nice enough to leave "esi" in edx */
|
|
|
|
decl %edx /* Number of bytes that are equal */
|
|
|
|
movl 16(%ebp), %eax
|
|
|
|
subl %edx, %eax /* Number of bytes that are unequal */
|
|
|
|
equal:
|
|
|
|
leave
|
|
|
|
ret
|