Indirect Addressing Modes
5-24
Figure 5−2. Circular Buffer with AMODE = 1
0009 0000
31 16 15 0
Buffer size =
9 + 1 = 10
Buffer index
31 0
003F8010
XAR1
XAR6
Top of buffer
Bottom of buffer
XAR6 + XAR1[15:0] = 3F8010h
XAR1[15:0] increments until
it matches XAR1[31:16]
XAR6 + XAR1[15:0] = 3F8010h + 0009h
Matches
XAR1[31:16]
0x0000
Example(s):
; Calculate FIR filter (X[N] = data array, C[N] = coefficientv array):
MOVW DP,#Xindex ; Load DP with page address of Xindex
MOVL XAR6,#X ; Load XAR6 with start address of X array
MOV @AH,#N ; Load AH with size of array X (N)
MOV AL,@Xindex ; Load AL with current circular index
MOVL XAR1,@ACC ; Load parameters into XAR1
MOVL XAR7,#C ; Load XAR7 with start address of C array
SPM −4 ; Set product shift mode to “>> 4”
ZAPA ; Zero ACC, P, OVC
RPT #N−1 ; Repeat next instruction N times
||QMACL P,*+XAR6[AR1%++],*XAR7++ ; ACC = ACC + P >> 4,
; P = (*AR6%++ * *XAR7++) >> 32
ADDL ACC,P << PM ; Final accumulate
MOV @Xindex,AR1 ; Store AR1 into current X index
MOVL @Sum,ACC ; Store result into sum