Computer Hardware User's Guide

Circular Addressing
6-25
Addressing Modes
Example 6–25. FIR Filter Code Using Circular Addressing
* Impulse Response
.sect ”Impulse_Resp”
H .float 1.0
.float 0.99
.float 0.95
.
.
.
.float 0.1
* Input Buffer
X .usect ”Input_Buf”,128
.data
HADDR .word H
XADDR .word X
N .word 128
* Initialization
*
LDP HADDR
LDI @N,BK ; Load block size.
LDI @HADDR,AR0 ; Load pointer to impulse re–
; sponse.
LDI @XADDR,AR1 ; Load pointer to bottom of
; input sample buffer.
*
TOP LDF IN,R3 ;Read input sample.
STF R3,*AR1++% ;Store with other samples,
;and point to top of buffer.
LDF 0,R0 ;Initialize R0.
LDF 0,R2 ;Initialize R2.
*
* Filter
*
RPTS N 1 ;Repeat next instruction.
MPYF3 *AR0++%,*AR1++%,R0
|| ADDF3 R0,R2,R2 ;Multiply and accumulate.
ADDF R0,R2 ;Last product accumulated.
*
STF R2,Y ;Save result.
B TOP ;Repeat.