Texas Instruments TMS320C67X/C67X+ DSP Car Speaker User Manual


 
Programming Considerations
Interrupts5-22 SPRU733
5.6 Programming Considerations
The interaction of the C6000 CPUs and sources of interrupts present program-
ming issues for you to consider when you are developing your code.
5.6.1 Single Assignment Programming
Using the same register to store different variables (called here: multiple
assignment) can result in unpredictable operation when the code can be
interrupted.
To avoid unpredictable operation, you must employ the single assignment
method in code that can be interrupted. When an interrupt occurs, all instruc-
tions entering E1 prior to the beginning of interrupt processing are allowed to
complete execution (through E5). All other instructions are annulled and
refetched upon return from interrupt. The instructions encountered after the
return from the interrupt do not experience any delay slots from the instructions
prior to processing the interrupt. Thus, instructions with delay slots prior to the
interrupt can appear, to the instructions after the interrupt, to have fewer delay
slots than they actually have.
Example 510 shows a code fragment which stores two variables into A1
using multiple assignment. Example 511 shows equivalent code using the
single assignment programming method which stores the two variables into
two different registers.
For example, suppose that register A1 contains 0 and register A0 points to a
memory location containing a value of 10 before reaching the code in
Example 510. The ADD instruction, which is in a delay slot of the LDW, sums
A2 with the value in A1 (0) and the result in A3 is just a copy of A2. If an interrupt
occurred between the LDW and ADD, the LDW would complete the update
of A1 (10), the interrupt would be processed, and the ADD would sum A1 (10)
with A2 and place the result in A3 (equal to A2 + 10). Obviously, this situation
produces incorrect results.
In Example 511, the single assignment method is used. The register A1 is
assigned only to the ADD input and not to the result of the LDW. Regardless
of the value of A6 with or without an interrupt, A1 does not change before it is
summed with A2. Result A3 is equal to A2.
Example 510. Code Without Single Assignment: Multiple Assignment of A1
LDW .D1 *A0,A1
ADD .L1 A1,A2,A3
NOP 3
MPY .M1 A1,A4,A5 ; uses new A1