OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [libiberty/] [ffs.c] - Blame information for rev 165

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 khays
/* ffs -- Find the first bit set in the parameter
2
 
3
@deftypefn Supplemental int ffs (int @var{valu})
4
 
5
Find the first (least significant) bit set in @var{valu}.  Bits are
6
numbered from right to left, starting with bit 1 (corresponding to the
7
value 1).  If @var{valu} is zero, zero is returned.
8
 
9
@end deftypefn
10
 
11
*/
12
 
13
int
14
ffs (register int valu)
15
{
16
  register int bit;
17
 
18
  if (valu == 0)
19
    return 0;
20
 
21
  for (bit = 1; !(valu & 1); bit++)
22
        valu >>= 1;
23
 
24
  return bit;
25
}
26
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.