dsp56800e Freescale Semiconductor, Inc, dsp56800e Datasheet - Page 209

no-image

dsp56800e

Manufacturer Part Number
dsp56800e
Description
16-bit Digital Signal Controller Core
Manufacturer
Freescale Semiconductor, Inc
Datasheet
accessed (such as occurs in data structures). However, post-updating word pointers always occurs in word
addresses, so using a word pointer in a post-update addressing mode to access a byte array would only
access every other byte. Using byte pointers fixes this problem.
Byte pointers are only used if an instruction contains the “.BP” suffix. Otherwise, the pointer is always
interpreted as a word pointer. The offsets for all instructions that are accessing bytes from memory are
always byte offsets, regardless of whether an instruction uses a pointer as a byte or word pointer.
Example 6-4 demonstrates the difference between the MOVE.BP and MOVE.B instructions using
numerical values. For each instruction in Example 6-4, the comment shows the word address where the
access occurs as well as the byte that is selected (upper or lower byte of the word).
; Load the R0, SP Address Pointers
; MOVE.BP -- R0 used as a byte pointer, offset is a byte offset
; MOVE.B -- R0 used as a word pointer, offset is a byte offset
; MOVE.B -- SP always used as a word pointer, offset is a byte offset
In Example 6-4, the address pointer R0 is loaded with the value $2000. Locations near the word address
$2000 are accessed when R0 is interpreted as a word pointer (when MOVE.B is used). Locations near the
word address $1000 are accessed when MOVE.BP is used, which causes R0 to be interpreted as a byte
pointer.
6.6.2
Byte arrays are a common data structure in many applications; they are often used to store string values.
The DSP56800E instruction set makes it easy to access and manipulate byte arrays through the use of byte
pointers.
The code in Example 6-5 on page 6-16 shows an eight-element byte array being initialized and also shows
accesses to the array. The base of the array is loaded first as a byte pointer via the assembler’s
function. The first two move instructions access the fifth and eighth array elements, respectively. The base
of the array is then reloaded, and the last two move instructions demonstrate sequential accesses to byte
elements.
Freescale Semiconductor
Byte Arrays
MOVEU.W
MOVEU.W
MOVE.BP
MOVE.BP
MOVE.BP
MOVE.BP
MOVE.BP
MOVE.BP
MOVE.B
MOVE.B
MOVE.B
MOVE.B
MOVE.B
MOVE.B
MOVE.B
MOVE.B
MOVE.B
MOVE.B
Example 6-4. Comparison of MOVE.BP and MOVE.B Instructions
#$2000,R0
#$4000,SP
x:(r0+0),x0
x:(r0+1),x0
x:(r0+2),x0
x:(r0+3),x0
x:(r0+4),x0
x:$2005,x0
x:(r0+0),x0
x:(r0+1),x0
x:(r0+2),x0
x:(r0+3),x0
x:(r0+4),x0
x:(sp),x0
x:(sp-1),x0
x:(sp-2),x0
x:(sp-3),x0
x:(sp-4),x0
Address Generation Unit
; load R0 pointer with the value $2000
; (can be either a byte or word pointer)
; load the stack pointer (SP) with $4000
; (SP must always be a word pointer)
; word address = $1000, selects lower byte
; word address = $1000, selects upper byte
; word address = $1001, selects lower byte
; word address = $1001, selects upper byte
; word address = $1002, selects lower byte
; word address = $1002, selects upper byte
; word address = $2000, selects lower byte
; word address = $2000, selects upper byte
; word address = $2001, selects lower byte
; word address = $2001, selects upper byte
; word address = $2002, selects lower byte
; word address = $4000, selects lower byte
; word address = $3fff, selects upper byte
; word address = $3fff, selects lower byte
; word address = $3ffe, selects upper byte
; word address = $3ffe, selects lower byte
Byte Pointer Memory Accesses
lb()
6-15

Related parts for dsp56800e