Charles, I know you have said this before, but I disagree, IF the bit fields are supplied by the compiler vendor. Both IAR and KEIL provide bit field definitions for the Philips parts' registers. While they occasionally use different names, that is rare (e.g. IOSET1 vs. IO1SET) and is easily fixed with a define. So they take responsibility for endian-ness and making sure the bits line up. Using bit fields makes the code much more readable than constants like 0x00040000. You can use notation like #define regbit (1<<18), but that is not as clear as IO0SET_bit.P0.18. (did I do the shift right - err left - correctly to get bit 18? Is the constant 0x00040000 correct for bit 18?).... We used to hear the same things about writing in c - real programmers write in assembler. Now it is real programmers don't use bit fields. Bit fields are a tool. Know how to use the tool and it can save time. Even if I had to redefine the bit field defines to move to another compiler, I think it is worth it. My two cents. Dan _____ From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf Of Charles Manning Sent: Wednesday, November 09, 2005 10:13 AM To: lpc2000@yahoogroups.com Subject: Re: [lpc2000] Bit-fields are brain-dead (was Looking to buy compiler) > Just to add to the 'never use bit-fields advice', here's an article > I found a while ago (where the author calls bit-fields brain-dead) ... I would refine this: Never use them for anything that does hardware accesses or has hardware dependencies. I use them quite a bit for packing data into software structures because this allows me to do bit-wise packing without writing a whole bunch of shifter code. Being able to bit-pack structures easily can save a lot of space when creating large numbers of them. SPONSORED LINKS Microprocessor <http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2 =Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=9 3&.sig=tsVC-J9hJ5qyXg0WPR0l6g> Microcontrollers <http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor& w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s =93&.sig=DvJVNqC_pqRTm8Xq01nxwg> Pic microcontrollers <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microproces sor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c =4&s=93&.sig=TpkoX4KofDJ7c6LyBvUqVQ> 8051 microprocessor <http://groups.yahoo.com/gads?t=ms&k=8051+microprocessor&w1=Microprocess or&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c= 4&s=93&.sig=1Ipf1Fjfbd_HVIlekkDP-A> _____ YAHOO! GROUPS LINKS * Visit your group "lpc2000 <http://groups.yahoo.com/group/lpc2000> " on the web. * To unsubscribe from this group, send an email to: lpc2000-unsubscribe@yahoogroups.com <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> . _____ [Non-text portions of this message have been removed]
Message
RE: [lpc2000] Bit-fields are brain-dead (was Looking to buy compiler)
2005-11-09 by Dan Beadle
Attachments
- No local attachments were found for this message.