Motorola DSP96002 User Manual
Page 265
MOTOROLA
DSP96002 USER’S MANUAL
A - 77
Example:
DO
#n1,END1
DO
#n2,END2
MOVE D0,X:(R0)+
END2
ADD
D1,D2
X:(R1)+,D3
END1
The assembler calculates the end of loop address (LA) (absolute address extension word xxxx) by evalu-
ating the end of loop expression and subtracting one. Thus the end of loop expression in the source code
represents the "next address" after the end of the loop. If a simple end of loop address label is used, it
should be placed after the last instruction in the loop.
The LA register is compared to the PC to determine when the end of loop is reached. If the end of loop is
reached, the loop counter (LC) is tested for one. If LC is not equal to one then it is decremented by one.
If LC is equal to one, the system stack is purged and instruction fetches continue at the incremented PC
address. Otherwise, the PC value on the top of the stack is read to fetch the start of the loop again.
Since the end of loop comparison is at fetch time and ahead of the end of loop execution, instructions which
change program flow or change the system stack may not be used near the end of the loop without some
restrictions. Proper DO loop operation is guaranteed if no instruction starting at address LA-2, LA-1 or LA
specifies the program controller registers SR, SP, SSL, LA, LC or (implicitly) PC as a destination register;
or specifies SSH as a source or destination register. Also, SSH cannot be specified as a source register
in the DO instruction itself. The assembler will generate a warning if the restricted instructions are found
within their restricted boundaries. See Section A.10 for the complete list of restrictions.
Implementation Notes:
DO SP,label The actual value that will be loaded in the LC is the value of the SP before the DO instruction
incremented by one.
DO SSL,label The LC will be loaded with its previous value that was saved in the stack by the DO in-
struction itself.
CCR Condition Codes: Not affected.
ER Status Bits: Not affected.
IER Flags: Not affected.
Instruction Format: DO #count,label
i i
i i i i
i i i i
i i i i
31
14 13
0
ABSOLUTE ADDRESS
0000
0001
1011
i i i i
i i