date and time created 92/02/29 12:48:58 by bostic
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sun, 1 Mar 1992 04:48:58 +0000 (20:48 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sun, 1 Mar 1992 04:48:58 +0000 (20:48 -0800)
SCCS-vsn: lib/libc/mips/string/ffs.s 5.1

usr/src/lib/libc/mips/string/ffs.s [new file with mode: 0644]

diff --git a/usr/src/lib/libc/mips/string/ffs.s b/usr/src/lib/libc/mips/string/ffs.s
new file mode 100644 (file)
index 0000000..d707644
--- /dev/null
@@ -0,0 +1,29 @@
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+       ASMSTR("@(#)ffs.s       5.1 (Berkeley) %G%")
+#endif /* LIBC_SCCS and not lint */
+
+#include "DEFS.h"
+
+/* bit = ffs(value) */
+
+LEAF(ffs)
+       move    v0, zero
+       beq     a0, zero, done
+1:
+       and     v1, a0, 1               # bit set?
+       addu    v0, v0, 1
+       srl     a0, a0, 1
+       beq     v1, zero, 1b            # no, continue
+done:
+       j       ra
+END(ffs)