Texas Instruments TMS320C28x Reference Manual page 502

Dsp cpu and instruction set
Table of Contents

Advertisement

SUBCU ACC,loc16
SYNTAX OPTIONS
SUBCU ACC,loc16
Operands
ACC
loc32
Description
Flags and
Z
Modes
N
C
Repeat
Example 1
; Calculate unsigned: Quot16 = Num16Den16, Rem16 = Num16%Den16
MOVU
RPT
||SUBCU
MOV
MOV
0001 1111 LLLL LLLL
Accumulator register
Addressing mode (see Chapter 5)
Perform 16-bit conditional subtraction, which can be used for unsigned
modulus division:
temp(32:0) = ACC << 1 − [loc16] << 16
if( temp(32:0) >= 0 )
ACC = temp(31:0) + 1
else
ACC = ACC << 1
To perform 16-bit unsigned modulus division, the AH register is zeroed and
the AL register is loaded with the "Numerator" value prior to executing the
SUBCU instruction. The value pointed to be the "loc16" addressing mode
contains the "Denominator" value. After executing the SUBCU instruction 16
times, the AH register will contain the "Remainder" and the AL register will
contain the "Quotient" results. To perform signed modulus division, the
"Numerator" and "Denominator" values must be converted to unsigned
quantities, before executing the SUBCU instruction. The final "Quotient"
result must be negated if the "Numerator" and "Denominator" values were of
different sign else the quotient is left unchanged.
At the end of the operation, the Z flag is set if the ACC value is zero, else Z is
cleared. The calculation of temp(32:0) has no effect on the Z bit.
At the end of the operation, the N flag is set if bit 31 of the ACC is 1, else N is
cleared. The calculation of temp(32:0) has no effect on the N bit.
If the calculation of temp(32:0) generates a borrow, C is cleared; otherwise C
is set.
Note:
The V and OVC flags are not affected by the operation.
If this operation is repeated, then the instruction will be executed N+1 times.
The state of the Z, N, C flags will reflect the final result. The V flag will be set if
an intermediate overflow occurs. The OVC flag will count intermediate
overflows, if overflow mode is disabled.
ACC,@Num16
#15
ACC,@Den16
@Rem16,AH
@Quot16,AL
Subtract Conditional 16 Bits
OPCODE
OBJMODE
; AL = Num16, AH = 0
; Repeat operation 16 times
; Conditional subtract with Den16
; Store remainder in Rem16
; Store quotient in Quot16
SUBCU ACC,loc16
RPT
CYC
X
Y
N+1
6-345

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the TMS320C28x and is the answer not in the manual?

Table of Contents

Save PDF