]> git.saurik.com Git - apple/xnu.git/blame - bsd/dev/ppc/ffs.s
xnu-517.7.7.tar.gz
[apple/xnu.git] / bsd / dev / ppc / ffs.s
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
e5568f75
A
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
1c79356b 11 *
e5568f75
A
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
e5568f75
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/* Copyright (c) 1992, 1997-1998 Apple Computer, Inc. All rights reserved.
23 *
24 * File: machdep/ppc/libc/ffs.s
25 *
26 * int ffs(int value)
27 *
28 * DESCRIPTION
29 * The ffs() function finds the first bit set in value and returns the
30 * index of that bit. Bits are numbered starting from 1, starting at
31 * the right-most bit. A return value of 0 means that the argument was
32 *
33 * HISTORY
34 * 14-Aug-1998 Umesh Vaishampayan (umeshv@apple.com)
35 * Optimized!
36 *
37 * 10-Mar-1998 Matt Watson (mwatson@apple.com)
38 * Correctified
39 *
40 * 19-Jan-1998 Matt Watson (mwatson@apple.com)
41 * Simplified
42 *
43 * 24-Jan-1997 Umesh Vaishampayan (umeshv@NeXT.com)
44 * Ported to PPC.
45 */
46
47.text
48.align 4
49.globl _ffs
50_ffs: /* Cycles */
51 neg r0,r3 /* 0 */
52 and r3,r0,r3 /* 1 */
53 li r4, 32 /* 1 */
54 cntlzw r3,r3 /* 2 */
55 subf r3,r3,r4 /* 3 */
56 blr
57
58 .globl _abs
59_abs:
60 srawi r0,r3,31
61 xor r3,r0,r3
62 subf r3,r0,r3
63 blr
64