Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat]

2005-10-27 by Thomas Keller

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

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.