1/* 2 * Written by J.T. Conklin <jtc@NetBSD.org>. 3 * Public domain. 4 * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> 5 */ 6 7#include <machine/asm.h> 8 9#if defined(LIBC_SCCS) 10 RCSID("$NetBSD: ffs.S,v 1.4 2009/07/20 15:21:00 christos Exp $") 11#endif 12 13ENTRY(ffs) 14 bsfl %edi,%eax 15 jz 1f /* ZF is set if all bits are 0 */ 16 incl %eax /* bits numbered from 1, not 0 */ 17 ret 18 191: xorl %eax,%eax /* clear result */ 20 ret 21