You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CubeSatSim/libs/libmf/source/hweight32.c

34 lines
454 B

#include "libmftypes.h"
#if defined(SDCC)
__reentrantb uint8_t hweight32(uint32_t x) __reentrant __naked
{
x;
__asm;
push acc
lcall _hweight16
mov dph,a
pop dpl
lcall _hweight8
mov a,dph
add a,dpl
mov dph,a
mov dpl,b
lcall _hweight8
mov a,dph
add a,dpl
mov dpl,a
ret
__endasm;
}
#else
__reentrantb uint8_t hweight32(uint32_t x) __reentrant
{
return hweight8(x) + hweight8(x >> 8) + hweight8(x >> 16) + hweight8(x >> 24);
}
#endif

Powered by TurnKey Linux.