ffs.S revision 1.1
11.1Schristos/*
21.1Schristos * Written by J.T. Conklin <jtc@NetBSD.org>.
31.1Schristos * Public domain.
41.1Schristos * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
51.1Schristos */
61.1Schristos
71.1Schristos#include <machine/asm.h>
81.1Schristos
91.1Schristos#if defined(LIBC_SCCS)
101.1Schristos	RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:51 christos Exp $")
111.1Schristos#endif
121.1Schristos
131.1SchristosENTRY(ffs)
141.1Schristos	bsfl	%edi,%eax
151.1Schristos	jz	L1	 		/* ZF is set if all bits are 0 */
161.1Schristos	incl	%eax			/* bits numbered from 1, not 0 */
171.1Schristos	ret
181.1Schristos
191.1Schristos	_ALIGN_TEXT
201.1SchristosL1:	xorl	%eax,%eax		/* clear result */
211.1Schristos	ret
22