MOTOROLA
ADDRESSING MODES
CPU12
3-8
REFERENCE MANUAL
In this example, X holds the base address of a table of pointers. Assume that X has
an initial value of $1000, and that the value $2000 is stored at addresses $100A and
$100B. The instruction first adds the value 10 to the value in X to form the address
$100A. Next, an address pointer ($2000) is fetched from memory at $100A. Then, the
value stored in location $2000 is read and loaded into the A accumulator.
3.8.5 Auto Pre/Post Decrement/Increment Indexed Addressing
This indexed addressing mode provides four ways to automatically change the value
in a base index register as a part of instruction execution. The index register can be
incremented or decremented by an integer value either before or after indexing takes
place. The base index register may be X, Y, or SP (auto-modify modes would not
make sense on PC).
Pre decrement and pre increment versions of the addressing mode adjust the value of
the index register before accessing the memory location affected by the instruction —
the index register retains the changed value after the instruction executes. Post-dec-
rement and post-increment versions of the addressing mode use the initial value in the
index register to access the memory location affected by the instruction, then change
the value of the index register.
The CPU12 allows the index register to be incremented or decremented by any integer
value in the ranges –8 through –1, or 1 through 8. The value need not be related to the
size of the operand for the current instruction. These instructions can be used to incor-
porate an index adjustment into an existing instruction rather than using an additional
instruction and increasing execution time. This addressing mode is also used to per-
form operations on a series of data structures in memory.
When an LEAS, LEAX, or LEAY instruction is executed using this addressing mode,
and the operation modifies the index register that is being loaded, the final value in the
register is the value that would have been used to access a memory operand (premod-
ification is seen in the result but postmodification is not).
Examples:
STAA
1,
–
SP
;equivalent to PSHA
STX
2,
–
SP
;equivalent to PSHX
LDX
2,SP+
;equivalent to PULX
LDAA
1,SP+
;equivalent to PULA
For a “last-used” type of stack like the CPU12 stack, these four examples are equiva-
lent to common push and pull instructions. For a “next-available” stack like the
M68HC11 stack, PSHA is equivalent to STAA 1,SP– and PULA is equivalent to LDAA
1,+SP. However, in the M68HC11, 16-bit operations like PSHX and PULX require mul-
tiple instructions to decrement the SP by one, then store X, then decrement SP by one
again.
Summary of Contents for CPU12
Page 8: ...MOTOROLA CPU12 viii REFERENCE MANUAL ...
Page 14: ...MOTOROLA INTRODUCTION CPU12 1 4 REFERENCE MANUAL ...
Page 20: ...MOTOROLA OVERVIEW CPU12 2 6 REFERENCE MANUAL ...
Page 38: ...MOTOROLA INSTRUCTION QUEUE CPU12 4 6 REFERENCE MANUAL ...
Page 300: ...MOTOROLA DEVELOPMENT AND DEBUG SUPPORT CPU12 8 16 REFERENCE MANUAL ...
Page 338: ...MOTOROLA MEMORY EXPANSION CPU12 10 8 REFERENCE MANUAL ...
Page 364: ...MOTOROLA INSTRUCTION REFERENCE CPU12 A 26 REFERENCE MANUAL ...
Page 386: ...MOTOROLA HIGH LEVEL LANGUAGE SUPPORT CPU12 C 6 REFERENCE MANUAL ...
Page 438: ...MOTOROLA SUMMARY OF CHANGES CPU12 S 2 REFERENCE MANUAL ...
Page 439: ......