summaryrefslogtreecommitdiff
path: root/sys/lib/libkern/arch/mips/ffs.S
blob: fdc8c0bd3eef909deb5dd13df25d74fc9aa2b5ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "DEFS.h"

	.set	noreorder

/*
 * bit = ffs(value)
 */
LEAF(ffs)
	beq	a0, zero, 2f
	move	v0, zero
1:
	and	v1, a0, 1		# bit set?
	addu	v0, v0, 1
	beq	v1, zero, 1b		# no, continue
	srl	a0, a0, 1
2:
	j	ra
	 nop
END(ffs)