A Conversation for Assembly Language
Glorious Assembly Language
Dr. Memory Started conversation Sep 29, 2003
I would like to contribute the following reasons why assembly language is still
widely used, particularly in "embedded" computers (computers which are themselves
part of some other product).
1) HLL's require an environment to run within. When the computer starts up,
how is this environment created? By running "boot" code, written in assembler,
which gets things going. This code does functions such as initializing the processor's
registers and memory control functions, copying initialized variables into RAM,
creating an execution stack and initial stack frame, and passing program control
into the compiled code (which itself may need to be copied into RAM).
2) Wierd machines for which compilers are hard-pressed to optimize, such as DSPs
(Digital Signal Processors - a specialized computer chip designed to do certain
math operations very quickly) and highly parallel processors (computers which
contain many sub-computers all running at the same time). Many of the world's
MP3 players are DSP chips running carefully hand-optimized assembler code.
3) CPU features which compilers don't know about. This applies mainly to people
who write operating systems and need control over memory management, caching,
or control over instruction sequences. My favorite assembly instruction, "eieio",
for the PowerPC, "enforce in-order execution of i/o", falls into this category.
4) Interfaces to external hardware. Assembler allows the programmer complete
control over the exact interaction of external devices to the computer.
5) Interrupt handlers - these are almost always written in assembler because
the execution is critical and they must explicitly manipulate the stack. This
is of particular importance on machines which have no stack hardware
6) When the darn thing craps out, some poor engineer will have to hook up a
logic analyzer to the processor and look at the actual ones and zeros on the
address and data buses when it fails. Most logic analyzers have a disassembler,
so it's important to be able to read the disassembled code to see what's
Key: Complain about this post