Saving The Hardware Stack; Restoring The Hardware Stack - Motorola DSP56800 Manual

16-bit digital signal processor
Table of Contents

Advertisement

8.13.1

Saving the Hardware Stack

An example of reading the entire contents of the HWS to X memory is shown in the following code:
; Save HWS
; 4 Icyc, 4 words
MOVE
SR,X:(R2)+
MOVE
HWS,X:(R2)+
MOVE
SR,X:(R2)+
MOVE
HWS,X:(R2)+
8.13.2

Restoring the Hardware Stack

When restoring the HWS, it is first necessary that the HWS be empty. If this is unclear, performing two
reads from the HWS will ensure that the stack is empty. Once this is true, then the HWS can be restored.
An example of restoring the contents of the HWS from X data memory follows:
; Restore HWS, 10 words, 14 Icyc worst case
; Assumes R2 points to "stored" HWS
; Destroys R2 register
MOVE
HWS,LA
MOVE
HWS,LA
BRCLR #$8000,X:(R2),OVER
LEA
(R2)+
MOVE
X:(R2)+,HWS
BRCLR #$8000,X:(R2),OVER
LEA
(R2)+
MOVE
X:(R2)+,HWS
OVER
; Read HWS pointer's LSB (LF) and
; save to memory
; Read first stack location and
; save in X memory
; Read HWS pointer's MSB (NL) and
; save to memory
; Read second stack location and
; save in X memory
; First read of HWS ensures NL bit is cleared
; Second read of HWS ensures LF bit is cleared
; If LF bit set, then push a value onto HWS
; Puts one value onto stack and sets LF bit
; If NL bit set, then push a value onto HWS
Software Techniques
Multitasking and the Hardware Stack
8-35

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents