Page 80 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 80
3
Addressing Modes
In the past two chapters, we have introduced the instruction cycle and the instruction set.
We have used a few addressing modes in order to understand those ideas. However, we did
not attempt to convey the principles of addressing modes. We now complete our
understanding of the instruction by describing the addressing modes used in the 6812.
Recall from Chapter 1 that an instruction generally consists of an operation with
one address in memory for an operand and/or result. How that address is determined is
called addressing, and the different ways that the address is determined are called
addressing modes. The data are accessed in a program, that is, read or written, by an
instruction with the addressing modes available in the computer. These modes correspond
to the data structures that can be easily managed in that computer. If you want to handle
a particular structure, such as a string of characters, an addressing mode such as
postincrement is very useful, as we discuss in more detail in Chapter 9. This chapter
introduces the 6812's addressing modes, which provide the tools that make handling the
most useful data structures so easy on this machine. Learning the rich set of addressing
modes here will also make it easier later to learn about the common data structures.
This chapter introduces the following general aspects of addressing. We first discuss
addressing modes that are determined by bits in the operation code byte, which is
generally the first byte of the instruction. Indexing modes use a post byte and are
discussed next. Relative modes are then discussed to show the important concept of
position independence. We give examples that rework the addition program of Chapter 1
to illustrate data structure ideas and position independence using these addressing modes.
Finally, we consider some architectural thoughts about addressing such as multiple
address instructions and the effective address computation in the fetch execute cycle. We
also discuss the level of addressing that indicates how many times an address must be
read from memory to get the actual or effective address of the operand or result used with
the instruction.
Upon completion of this chapter, you should be able to use the addressing modes
described here with any instruction that has been introduced in Chapter 2. You should be
able to determine what has been done to compute the effective address, what that effective
address will be, and what side effects are generated where some modes are used. This will
prepare you to use good data structures in your programs and thus to write shorter, faster,
and clearer programs as you progress through this material.
57