dsp56800e Freescale Semiconductor, Inc, dsp56800e Datasheet - Page 159

no-image

dsp56800e

Manufacturer Part Number
dsp56800e
Description
16-bit Digital Signal Controller Core
Manufacturer
Freescale Semiconductor, Inc
Datasheet
There is no instruction for reading a long value from an accumulator with saturation enabled. If this
function is required, the SAT instruction can be used, as shown in Example 5-10.
5.2.5
There are three useful techniques for converting the 36-bit contents of an accumulator to a 16-bit value,
which can then be stored to memory or used for further computation. This conversion is useful for
processing word-sized operands (16 bits) because it guarantees that an accumulator contains correct sign
extension and that the least significant 16 bits are all zeros. The three techniques appear in Example 5-11.
In the last technique, where limiting is enabled, limiting only occurs when the extension register is in use.
Refer to Section 8.2.2, “Status Register,” on page 8-7. When the extension register is in use, the extension
in use (E) bit of the status register is set.
5.2.6
There are times when an accumulator value must be saved to the stack, such as in interrupt-handling
routines. To be saved and restored properly, the accumulator must be saved with saturation disabled. The
MOVE.W A,X:(SP)+
this instruction operates with saturation enabled and can inadvertently store the value $7FFF or $8000 if
the extension register is in use. The solution is to save the individual portions of the accumulator, as
demonstrated in Example 5-12.
A faster way of saving and restoring accumulators is to access the stack 32 bits at a time, as shown in
Example 5-13 on page 5-14.
Freescale Semiconductor
Converting a 36-Bit Accumulator to a 16-Bit Value
Saving and Restoring Accumulators
SAT
MOVE.L
;Converting with no limiting
MOVE.W
MOVE.W
;Extracting the A0 portion (no limiting)
ASL16
ASL16
;Converting with limiting enabled
MOVE.W
MOVE.W
; Saving the A accumulator to the stack
ADDA
MOVE.W
MOVE.W
MOVE.W
; Restoring the A accumulator from the stack
MOVE.W
MOVE.W
MOVE.W
Example 5-10. Reading a Long Value from an Accumulator with Limiting
Example 5-12. Saving and Restoring an Accumulator—Word Accesses
Example 5-11. Converting a 36-Bit Accumulator to a 16-Bit Value
instruction should never be used when a value is being saved to the stack, because
A
A10,X:D_to_A_data
A1,A
C1,B
A
A,D
A,A
A,C
#1,SP
A2,X:(SP)+
A1,X:(SP)+
A0,X:(SP)
X:(SP)-,A0
X:(SP)-,A1
X:(SP)-,A2
;Sign extend A2, A0 set to $0000
;Sign extend B2, B0 set to $0000
;Sign extend A2, write A1, clear A0
;Sign extend D2, write D1, clear D0
;Sign extend A2, limit if required
;Sign extend C2, limit if required
Data Arithmetic Logic Unit
; Point to first empty location
; Save extension register
; Save A1 register
; Save A0 register
; Restore A0 register
; Restore A1 register
; Restore extension register
; Limit the value in the A accumulator
; Saturation is no longer required
Accessing the Accumulator Registers
5-13

Related parts for dsp56800e