??? 09/11/12 11:39 Read: times |
#188308 - Just use C expression Responding to: ???'s previous message |
Maarten Brock said:
C-standard said:
The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined. This means that the compiler gets to choose which order it uses (globally, not case-by-case) and another compiler can make a different choice. It is never wise to rely on bitfield allocation strategy. final_var => D7 D6 D5 D4 D3 var3.D6 var2.D4 var1.D7 final_var = (var4 & 0xF8) | ((var3 & 0x40) >> 4) | ((var2 & 0x10) >> 3) | ((var1 & 0x80) >> 7); Of course you could map any bit to wherever you want. The >> operator takes quite a lot of cycles. Different C expressions may be compiled more efficiently. In practice, it won't really matter. David. |
Topic | Author | Date |
Different variable bit merge into single variable? | 01/01/70 00:00 | |
Of course | 01/01/70 00:00 | |
its bit addressable.... | 01/01/70 00:00 | |
No | 01/01/70 00:00 | |
just want to check... | 01/01/70 00:00 | |
What was missing in the answers you have already received? | 01/01/70 00:00 | |
no defined bit order | 01/01/70 00:00 | |
Just use C expression | 01/01/70 00:00 | |
what is wrong with IE? | 01/01/70 00:00 | |
Right!!!!!!!!!! | 01/01/70 00:00 | |
gobbledygook | 01/01/70 00:00 |