xref: /netbsd-src/common/lib/libc/arch/powerpc/string/ffs.S (revision cf88c3890b9a2e310adacd2c695f42a55ca4e79a)
1*cf88c389Smatt/*	$NetBSD: ffs.S,v 1.5 2011/01/15 07:31:12 matt Exp $ */
237c9f0a6Schristos
39eb6edc9Sross/*-
49eb6edc9Sross * Copyright (C) 2001	Martin J. Laubach <mjl@NetBSD.org>
59eb6edc9Sross * All rights reserved.
69eb6edc9Sross *
79eb6edc9Sross * Redistribution and use in source and binary forms, with or without
89eb6edc9Sross * modification, are permitted provided that the following conditions
99eb6edc9Sross * are met:
109eb6edc9Sross * 1. Redistributions of source code must retain the above copyright
119eb6edc9Sross *    notice, this list of conditions and the following disclaimer.
129eb6edc9Sross * 2. Redistributions in binary form must reproduce the above copyright
139eb6edc9Sross *    notice, this list of conditions and the following disclaimer in the
149eb6edc9Sross *    documentation and/or other materials provided with the distribution.
159eb6edc9Sross * 3. The name of the author may not be used to endorse or promote products
169eb6edc9Sross *    derived from this software without specific prior written permission.
179eb6edc9Sross *
189eb6edc9Sross * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
199eb6edc9Sross * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
209eb6edc9Sross * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
219eb6edc9Sross * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
229eb6edc9Sross * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
239eb6edc9Sross * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
249eb6edc9Sross * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
259eb6edc9Sross * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
269eb6edc9Sross * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
279eb6edc9Sross * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
289eb6edc9Sross */
299eb6edc9Sross/*----------------------------------------------------------------------*/
309eb6edc9Sross
319eb6edc9Sross#include <machine/asm.h>
329eb6edc9Sross
33*cf88c389Smatt__RCSID("$NetBSD: ffs.S,v 1.5 2011/01/15 07:31:12 matt Exp $")
34*cf88c389Smatt
359eb6edc9Sross	.align 4
369eb6edc9SrossENTRY(ffs)
379eb6edc9Sross	neg	%r4, %r3
389eb6edc9Sross	and	%r3, %r4, %r3
399eb6edc9Sross	cntlzw	%r3, %r3
409eb6edc9Sross	li	%r0, 32
419eb6edc9Sross	subf	%r3, %r3, %r0
429eb6edc9Sross	blr
43*cf88c389SmattEND(ffs)
449eb6edc9Sross
459eb6edc9Sross/*----------------------------------------------------------------------*/
46