Page 52 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 52
2,1 Move Instructions 29
Table 2.1. Move Instructions Using an Effective Address
Notice that although CLRA and LDAA #0 make the same move, CLRA clears C,
whereas LDAA #0 does not affect C. Your program may need to use C later. The test
instruction TST, sometimes called a "half a load " instruction, adjusts the N and Z bits
in the condition code register exactly as a load instruction does but without actually
loading the byte into an accumulator. The versatile "load effective address" instructions,
LEAK, LEAY, and LEAS, load one of the index registers or stack pointer with the
effective address computed in an indirect index address calculation, which will be
discussed in Chapter 3. These instructions do not affect the condition code register bits.
Table 2.1 lists the move instructions that use addressing modes. The expressions
such as (E) -> A; accurately describe the instruction's principle effect, E is the effective
address, (E) is the word in memory at location E, A is accumulator A, and -> is a data
transfer, so (E) -> A; means that the word in memory at the location determined by the
instruction's effective address is put into accumulator A. The CPU12RG/D manual
Instruction Set Summary further gives the opcode bytes, allowable addressing modes for
each instruction, and condition code modifications that result from executing these
instructions. These same conventions are used with the tables that follow in this chapter.
Table 2.2 lists move instructions that push on or pull from the stack. The stack
pointed to by register SP is called the hardware stack. A program can have other stacks
as well. A stack is an abstraction of a stack of letters on your desk. Received letters are
put on top of the stack; when read, they are removed from the top of the stack.
In the computer, letters become bytes and the memory that stores the stack becomes
a buffer with a stack pointer as follows. One decides to put this buffer, say, from $b80
to $bff. See Figure 2.2. The amount of storage allocated to the buffer should be the
worst case number of bytes saved on the stack. Usually, we allow a little extra to prevent
a stack overflow. SP points to the top byte that is on the stack. The SP register is
generally initialized once to the high end of the buffer, at the beginning of the program,