> On Monday 09 December 2002 21:04, David Brown wrote: > > This is something that could be a very useful addition. In fact, one of > > the things I've been testing recently is what sort of code mspgcc produces > > for bitfields, since many embedded compilers I have used in the past > > produce horrible code for bitfields (the answer is mspgcc makes very good > > code, except perhaps in the bizare case of switches on bitfields). > > This is really bad code cause mcu core has no 'bitfield extract' instructions. > So, if you declare some bit-field variable which starts from non-zero position > and assign to some other non bit-field var, gcc will shift this down. > But if you're writing a constant to bit-field var, gcc will be Ok. > And also, gcc (somehow) treats bit-fields as 8bits chars (which is Ok for IO > ports). > > Anyway I'll think how to optimize it... >
Don't worry too much about it - I shouldn't imagine that switching on bitfields is too common. But if switching on an eight-bit char leads to extra code (to expand it to 16-bit, for example), then that might be worth looking at, as 8 bit variables are used all the time.
