We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have to count modified bits in a volatile 32 bit data word.Example:Initial counter32[32] := 0; olddata := 0x00000010; newdata := 0x0000000001;So we have moddata := newdata xor olddata => moddata := 00000011.So bit0 and bit1 have changed.Now I would have counter[1]++ and counter[0]++;How this can be done on a Cortex-M0+ fastes way?Best regards Juergen
I think this is a workable CM0 assembler version
pop32 PROC EXPORT pop32 ldr r1, =0x55555555 lsrs r2, r0, #1 ands r1, r2 subs r0, r1 ldr r1, =0x33333333 lsrs r2, r0, #2 ands r0, r1 ands r2, r1 adds r0, r2 lsrs r1, r0, #4 ldr r2, =0x0F0F0F0F adds r0, r1 ands r0, r2 lsrs r1, r0, #8 adds r0, r1 lsrs r1, r0, #16 adds r0, r1 movs r1, #0x3f ands r0, r1 bx lr ENDP