Motorola HC12 Manuale Utente

Pagina di 328
User’s Manual
MCUez HC12 Assembler
138
Assembler Syntax
MOTOROLA
Assembler Syntax
7.4.3.10  Indexed, Pre-Decrement
This addressing mode allows the user to decrement the base register by a
specified value before indexing takes place. The base register is decremented by
the specified value and the content of the modified base register is referenced in
the instruction.
The valid range for a pre-decrement value is [1...8]. The base index register may
be X, Y, or SP.
Example:
ORG $1000
CST_TBL:
DC.B $5, $10, $18, $20, $28, $30
END_TBL:
DC.B $0
main:
CLRA
CLRB
LDX #$END_TBL
loop:
ADDD 1,-X
CPX   #CST_TBL
BNE   loop
Base register X is loaded with the address of the element following the table
CST_TBL
 ($1006).
Register X is decremented by 1 (its value is $1005) and the value at this address
($30) is added to register D.
X is not equal to the address of
CST_TBL
, so it is decremented again and the
content of address $1004 is added to register D.
This loop is repeated as long as register X did not reach the beginning of the
table
CST_TBL
 ($1000).