28.2.107 __builtin_popcountl

Architecture

dsPIC33C/E/F, dsPIC30

Description

Count the number of 1’s (set bits) in a long integer.

Prototype

int16_t __builtin_nop(uint32_t num);

Argument

num – long integer number

Return Value

Returns the number of 1's found.

Example Instruction Sequence

        clr     w0
        mov     w2,w4
   .LL1:
        ff1r    w4,w1
        bra     c,.LL2
        inc     w0,w0
        lsr     w4,w1,w4
        bra     .LL1
   .LL2:
        mov     w3,w4
   .LL3:
        ff1r    w4,w1
        bra     c,.LL4
        inc     w0,w0
        lsr     w4,w1,w4
        bra     .LL3
   .LL4: