Summary (Microcontrollers)

3.7
In this topic we looked at the addressing modes in the 6812. We saw four genera! themes: the use of page zero, the use of index registers, the use of relative addressing for position independence, and the use of stack addressing for reentrancy and recursion.
With the first theme, we saw inherent and page zero addressing are useful for improving static and dynamic efficiency over direct addressing. Put the most commonly accessed variables in registers, using inherent addressing to access them, and put the next most common variables in page zero, using page zero addressing to access them.
For the second theme, we saw that index registers may be used efficiently to handle addresses that require several accesses and that index registers may be useful for data structure accesses. Index addressing is the fastest and shortest index addressing option and index addressing using 5-bit offsets is available for locations close to that pointed to by the register, while 16-bit offsets are available for all accesses. We also saw that the accumulators may be used, in lieu of an offset, to combine a variable in an index register with a variable in an accumulator to get the effective address. Index registers and their addressing modes provide a lot of power, which we explore further throughout this topic.
With the third theme, the program counter is used as a kind of index register and the same steps used to carry out index addressing are used to carry out relative addressing using the program counter in place of an index register. Although the mechanics are the same, the effect is quite different, and the representation of the address is different. In particular, the address in the instruction using relative addressing is the effective address, not an offset, while the machine code for the instruction uses a relative offset, which is the amount that must be added to the program counter to get the effective address. This mode is useful in making programs position independent, so that they may be mass produced in ROMs and many different systems can use the same ROM.
The last theme showed how the stack pointer can be used with an offset to access local variables and parameters passed on the stack. The reentrancy and recursion techniques are shown to be easily implemented using stack pointer addressing.
This topic covered the rich collection of addressing modes in the 6812. These correspond to the modes in most of the other microcomputers and to most of the useful modes in any computer. Now that you know them, you should be prepared to use them with any instruction in the 6812 (where they are permitted) as we discuss these instructions in the next topic. You should know which mode to use, based on our study of the themes above so that you can produce shorter, faster, and clearer programs.


Do You Know These Terms?

See the end of topic 1 for instructions.
addressing
addressing modes
accessed
inherent
implied
self-modifying
code page zero
mode
pointer register index register index addressing post byte offset
auto increment
autodecrement indirect addressing position
independent program counter
relative relative relative offset sixteen V
complement recursive
subroutine
reentrant
subroutine nested allocation unsigned overflow signed overflow inner product three-address
instruction jump vector
Technological Arts’ Adapt812 is a modular implementation of the 68HC812A4, in single-chip mode, which includes all essential support circuitry for the microcontroller. A well designed connector scheme groups the dedicated 170 lines on one standard 50-pin connector, while routing the dual-purpose I/O lines to a second 50-pin connector, to form the address and data bus for use in expanded memory modes.
tmpD-13_thumb

Next post:

Previous post: