xref: /openbsd/lib/libc/arch/i386/string/ffs.S (revision 898184e3)
1/*	$OpenBSD: ffs.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
2/*
3 * Written by J.T. Conklin <jtc@netbsd.org>.
4 * Public domain.
5 */
6
7#include <machine/asm.h>
8
9ENTRY(ffs)
10	bsfl	4(%esp),%eax
11	jz	L1	 		/* ZF is set if all bits are 0 */
12	incl	%eax			/* bits numbered from 1, not 0 */
13	ret
14
15	.align 2
16L1:	xorl	%eax,%eax		/* clear result */
17	ret
18