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.5Sjakllsch	RCSID("$NetBSD: ffs.S,v 1.5 2014/03/22 19:16:34 jakllsch Exp $")
111.1Schristos#endif
121.1Schristos
131.1SchristosENTRY(ffs)
141.1Schristos	bsfl	%edi,%eax
151.4Schristos	jz	1f	 		/* ZF is set if all bits are 0 */
161.1Schristos	incl	%eax			/* bits numbered from 1, not 0 */
171.1Schristos	ret
181.1Schristos
191.4Schristos1:	xorl	%eax,%eax		/* clear result */
201.1Schristos	ret
211.5SjakllschEND(ffs)
22