xref: /minix3/common/lib/libc/arch/powerpc/string/ffs.S (revision b6cbf7203b080219de306404f8022a65b7884f33)
1*b6cbf720SGianluca Guida/*	$NetBSD: ffs.S,v 1.5 2011/01/15 07:31:12 matt Exp $ */
2*b6cbf720SGianluca Guida
3*b6cbf720SGianluca Guida/*-
4*b6cbf720SGianluca Guida * Copyright (C) 2001	Martin J. Laubach <mjl@NetBSD.org>
5*b6cbf720SGianluca Guida * All rights reserved.
6*b6cbf720SGianluca Guida *
7*b6cbf720SGianluca Guida * Redistribution and use in source and binary forms, with or without
8*b6cbf720SGianluca Guida * modification, are permitted provided that the following conditions
9*b6cbf720SGianluca Guida * are met:
10*b6cbf720SGianluca Guida * 1. Redistributions of source code must retain the above copyright
11*b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer.
12*b6cbf720SGianluca Guida * 2. Redistributions in binary form must reproduce the above copyright
13*b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer in the
14*b6cbf720SGianluca Guida *    documentation and/or other materials provided with the distribution.
15*b6cbf720SGianluca Guida * 3. The name of the author may not be used to endorse or promote products
16*b6cbf720SGianluca Guida *    derived from this software without specific prior written permission.
17*b6cbf720SGianluca Guida *
18*b6cbf720SGianluca Guida * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19*b6cbf720SGianluca Guida * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20*b6cbf720SGianluca Guida * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21*b6cbf720SGianluca Guida * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22*b6cbf720SGianluca Guida * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23*b6cbf720SGianluca Guida * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24*b6cbf720SGianluca Guida * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25*b6cbf720SGianluca Guida * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*b6cbf720SGianluca Guida * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27*b6cbf720SGianluca Guida * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*b6cbf720SGianluca Guida */
29*b6cbf720SGianluca Guida/*----------------------------------------------------------------------*/
30*b6cbf720SGianluca Guida
31*b6cbf720SGianluca Guida#include <machine/asm.h>
32*b6cbf720SGianluca Guida
33*b6cbf720SGianluca Guida__RCSID("$NetBSD: ffs.S,v 1.5 2011/01/15 07:31:12 matt Exp $")
34*b6cbf720SGianluca Guida
35*b6cbf720SGianluca Guida	.align 4
36*b6cbf720SGianluca GuidaENTRY(ffs)
37*b6cbf720SGianluca Guida	neg	%r4, %r3
38*b6cbf720SGianluca Guida	and	%r3, %r4, %r3
39*b6cbf720SGianluca Guida	cntlzw	%r3, %r3
40*b6cbf720SGianluca Guida	li	%r0, 32
41*b6cbf720SGianluca Guida	subf	%r3, %r3, %r0
42*b6cbf720SGianluca Guida	blr
43*b6cbf720SGianluca GuidaEND(ffs)
44*b6cbf720SGianluca Guida
45*b6cbf720SGianluca Guida/*----------------------------------------------------------------------*/
46