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 9RCSID("$MirOS: src/kern/c/i386/ffs.S,v 1.2 2008/08/03 21:02:02 tg Exp $") 10 11 .text 12 13ENTRY(ffs) 14 bsfl 4(%esp),%eax 15 jz L1 /* ZF is set if all bits are 0 */ 16 incl %eax /* bits numbered from 1, not 0 */ 17 ret 18 19 _ALIGN_TEXT 20L1: xorl %eax,%eax /* clear result */ 21 ret 22