I'm not sure what you're trying to do. If you want to extract all of the bits and move them to a new variable, just copy them. If you only want the low order bits, you'd do something like
Code:
unsigned int mask = (1<<length) - 1; // fill mask with <length> bits of 1s
dest &= ~mask; // Clear out low order bits in dest
dest |= source & mask; // copy low order bits from source to dest, leaving the rest of dest intact.
You can shift mask up to pick something other than the least significant bits.
If you're copying from a 32 bit value to an array of 4 8 bit values :
Code:
dest[0] = source;
dest[1] = source >> 8;
dest[2] = source >> 16;
dest[3] = source >> 24;
Combine the two bits of code if you only need to copy parts of source to dest.