static inline real_t DESCALE(unsigned val, int shift)
{
int out;
asm volatile(
"lsrs %[out], %[val], %[shift]\n\t"
"rsb %[shift], %[shift], #0\n\t"
"adc %[out], %[val], lsl %[shift]"
: [out] "=&r" (out),
[shift] "+r" (shift)
: [val] "r" (val)
);
return out;
}

static inline real_t DESCALE(unsigned val, int shift)
{
int out;
if (shift > 0)
out = (val + (1 << (shift - 1))) >> shift;
else
out = val << -shift;
return out;
}