SUBCU ACC,loc16
Example 2
; Calculate signed: Quot16 = Num16Den16, Rem16 = Num16%Den16
CLRC
MOV
ABSTC
MOV
MOV
ABSTC
MOVU
RPT
||SUBCU
MOV
MOV
NEGTC
MOV
Example 3
; Calculate unsigned: Quot32 = Num32/Den16, Rem16 = Num32%Den16
MOVU
RPT
||SUBCU
MOV
MOV
RPT
||SUBCU
MOV
MOV
Example 4
; Calculate signed: Quot32 = Num32/Den16, Rem16 = Num32%Den16
CLRC
MOV
ABSTC
MOV
MOVL
ABSTC
MOV
MOVU
RPT
||SUBCU
MOV
MOV
RPT
||SUBCU
MOV
MOV
NEGTC
MOV
6-346
TC
ACC,@Den16 << 16
ACC
T,@AH
ACC,@Num16 << 16
ACC
ACC,@AH
#15
ACC,@T
@Rem16,AH
ACC,@AL << 16
ACC
@Quot16,AH
ACC,@Num32+1
#15
ACC,@Den16
@Quot32+1,AL
AL,@Num32+0
#15
ACC,@Den16
@Rem16,AH
@Quot32+0,AL
TC
ACC,@Den16 << 16
ACC
T,@AH
ACC,@Num32
ACC
P,@ACC
ACC,@PH
#15
ACC,@T
@Quot32+1,AL
AL,@PL
#15
ACC,@T
@Rem16,AH
ACC,@AL << 16
ACC
@Quot32+0,AH
; Clear TC flag, used as sign flag
; AH = Den16, AL = 0
; Take abs value, TC = sign ^ TC
; Temp save Den16 in T register
; AH = Num16, AL = 0
; Take abs value, TC = sign ^ TC
; AH = 0, AL = Num16
; Repeat operation 16 times
; Conditional subtract with Den16
; Store remainder in Rem16
; AH = Quot16, AL = 0
; Negate if TC = 1
; Store quotient in Quot16
; AH = 0, AL = high 16-bits of Num32
; Repeat operation 16 times
; Conditional subtract with Den16
; Store high 16-bit in Quot32
; AL = low 16-bits of Num32
; Repeat operation 16 times
; Conditional subtract with Den16
; Store remainder in Rem16
; Store low 16-bit in Quot32
; Clear TC flag, used as sign flag
; AH = Den16, AL = 0
; Take abs value, TC = sign ^ TC
; Temp save Den16 in T register
; ACC = Num32
; Take abs value, TC = sign ^ TC
; P = Num32
; AH = 0, AL = high 16-bits of Num32
; Repeat operation 16 times
; Conditional subtract with Den16
; Store high 16-bit in Quot32
; AL = low 16-bits of Num32
; Repeat operation 16 times
; Conditional subtract with Den16
; Store remainder in Rem16
; AH = low 16-bits of Quot32, AL = 0
; Negate if TC = 1
; Store low 16-bit in Quot32
Need help?
Do you have a question about the TMS320C28x and is the answer not in the manual?