summaryrefslogtreecommitdiffstats
path: root/libc/arch-x86/string/rindex.S
diff options
context:
space:
mode:
Diffstat (limited to 'libc/arch-x86/string/rindex.S')
-rw-r--r--libc/arch-x86/string/rindex.S29
1 files changed, 29 insertions, 0 deletions
diff --git a/libc/arch-x86/string/rindex.S b/libc/arch-x86/string/rindex.S
new file mode 100644
index 0000000..0260d38
--- /dev/null
+++ b/libc/arch-x86/string/rindex.S
@@ -0,0 +1,29 @@
+/* $OpenBSD: rindex.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#ifdef STRRCHR
+ENTRY(strrchr)
+#else
+ENTRY(rindex)
+#endif
+ pushl %ebx
+ movl 8(%esp),%edx
+ movb 12(%esp),%cl
+ xorl %eax,%eax /* init pointer to null */
+ .align 2,0x90
+L1:
+ movb (%edx),%bl
+ cmpb %bl,%cl
+ jne L2
+ movl %edx,%eax
+L2:
+ incl %edx
+ testb %bl,%bl /* null terminator??? */
+ jnz L1
+ popl %ebx
+ ret