Page 110 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 110
4
Assembly Language
Programming
In the examples presented so far, you have probably noticed some real programming
inconveniences, such as finding the operation code bytes, computing the addresses
(particularly relative addresses), and associating the variable names with their memory
locations. Furthermore, if you change the program, much of this routine work may have
to be done again. What we have been doing is sometimes called hand assembly, in that
we generate all of the machine code ourselves. Certainly, hand assembly is appropriate to
the understanding of computer fundamentals. Beyond this we need to know hand
assembly to remove the errors without reassembly. In this chapter we study the
assembler and the skill of assembling programs using the computer.
Before the success of C and C++ compilers, when most programs were written in
assembly language, more knowledge of assembly language was needed than is needed
now because most programs are written in C and C++. The programmer needs to know
how to read an assembly-language listing, which assembles code written by a compiler,
and how to insert critical assembly-language statements in a C or C++ program. This
chapter discusses critical assembler concepts that a programmer writing in C and C++
must know. The next chapter will delve deeper into assembly-language concepts, to
enable the programmer to write large assembly-language programs.
87