From C standard: "The order of the distribution of bit fields within a device (from high order to low or low order) is determined by the implementation."
Thus, you should not use bit fields where order matters.
Use explicit masking and switching instead:
reqbit1 = (w >> 1) & 1; reqbit2 = (w >> 4) & 3;
or
reqbit1 = (w & 0x00000002) >> 1; reqbit2 = (w & 0x00000010) >> 4;
and for another direction
w = (reqbit1 << 1) | (reqbit2 << 4);
Unwanted parts are usually called reserved1 , etc.
source share