tags:

views:

47

answers:

2

As said. e.g. for the 8-bit(just for example, no byte order considered) integer 00100100, is there an instruction gives 5?

Thanks in advance,

+1  A: 

Yep, BSR. However, do note that the bithack page claims that at least on one CPU a sequence (unrolled loop) of bit shift operations is faster than a single BSR.

Alex Martelli
+2  A: 

Technically, no. There's BSR to find the most significant bit that's set, and BSF to find the least significant bit that's set -- but the smallest item either will work on is a 16-bit word.

Jerry Coffin