Array Indexes; Global Or Fixed Array With A Constant - Motorola DSP56800 Manual

16-bit digital signal processor
Table of Contents

Advertisement

Software Techniques
PUSH
LC
PUSH
LA
DO
#N,LABEL
(instructions in loop)
Bcc
EXITLP
;
(instructions)
LABEL
BRA
OVER
EXITLP ENDDO
OVER
POP
LA
POP
LC
;
;
------ or with another technique ------
;
PUSH
LC
PUSH
LA
DO
#N,LABEL
;
(instructions)
Bcc
OVER
ENDDO
BRA
LABEL
OVER
(instructions)
LABEL
POP
LA
POP
LC
8.7

Array Indexes

The flexible set of addressing modes on the DSP56800 architecture allow for several different ways to
index into arrays. Array indexing usually involves a base address and an offset from this base. The base
address is the address of the first location in the array, and the offset indicates the location of the data in the
array. For example, the first value in the array typically has an offset of 0, whereas the fourth element has
th
an offset of 3. The n
element is always accessed with an offset of n - 1.
There are two types of arrays typically implemented: global arrays (whose base address is fixed and known
at assembly time) and local arrays (whose base address may vary as the program is running). Global arrays
that are small in size can benefit from the single-word instruction that directly accesses the first 128
locations of the X data memory, as well as the indexed with short displacement addressing mode.
8.7.1

Global or Fixed Array with a Constant

This type of array indexing is performed with the X:#xxxx or X:<aa> addressing mode, where the
assembler adds the base address to the constant offset into the array. Arrays that are small in size can be
indexed using the X:<aa> addressing mode, saving one program word and one instruction cycle. It is also
possible to use the X:(Rn+xxxx) or X:(R2+xx) addressing modes if the base address of the array is stored
in a Rn register.
8-26
; Save outer loop registers if nested loop
; 2 Icyc for each iteration
; 3 Icyc if loop terminates when true
; 3 additional Icyc for BRA when exiting loop
; if normal exit
; 1 additional Icyc for ENDDO when exiting
; loop if exit via Bcc
; Restore outer loop registers if nested loop
; Save outer loop registers if nested loop
; 3 Icyc for each iteration
; 6 Icyc if loop terminates when true
; Restore outer loop registers if nested loop
DSP56800 Family Manual

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents