summaryrefslogtreecommitdiff
path: root/sys/lib/libkern/arch/i386/bcmp.S
diff options
context:
space:
mode:
Diffstat (limited to 'sys/lib/libkern/arch/i386/bcmp.S')
-rw-r--r--sys/lib/libkern/arch/i386/bcmp.S35
1 files changed, 35 insertions, 0 deletions
diff --git a/sys/lib/libkern/arch/i386/bcmp.S b/sys/lib/libkern/arch/i386/bcmp.S
new file mode 100644
index 00000000000..12d344216cc
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/bcmp.S
@@ -0,0 +1,35 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: bcmp.S,v 1.5 1995/10/07 09:27:01 mycroft Exp $")
+#endif
+
+ENTRY(bcmp)
+ pushl %edi
+ pushl %esi
+ movl 12(%esp),%edi
+ movl 16(%esp),%esi
+ xorl %eax,%eax /* clear return value */
+ cld /* set compare direction forward */
+
+ movl 20(%esp),%ecx /* compare by words */
+ shrl $2,%ecx
+ repe
+ cmpsl
+ jne L1
+
+ movl 20(%esp),%ecx /* compare remainder by bytes */
+ andl $3,%ecx
+ repe
+ cmpsb
+ je L2
+
+L1: incl %eax
+L2: popl %esi
+ popl %edi
+ ret