blob: 96affabed07ad0ddeed0c8d114fcd28074554022 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/* $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
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