Motorola HC12 User Manual

Page of 328
Assembler Syntax
Source Line
MCUez HC12 Assembler
User’s Manual
MOTOROLA
Assembler Syntax
139
7.4.3.11  Indexed, Pre-Increment
This addressing mode allows the user to increment the base register by a
specified value before indexing takes place. The base register is incremented by
the specified value and the content of the modified base register is referenced in
the instruction.
The valid range for a pre-increment 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 #$CST_TBL
loop:
ADDD 2,+X
CPX   #END_TBL
BNE   loop
Base register X is loaded with the address of the table
CST_TBL
 ($1000).
Register X is incremented by 2 (its value is $1002) and the value at this address
($18) is added to register D.
X is not equal to the address of
END_TBL
, so it is incremented 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 end of the table
END_TBL
 ($1006).