Freeing One Hardware Stack Location; Multitasking And The Hardware Stack - Motorola DSP56800 Manual

16-bit digital signal processor
Table of Contents

Advertisement

Software Techniques
8.12

Freeing One Hardware Stack Location

There are certain cases where a section of code should use DO looping, but it is not clear whether the HWS
is full or not. An example is an ISR, which may be called when two nested DO loops are in progress. In
these cases it may be desirable to free a single location on the HWS for use by a section of code such as an
ISR. The following code shows how to free one location for an ISR:
; Interrupt Service Routine - Frees Up One HWS Location
; 14 extra Icyc, 12 extra words
;
ISR
LEA
(SP)+
MOVE
LA,X:(SP)+
MOVE
SR,X:(SP)+
MOVE
LC,X:(SP)+
MOVE
HWS,X:(SP)
;
(instructions)
DO
#3,LABEL
INCW
A
LABEL
;
(instructions)
POP
LA
BRCLR #$8000,X:(SP-1),_OVER
MOVE
LA,HWS
_OVER
POP
LC
POP
POP
LA
RTI
For ISRs that are maskable, it is better to follow the recommendations outlined in Section 8.6.4, "Nested
Loops," to reduce the overhead needed for freeing up one HWS location. This greatly simplifies the setup
code required when entering and exiting the ISR.
8.13

Multitasking and the Hardware Stack

For multitasking, it is important to be able to save and later restore the hardware DO loop stack (HWS).
This section shows code that will perform the save and restore operations. When reading the HWS, two
locations of the stack are read as well as the current state of the HWS, contained in the NL and LF bits of
the OMR and SR, respectively. Each read of the HWS register pops the HWS one value, and each write of
the HWS register pushes the HWS one value.
8-34
; Push four registers onto the stack
; Save LA register in case already in loop
; Save LF bit in SR register...
; Save LC register...
; Save HWS register...
; Conditionally restore HWS
; Restore LC register from stack
; Toss SR register from stack
; Restore LA register from stack
DSP56800 Family Manual

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents