28.2.106 __builtin_popcount
Architecture
dsPIC33C/E/F, dsPIC30
Description
Count the number of 1’s (set bits) in an integer.
Prototype
int16_t __builtin_popcount(uint16_t num);
Argument
num
– integer number
Return Value
Returns the number of 1’s found.
Example Instruction sequence
clr w0
mov w1,w3
.LL1:
ff1r w3,w2
bra c,.LL2
inc w0,w0
lsr w3,w2,w3
bra .LL1
.LL2: