Motorola HC12 User Manual
User’s Manual
MCUez HC12 Assembler
140
Assembler Syntax
MOTOROLA
Assembler Syntax
7.4.3.12 Indexed, Post-Decrement
This addressing mode allows the user to decrement the base register by a
specified value after indexing takes place. The content of the base register is
read and then decremented by the specified value.
specified value after indexing takes place. The content of the base register is
read and then decremented by the specified value.
Valid range for a pre-decrement value is [1...8]. The base index register may be
X, Y, or SP.
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 2,X-
CPX #CST_TBL
BNE loop
Base register X is loaded with the address of the element following the table
CST_TBL
($1006).
The value at address $1006 ($0) is added to register D. Register X is
decremented by 2 (its value is $1004).
decremented by 2 (its value is $1004).
Register X is not equal to the address of
CST_TBL
, so the value at address
$1004 is added to D; and X is decremented by 2 again (its value is now $1002).
This loop is repeated as long as register X did not reach the beginning of the
table
table
CST_TBL
($1000).