dsp56800e Freescale Semiconductor, Inc, dsp56800e Datasheet - Page 259

no-image

dsp56800e

Manufacturer Part Number
dsp56800e
Description
16-bit Digital Signal Controller Core
Manufacturer
Freescale Semiconductor, Inc
Datasheet
This technique should not be used to terminate a loop that is nested within another loop. A nested DO loop
can be terminated by using the ENDDO instruction (see Section 8.5.4.2, “Immediate Exit from a Hardware
Loop,” for the correct usage of this instruction). Writing a value to LC causes the previous value in LC to
be copied to LC2, thus destroying the outer loop’s count.
8.5.4.2
When it is necessary to break out of a loop immediately, without executing any more iterations in the loop,
use the ENDDO instruction.
Note that the ENDDO instruction does not cause execution to jump to the end of the loop. ENDDO only
cleans up the hardware stack and the internal loop processing state. A BRA or JMP instruction must be
used to stop the execution of instructions within the body of the loop.
Two examples of code that show how to perform immediate exits appear in Example 8-8.
;
;
LABEL
EXITLP
OVER
;
;
;
;
OVER
;
LABEL
8.5.5
The DO instruction allows an immediate value up to 63 to be specified for the loop count. In cases where it
is necessary to specify a value that is larger than 63, the DOSLC instruction should be used. A 16-bit
immediate loop count can be loaded into the LC register before the loop is started. The loop is then
initiated with the DOSLC instruction, which assumes that the count has previously been loaded into LC.
Example 8-9 on page 8-22 demonstrates this technique.
Freescale Semiconductor
Specifying a Large Immediate Loop Count
DO
(instructions in loop)
Bcc
(other instructions in loop (skipped if immediate exit))
BRA
------ alternate method ------
DO
(instructions)
Bcc
ENDDO
BRA
(instructions)
Immediate Exit from a Hardware Loop
ENDDO
There are restrictions on the location of instructions that modify the LC
register with respect to the end of the loop. See the sections concerning DO
and DOSLC in Section A.2, “Instruction Descriptions,” on page A-7.
#LoopCount,LABEL
EXITLP
OVER
#LoopCount,LABEL
OVER
LABEL
Example 8-8. Immediate Exit from Hardware Loop
;
;
; additional cycle for BRA for normal loop exit
; 1 additional cycle for ENDDO when exiting
; loop if exit via Bcc
; executed each iteration
; executed only for immediate termination
Program Controller
NOTE:
Hardware Looping
8-21

Related parts for dsp56800e