Page 131 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 131
1.08 Chapter 4 Assembly Language Programming
tool also has some negative aspects. To use an assembler, you have to spell the
mnemonics correctly and use the symbolic addresses exactly the same way throughout
the program. You have to be concerned about the rales of writing a line of assembly-
language code and the rales about forward references. But once these are mastered, you
can use this powerful tool to help you write larger assembly-language programs.
The middle of this chapter explored some techniques for handling character strings to
prepare you for the simple assembler. These techniques are pervasively used in
microcontrollers. The PUT subroutine and the corresponding GET subroutine are used
whenever we need to output or input characters. While they are actually discussed in
§11.8, a stub can be used in the meantime to simulate output as shown in §4.4, and a
similar stub can be used to simulate input. The string copy subroutine can be modified
to make a string concatinate subroutine to append strings, and variations of the search
and dictionary subroutines can recognize strings of characters, to respond to them.
At the end of this chapter, we presented a simple assembler. This program is larger
than those that we found in Chapters 1 to 3. Scanning over this program, you should
become aware of the need for a tool like the assembler to write longer programs.
Consider the effort of writing such a long program manually, as we did in Chapters I to
3. We will also note, in Chapter 6, the need for subroutines. Our assembler used
subroutines to break up a long program into shorter subroutines, which were easier to
understand and to debug. This program and preliminary material in §4.4 also introduced
techniques in handling ASCII character strings. You will use these techniques in most of
the programs that you write from now on.
The assembler is just one such tool for converting your ideas into machine
instructions. High-level languages can be used too, using compilers and interpreters to
convert your language into the machine's language. High-level languages let you write
even larger programs with a similar degree of effort, but they move you away from the
machine, and it is difficult to extract the full power of the computer when you arc no
longer in full control. While high-level languages are used extensively to program most
computers, especially larger computers, you will find many instances where yoo will
have to program small computers in assembly language in your engineering designs.
This section has introduced the essential ideas of the assembler. The next chapter
further expands the capabilities of the conditional and macro assembler and the linker,
However, this chapter contains all the reader needs to know to read the assembly-
language source code that is generated by a C compiler.
Do You Know These Terms?
See the end of chapter 1 for instructions.
hand assembly object code operation field allocate
assembler listing operand field initialize
ASCII character assembly errors expressions pass
line of assembly- vector comment field symbol table
language code labels include file location counter
assembly- symbolic address assembler forward reference
language symbol directive two-pass
statement label field undefined data assembler