Hardware Reference
In-Depth Information
each machine word contains exactly one machine instruction, then an n -line assem-
bly program will produce an n -instruction machine language program.
The reason that people use assembly language, as opposed to programming in
machine language (in binary or hexadecimal), is that it is much easier to program
in assembly language. The use of symbolic names and symbolic addresses instead
of binary or hexadecimal ones makes an enormous difference. Most people can
remember that the abbreviations for add, subtract, multiply, and divide are ADD ,
SUB , MUL , and DIV , but few can remember the corresponding numerical values the
machine uses. The assembly language programmer need only remember the sym-
bolic names because the assembler translates them to the machine instructions.
The same remarks apply to addresses. The assembly language programmer
can give symbolic names to memory locations and have the assembler worry about
supplying the correct numerical values. The machine language programmer must
always work with the numerical values of the addresses. As a consequence, no one
programs in machine language today, although people did so decades ago, before
assemblers had been invented.
Assembly languages have another property, besides the one-to-one mapping of
assembly language statements onto machine instructions, that distinguishes them
from high-level languages. The assembly programmer has access to all the fea-
tures and instructions available on the target machine. The high-level language
programmer does not. For example, if the target machine has an overflow bit, an
assembly language program can test it, but a Java program cannot test it. An
assembly language program can execute every instruction in the instruction set of
the target machine, but the high-level language program cannot. In short, every-
thing that can be done in machine language can be done in assembly language, but
many instructions, registers, and similar features are not available for the high-level
language programmer to use. Languages for system programming, like C, are a
cross between these types, with the syntax of a high-level language but with some
of the access to the machine of an assembly language.
One final difference that is worth making explicit is that an assembly language
program can run only on one family of machines, whereas a program written in a
high-level language can potentially run on many machines. For many applications,
this ability to move software from one machine to another is of great practical
importance.
7.1.2 Why Use Assembly Language?
Assembly language programming is difficult. Make no mistake about that. It
is not for wimps and weaklings. Furthermore, writing a program in assembly lan-
guage takes much longer than writing the same program in a high-level language.
It also takes much longer to debug and is much harder to maintain.
Under these conditions, why would anyone ever program in assembly lan-
guage? There are two reasons: performance and access to the machine. First of
 
Search WWH ::




Custom Search