1/* $OpenBSD: ffs.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */ 2/* 3 * Written by J.T. Conklin <jtc@netbsd.org>. 4 * Public domain. 5 */ 6 7#include "SYS.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 18END_WEAK(ffs) 19