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