Hi all,
I need help for to convert logic in following way:
if 1st bit set in (00000000000000000000000000001) i can get 1
f 1st bit set in (00000000000000000000000000100) i can get 2
f 1st bit set in (00000000000000000100000000000) i can get 11
...........................................................................................................
f 1st bit set in (10000000000000000000000000001) i can get 31
is there any instruction for ARM cortex-r4. i found BSF but i do not think it support .
" I mean to say i just want to get the set bit position number in uint32 data ".
Please help me .
I think you can use RBIT instruction to reverse the bit order, then use CLZ instruction to get the bit position.
If you are using Arm compiler, you can get the value using intrinsic functions: __rbit() and __clz()
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/CJAJJDDH.html
Something like:
y= __clz(__rbit(x)); // return 0 to 31 based on the first "1" direction from LSB to MSB
regards,
Joseph