Page 56 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 56
2,1 Move Instructions 33
This move instruction moves the immediate operand $04 into a hidden register and
then moves the data from the hidden register into location $803. From the CPU12RG/D
manual, we observe that its execution takes four memory cycles. The alternative to this
instruction is the program segment:
LDAA #4
STAA $803
which is encoded as follows:
This pair of instructions takes the same number of bytes as the MOVE instruction.
Further, the LDAA instruction executes in one memory cycle, and the STAA instruction
executes in three memory cycles. The MOVE instruction is neither statically nor
dynamically more efficient than the pair of instructions, LDAA and STAA. However, it
is clearer. We recommend using the MOVE instruction to write a constant into memory.
But if the same constant is written into two places in memory, as in
LDAA #4
STAA $803
STAA $807
then a program sequence using the MOVE instruction is less efficient:
MOVE #4,$803
MOVE #4,$807
This program sequence takes ten bytes and executes in eight memory cycles, while the
program sequence above it takes eight bytes and executes in seven memory cycles.
The MOVE instruction also moves data from any memory location to any memory
location. MOVE $801,$803 moves a byte from location $801 to location $803. The
MOVW instruction similarly moves 16 bits of data.
Missing move instructions can often be implemented by combinations of other
move instructions. Because there is no instruction to "load" the condition code register, it
can be loaded through accumulator A or B with the TFR instruction. For example, to put
3 into the condition code, execute the code shown in Figure 2.4.
Figure 2.4. Program Segment to Initialize the Condition Code Register