ffs.S 340 B

12345678910111213141516171819
  1. /* $OpenBSD: ffs.S,v 1.2 1996/09/27 06:47:45 mickey Exp $ */
  2. /*
  3. * Written by J.T. Conklin <jtc@netbsd.org>.
  4. * Public domain.
  5. */
  6. #include <machine/asm.h>
  7. ENTRY(ffs)
  8. bsfl 4(%esp),%eax
  9. jz L1 /* ZF is set if all bits are 0 */
  10. incl %eax /* bits numbered from 1, not 0 */
  11. ret
  12. .align 2
  13. L1: xorl %eax,%eax /* clear result */
  14. ret