<b>
unsigned char x;

void foo(unsigned char d)
{
    x = (x & 0xF) | (d << 4);
}
</b>