| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 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 | |||||
| 9 | ENTRY(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 | ||||
| 16 | L1: xorl %eax,%eax /* clear result */ | ||||
| 17 | ret | ||||