Thomas Keller wrote: > On Wed, 2005-10-26 at 22:46 -0500, Zack Widup wrote: > >>I'm the same way. I write mostly in assembler, for a couple reasons >>anyway: 1 - it makes me "think" like the microcontroller, and 2 - it >>seems the little bits of C code I've written have redundundundant >>lines in them that make the code longer than if I write it in >>assembler. > > > Yes. Assuming any degree of competence in assemblker at all, code > written in assembler will be smaller and faster than code generated by a > compiler. This is because the compiler, in order to provide the very > generalized programming environemnt necessary in high level languages, > must use very generalized structures and flows. Further, because the > compiler has no way of "knowing" what your intentions as programmer are, > it must manage resources on the target in fixed ways, which are often > not efficient for the sopecific purpose your progarm is designed for. > Vis all the ridiculous register swapping that compiled code often > contains. > > >>I'm not knocking the higher-level languages, it's just that I haven't >>really needed them myself. > > > Well, while I agree with you, I feel compelled to point out that the > primary reasons most people who use high level languages to do embedded > programming are 1) lack of knowledge and expoerience in assembly > language programming, and 2) in commercial development enviroinments, > the time savings to develop working code can be significant, and time > saved equates to development costs saved. > > Reason #2 is not going to ever go away, because it is almost always > bean counters who make the important decisions in a business. Reason #1 > probably won't ever go away either, because so many people are unwilling > to learn new programming languages or methodologies. > > Personally, I plan to do most of my embedded programming in assem,bly > language, because I find it challenegin and fun to, as you pointy out, > "think like the processor," as well as because it affords me direct > control over the hardware. You just can't get any closer to the machine > than assembly language (some might argue that programming in "machine > language" (e.g., binary op codes directly entered into memory using a > switch register) is closer, but I disagree. With the exeception that > most decent assemblers support macro processing and mnemonic labeling, > assembly language translates directly into machine code, and is just as > close to the hardware as the machine code is. > > Tom Good points there. I personally like to model my programme in a high-level language on the PC mainly to get a feel for what it is that I am trying to do. Then I refine that programme until I am satisfied with its performance. When it works correctly on the PC, I then hand-translate it to assembler code. Of course, there are limitations to that approach (like working with the on-chip peripherals which don't model easily), but it gives me a code base which I can then add stuff to. The high-level is also useful in documentation where I am trying to explain just what it is that the programme does. Things get even better if I have a compiler that excretes assembly code for whatever CPU I'm working with; then I can go in and hand-optimise the compiler's output. erikc
Message
Re: [AVR-Chat]
2005-10-27 by erikc
Attachments
- No local attachments were found for this message.