find position of most significant bit ?

Karl Hasselström
Wed, 27 Nov 2002 19:18:37 +0100

On 2002-11-27 11:22:00 -0500, delta trinity wrote:
> Then, I guess the fastest way to check, if you have a x86 class processor, 
> is to use the 'bsr' assembly instruction (bit scan reverse):
> (Assuming you've put the A->_mp_d[ABS(A->_mp_size)] value into edx.  You 
> could also use a memory refference)
> bsr   eax,edx
> Then, eax contain index of most significant bit.

Use the count_leading_zeros macro. It is defined in terms of some
inline assembly something for lots of processors. It seems to use the
bsrl instruction for at least some x86 variants.

Kalle Hasselström,