1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Ralph Campbell. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11#include <machine/machAsmDefs.h> 12 13#if defined(LIBC_SCCS) && !defined(lint) 14 ASMSTR("@(#)ffs.s 8.1 (Berkeley) 06/04/93") 15#endif /* LIBC_SCCS and not lint */ 16 17/* bit = ffs(value) */ 18 19LEAF(ffs) 20 move v0, zero 21 beq a0, zero, done 221: 23 and v1, a0, 1 # bit set? 24 addu v0, v0, 1 25 srl a0, a0, 1 26 beq v1, zero, 1b # no, continue 27done: 28 j ra 29END(ffs) 30