If I have a 16-bit number named n and another 16-bit number named n2, and I want to set the first 8 bits of n2 to n. Only the first 8 bits of n should be the same as n2, the remaining 8 should not change. What should I do in such a case? I tried shifting the numbers by 8 but I don't know how to extract the MSB of n and set it to the MSB of n2 and then shift.
Can someone please help me out?
Thanks!