Indirect Addressing
Indirect Addressing
Indirect Addressing
–
–
Example
Example
Autoincrement
Autoincrement
∑
=
=
4
0n
n
xy
Data
Data
x0
x0
x1
x1
x2
x2
x3
x3
x4
x4
x
x
y
y
XAR2
XAR2
*(0:16bit) - 16 bit label
- must be in lower 64K
- 2 word instruction
x .usect “samp”,6
y .set (x + 5)
.sect “code”
MOVL XAR2,#x
MOV ACC,*XAR2++
ADD ACC,*XAR2++
ADD ACC,*XAR2++
ADD ACC,*XAR2++
ADD ACC,*XAR2++
MOV *(0:y),AL
Fast, efficient access to arrays, lists, tables, etc.
Indexed addressing offers the ability to select operands from within an array without modification
to the base pointer. Stack-based operations are handled with a 16-bit Stack Pointer register, which
operates over the base 64K of data memory. It offers 6-bit non-destructive indexing to access
larger stack-based arrays efficiently.
Indirect Addressing
Indirect Addressing
–
–
Example
Example
Offset
Offset
x[2] = x[1] + x[3]
x[2] = x[1] + x[3]
MOVL
MOVL
XAR2,#x
XAR2,#x
MOV
MOV
AR0,#1
AR0,#1
MOV
MOV
AR1,#3
AR1,#3
MOV
MOV
ACC,*+XAR2[
ACC,*+XAR2[
AR0
AR0
]
]
ADD
ADD
ACC,*+XAR2[
ACC,*+XAR2[
AR1
AR1
]
]
MOV
MOV
*+XAR2[2],AL
*+XAR2[2],AL
x .
x .
usect
usect
“.samp”,5
“.samp”,5
.sect “.code”
.sect “.code”
MOVL
MOVL
XAR2,#x
XAR2,#x
MOV
MOV
ACC,*+XAR2[1]
ACC,*+XAR2[1]
ADD
ADD
ACC,*+XAR2[3]
ACC,*+XAR2[3]
MOV
MOV
*+XAR2[2],AL
*+XAR2[2],AL
x .
x .
usect
usect
“.samp”,5
“.samp”,5
.sect “.code”
.sect “.code”
x
x
Data
Data
x0
x0
x1
x1
x2
x2
x3
x3
x4
x4
XAR2
XAR2
[3]
[3]
3 bit offset
3 bit offset
16 bit offset
16 bit offset
Allows offset into arrays with fixed base pointer
C28x - Appendix B - Addressing Modes B - 11