SUBCU ACC,loc16
6-345
SUBCU ACC,loc16
Subtract Conditional 16 Bits
SYNTAX OPTIONS
OPCODE
OBJMODE
RPT
CYC
SUBCU ACC,loc16
0001 1111 LLLL LLLL
X
Y
N+1
Operands
ACC
Accumulator register
loc32
Addressing mode (see Chapter 5)
Description
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.
Flags and
Modes
Z
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.
N
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.
C
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.
Repeat
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.
Example 1
; Calculate unsigned: Quot16 = Num16Den16, Rem16 = Num16%Den16
MOVU ACC,@Num16
; AL = Num16, AH = 0
RPT #15
; Repeat operation 16 times
||SUBCU ACC,@Den16
; Conditional subtract with Den16
MOV @Rem16,AH
; Store remainder in Rem16
MOV @Quot16,AL
; Store quotient in Quot16
Содержание TMS320C28x
Страница 30: ...1 12...
Страница 80: ...This page intentionally left blank 2 50 This page intentionally left blank...
Страница 269: ...IN loc16 PA 6 112 MOV AL 0 AL 0 UOUT IORegC AL IOspace IORegC AL 10...
Страница 308: ...MAXCUL P loc32 6 151 Saturate MOVL Var64 2 ACC Store result into Var64 MOVL Var64 P...
Страница 509: ...SUBL ACC P PM 6 352 SUBL ACC P PM ACC S B 11 M X 4 MOVH Y ACC 5 Store Q15 result into Y...
Страница 585: ...This page intentionally left blank 7 32 This page intentionally left blank...