Enddo - Motorola DSP56800 Manual

16-bit digital signal processor
Table of Contents

Advertisement

ENDDO

Operation:
NL → LF
HWS[1] → HWS[0]; 0 → NL
Description: Terminate the current hardware DO loop immediately. Normally, a hardware DO loop is terminated
when the last instruction of the loop is executed and the current LC equals one, but this instruction can
terminate a loop before normal completion. If the value of the current DO LC is needed, it must be read
before the execution of the ENDDO instruction. Initially, the LF is restored from the NL bit, and the
top-of-loop address is purged from the HWS. The contents of the second HWS location are written into
the first HWS location, and the NL bit is cleared.
Example:
DO
MOVEC
CMP
JNE
ENDDO
JMP
CONTINU
ENDLP
Explanation of Example:
This example illustrates the use of the ENDDO instruction to terminate the current DO loop. The value
of the LC is compared with the value in the Y1 register to determine if execution of the DO loop should
continue. The ENDDO instruction updates certain program controller registers but does not automat-
ically jump past the end of the DO loop. Thus, if this action is desired, a JMP/BRA instruction (that is,
JMP NEXT as shown previously) must be included after the ENDDO instruction to transfer program
control to the first instruction past the end of the DO loop.
Note:
The ENDDO instruction updates the program controller registers appropriately but does not automat-
ically jump past the end of the loop. If desired, this must be done explicitly by the programmer.
Restrictions:
Due to pipelining and the fact that the ENDDO instruction accesses the program controller registers,
the ENDDO instruction must not be immediately preceded by any of the following instructions:
Also, the ENDDO instruction cannot be the next-to-last instruction in a DO loop (at the LA-1).
End Current DO Loop
Y0,ENDLP
:
LC,A
Y1,A
CONTINU
ENDLP
:
:
MOVE
#$1234,X0
MOVEC to SR or HWS
MOVEC from HWS
Any bit-field instruction on the SR
Instruction Set Details
Assembler Syntax:
ENDDO
; execute loop ending at ENDLP (Y0) times
; get current value of loop counter (LC)
; compare loop counter with value in Y1
; go to ONWARD if LC not equal to Y1
; LC equal to Y1, restore all DO registers
; go to NEXT
; LC not equal to Y1, continue DO
; loop
; (last instruction in DO loop)
; (first instruction AFTER DO loop)
ENDDO
A-77

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents