summaryrefslogtreecommitdiffstats
path: root/lib/libc/arch/i386/string/index.S
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/arch/i386/string/index.S')
-rw-r--r--lib/libc/arch/i386/string/index.S31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/libc/arch/i386/string/index.S b/lib/libc/arch/i386/string/index.S
new file mode 100644
index 00000000000..01f80b6f0d8
--- /dev/null
+++ b/lib/libc/arch/i386/string/index.S
@@ -0,0 +1,31 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: index.S,v 1.8 1995/04/28 22:58:01 jtc Exp $")
+#endif
+
+#ifdef STRCHR
+ENTRY(strchr)
+#else
+ENTRY(index)
+#endif
+ pushl %ebx
+ movl 8(%esp),%eax
+ movb 12(%esp),%cl
+ .align 2,0x90
+L1:
+ movb (%eax),%bl
+ cmpb %bl,%cl /* found char??? */
+ je L2
+ incl %eax
+ testb %bl,%bl /* null terminator??? */
+ jnz L1
+ xorl %eax,%eax
+L2:
+ popl %ebx
+ ret