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/hweight16.c

29 lines
355 B

#include "libmftypes.h"
#if defined(SDCC)
__reentrantb uint8_t hweight16(uint16_t x) __reentrant __naked
{
x;
__asm;
lcall _hweight8
mov a,dpl
xch a,dph
mov dpl,a
lcall _hweight8
mov a,dph
add a,dpl
mov dpl,a
ret
__endasm;
}
#else
__reentrantb uint8_t hweight16(uint16_t x) __reentrant
{
return hweight8(x) + hweight8(x >> 8);
}
#endif

Powered by TurnKey Linux.