How this works. Every operation is applied to the value masked to the selected
word width, so the result is what a fixed-width register would actually hold. The two right
shifts differ in what they feed in at the top:
logical (
>>>) always
shifts in zeros, while
arithmetic (
>>) replicates the sign bit so a
negative value stays negative — which is why
0xF0 >> 4 is
0xFF
at 8 bits signed but
0x0F logical. In C, which one you get depends on whether the
operand is signed, and shifting by more than the word width is undefined behaviour rather than
zero. Shift counts here are read as decimal regardless of the selected base.