SUBCUL ACC,loc32
Example 1
; Calculate unsigned: Quot32 = Num32/Den32, Rem32 = Num32%Den32
MOVB
MOVL
RPT
||SUBCUL
MOVL
MOVL
Example 2
; Calculate signed: Quot32 = Num32/Den32, Rem32 = Num32%Den32
CLRC
MOVL
ABSTC
MOVL
MOVL
ABSTC
MOVL
MOVB
RPT
||SUBCUL
MOVL
MOVL
NEGTC
MOVL
Example 3
; Calculate unsigned: Quot64 = Num64Den32, Rem32 = Num64%Den32
MOVB
MOVL
RPT
||SUBCUL
MOVL
MOVL
RPT
||SUBCUL
MOVL
MOVL
6-348
ACC,#0
; Zero ACC
P,@Num32
; Load P register with Num32
#31
; Repeat operation 32 times
ACC,@Den32
; Conditional subtract with Den32
@Rem32,ACC
; Store remainder in Rem32
@Quot32,P
; Store quotient in Quot32
TC
; Clear TC flag, used as sign flag
ACC,@Den32
; Load ACC with contents of Den32
ACC
; Take absolute value, TC = sign ^ TC
XT,@ACC
; Temp save denominator in XT register
ACC,@Num32
; Load ACC register with Num32
ACC
; Take abs value, TC = sign ^ TC
P,@ACC
; Load P register with numerator
ACC,#0
; Zero ACC
#31
; Repeat operation 32 times
ACC,@XT
; Conditional subtract with denominator
@Rem32,ACC
; Store remainder in Rem32
ACC,@P
; Load ACC with quotient
ACC
; Negate ACC if TC=1 (negative result)
@Quot32,ACC
; Store quotient in Quot32
ACC,#0
; Zero ACC
P,@Num64+2
; Load P with high 32-bits of Num64
#31
; Repeat operation 32 times
ACC,@Den32
; Conditional subtract with Den32
@Quot64+2,P
; Store high 32 bit quotient in Quot64
P,@Num64+0
; Load P with low 32-bits of Num64
#31
; Repeat operation 32 times
ACC,@Den32
; Conditional subtract with Den32
@Rem32,ACC
; Store remainder in Rem32
@Quot64+0,P
; Store low 32 bit quotient in Quot64
Need help?
Do you have a question about the TMS320C28x and is the answer not in the manual?