SCCS-vsn: lib/libc/mips/string/ffs.s 5.1
--- /dev/null
+/*-
+ * 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)