This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Structure with bit field

Is it possible to assign a structure (in C) with defined bit-fields to a SFR that is not bit addressable to gain bit addressability ?

Parents
  • Note that the bit fields in C does not have well-defined behaviour, i.e. if they align high or low in the byte or where extra pad may be placed.

    And they are not true native bit variables so the compiler expects to use byte-sized operations to or a bit to set it, or and with the complement of the bit to clear it. It is easy to trick yourself into reading the code and see efficient 8051 bit operations where the real program in reality performs teh same operations you would get from "mystruct.flags |= (1<<4)".

Reply
  • Note that the bit fields in C does not have well-defined behaviour, i.e. if they align high or low in the byte or where extra pad may be placed.

    And they are not true native bit variables so the compiler expects to use byte-sized operations to or a bit to set it, or and with the complement of the bit to clear it. It is easy to trick yourself into reading the code and see efficient 8051 bit operations where the real program in reality performs teh same operations you would get from "mystruct.flags |= (1<<4)".

Children