Since ARM has no trailing zero count, you may even end up with following code for bsf32:Code: Select all
static inline int BSF32(uint32 bb) { #ifdef USE_ARM_ASM return __builtin_clz(bb & -bb) ^ 31; #else [/quote] Thanks, I will try that also. But I am unable to find such bit tricks by myself, and to understand that it works, I had to check with an example ! Pascal Georges
Bit Scan (equivalent to ASM instructions bsr and bsf)
Moderators: hgm, Dann Corbit, Harvey Williamson
-
pgeorges
Re: Bit Scan (equivalent to ASM instructions bsr and bsf)
-
pgeorges
Re: Bit Scan (equivalent to ASM instructions bsr and bsf)
This is an engine port.diep wrote:Small question: why use bitboards at a 32 bits ARM processor?
You know, you can try put car wheels underneath a bicycle, but the question is whether that makes any sense.
Vincent
Pascal Georges
-
Gerd Isenberg
- Posts: 2250
- Joined: Wed Mar 08, 2006 8:47 pm
- Location: Hattingen, Germany
Re: Bit Scan (equivalent to ASM instructions bsr and bsf)
bb & -bb isolates the least significant bit thanks to the two's complement:pgeorges wrote: Thanks, I will try that also. But I am unable to find such bit tricks by myself, and to understand that it works, I had to check with an example !
Pascal Georges
Code: Select all
0010 0001 0110 0000
1101 1110 1010 0000 -> copy bits from bit zero until first one, then complement
0000 0000 0010 0000
Code: Select all
31 - x(0..31) == 31 ^ x(0..31) == x(0..31) ^ 31