For example with input x
x = 1234567890 // == 0100 1001 1001 0110 0000 0010 1101 0010
Get upper and lower mask
umask = 7 << 24 // == 0000 0111 0000 0000 0000 0000 0000 0000
lmask = 7 << 3 // == 0000 0000 0000 0000 0000 0000 0011 1000
Get the bits that we want to swap
y = x & umask // == 0000 0001 0000 0000 0000 0000 0000 0000
z = x & lmask // == 0000 0000 0000 0000 0000 0000 0001 0000
Shift y to the lower position
y = y >> (24 - 3) // == 0000 0000 0000 0000 0000 0000 0000 1000
Shift z to the higher position
z = z << (24 - 3) // == 0000 0010 0000 0000 0000 0000 0000 0000
Mask out old values
x = x & ~( umask | lmask ) // == 0100 1000 1001 0110 0000 0010 1100 0010
Put in new values
x = x | y | z // == 0100 1010 1001 0110 0000 0010 1100 1010