|For novel ideas about building embedded systems (both hardware and firmware), join the 39,000+ engineers who subscribe to The Embedded Muse, a free biweekly newsletter. The Muse has no hype and no vendor PR. Click here to subscribe.
By Jack Ganssle
Is Assembly Obsolete?
A number of readers, responding to a recent posting on Slashdot about unneeded abilities, wrote wondering if assembly language has finally become obsolete.
No doubt it has died a merciful death in the PC and IT arenas, but assembly programming will always be an important, even critical, skill for firmware developers.
It certainly has become somewhat marginalized, even in embedded development. Traditional C-resilient areas like ISRs are now typically coded in a high-level language (if you can call C high-level). Complex processors with deep pipelines give the edge to compilers which can optimize instruction ordering far more efficiently than a human. Even brain-dead low end PICs have decent C toolchains now.
Survey data about language use typically show about 20% of firmware folks code at least some of the time in assembly. That's about four times Java's score, and pretty comparable to the sum of people using OO features like inheritance or polymorphism.
<i>Every</i> firmware engineer needs to know an assembly language. C pointers, which baffle too many, suddenly make sense in the context of address indirection. How can someone with no assembly experience possibly understand the implications of register variables? Performance tuning, once one has optimized the algorithm, often comes down to fiddling with C constructs to generate the most efficient machine code.
Despite wonderful IDEs and debuggers that let us work with source code throughout the development cycle, endianness, vector tables and the like will always require understanding what is going on at the machine-code level. Startup code and RAM test routines that can't use a stack come only from programmers proficient at assembly programming.
But more importantly, it's quite impossible to have any deep understanding of computer architecture without understanding registers, addressing modes and instructions. If a Java-only developer ever pondered CPU design, can you imagine the horribly-complex room-full of logic he'd envision? "Here's the circuit that implements a formatted print instruction." Assembly has a pretty clear one to one mapping between the programming language and the underlying hardware.
I do think that increasing program sizes as well as globalization is leading to a new specialization in embedded systems development. Some firmware programmers work only in narrow niches, and may indeed never use assembly. But staying that far removed from the hardware is career suicide. The best developers, the ones everyone calls on to solve difficult systemic problems, know <i>how</i> the computer works, in detail.
What do you think? Have you abandoned assembly language?