CopyBits(x,p,n,y) copy n LSBs from y to x starting LSB at 'p'th position.
t =((~(~0<<n))<<p) x = x & ~t; y = y & t; x=x|y;