Setting Up A Modulo Buffer - Motorola DSP56800 Manual

16-bit digital signal processor
Table of Contents

Advertisement

Address Generation Unit
The buffer is used simply by accessing it with MOVE instructions. The effect of modulo address
arithmetic becomes apparent when the buffer is accessed multiple times, as in Example 4-2 on page 4-30.
MOVE
X:(R0)+,X0
MOVE
X:(R0)+,X0
MOVE
X:(R0)+,X0
MOVE
X:(R0)+,X0
MOVE
X:(R0)+,X0
MOVE
X:(R0)+,X0
MOVE
X:(R0)+,X0
MOVE
X:(R0)+,X0
For the first several memory accesses, the buffer pointer is incremented as expected, from $0800 to $0801,
$0802, and so forth. When the pointer reaches the top of the buffer, rather than incrementing from $0804 to
$0805, the pointer value "wraps" back to $0800.
The behavior is similar when the buffer pointer register is incremented by a value greater than one.
Consider the source code in Example 4-3, where R0 is post-incremented by three rather than one. The
pointer register correctly "wraps" from $0803 to $0801—the pointer does not have to land exactly on the
upper and lower bound of the buffer for the modulo arithmetic to wrap the value properly.
Example 4-3. Accessing the Circular Buffer with Post-Update by Three
MOVE
#(5-1),M01
MOVE
#$0800,R0
MOVE
#3,N
NOP
NOP
MOVE
X:(R0)+N,X0
MOVE
X:(R0)+N,X0
MOVE
X:(R0)+N,X0
MOVE
X:(R0)+N,X0
In addition, the pointer register does not need to be incremented; it could be decremented instead.
Instructions that post-decrement the buffer pointer also work correctly. Executing the instruction
when the value of R0 is $0800 will correctly set R0 to $0804.
X:(R0)-,X0
4.3.2.5

Setting Up a Modulo Buffer

The following steps detail the process of setting up and using the 37-location circular buffer shown in
Figure 4-16 on page 4-27.
1. Determine the value for the M01 register.
— Select the size of the desired buffer; it can be no larger than 16,384 locations. If modulo
arithmetic is to be enabled only for the R0 address register, this gives the following:
M01 = # locations - 1 = 37 - 1 = 36 = $0024
— If modulo arithmetic is to be enabled for both the R0 and R1 address registers, be sure to set the
high-order bit of M01:
M01 = # locations - 1 + $8000 = 37 - 1 + 32768 = 32804 = $8024
4-30
Example 4-2. Accessing the Circular Buffer
; First time accesses location $0800
; and bumps the pointer to location $0801
; Second accesses at location $0801
; Third accesses at location $0802
; Fourth accesses at location $0803
; Fifth accesses at location $0804
; and bumps the pointer to location $0800
; Sixth accesses at location $0800 <=== NOTE
; Seventh accesses at location $0801
; and so forth...
; Initialize the buffer for five locations
; Initialize the pointer to $0800
; Initialize "bump value" to 3
; First time accesses location $0800
; and bumps the pointer to location $0803
; Second accesses at location $0803
; and wraps the pointer around to $0801
; Third accesses at location $0801
; and bumps the pointer to location $0804
; Fourth accesses at ...
DSP56800 Family Manual
MOVE

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents