![background image](http://html1.mh-extra.com/html/texas-instruments/tms320c28x/tms320c28x_reference-manual_1097071503.webp)
SUBCU ACC,loc16
6-346
Example 2
; Calculate signed: Quot16 = Num16Den16, Rem16 = Num16%Den16
CLRC TC
; Clear TC flag, used as sign flag
MOV ACC,@Den16 << 16
; AH = Den16, AL = 0
ABSTC ACC
; Take abs value, TC = sign ^ TC
MOV T,@AH
; Temp save Den16 in T register
MOV ACC,@Num16 << 16
; AH = Num16, AL = 0
ABSTC ACC
; Take abs value, TC = sign ^ TC
MOVU ACC,@AH
; AH = 0, AL = Num16
RPT #15
; Repeat operation 16 times
||SUBCU ACC,@T
; Conditional subtract with Den16
MOV @Rem16,AH
; Store remainder in Rem16
MOV ACC,@AL << 16
; AH = Quot16, AL = 0
NEGTC ACC
; Negate if TC = 1
MOV @Quot16,AH
; Store quotient in Quot16
Example 3
; Calculate unsigned: Quot32 = Num32/Den16, Rem16 = Num32%Den16
MOVU ACC,@Num32+1
; AH = 0, AL = high 16-bits of Num32
RPT #15
; Repeat operation 16 times
||SUBCU ACC,@Den16
; Conditional subtract with Den16
MOV @1,AL
; Store high 16-bit in Quot32
MOV AL,@Num32+0
; AL = low 16-bits of Num32
RPT #15
; Repeat operation 16 times
||SUBCU ACC,@Den16
; Conditional subtract with Den16
MOV @Rem16,AH
; Store remainder in Rem16
MOV @0,AL
; Store low 16-bit in Quot32
Example 4
; Calculate signed: Quot32 = Num32/Den16, Rem16 = Num32%Den16
CLRC TC
; Clear TC flag, used as sign flag
MOV ACC,@Den16 << 16
; AH = Den16, AL = 0
ABSTC ACC
; Take abs value, TC = sign ^ TC
MOV T,@AH
; Temp save Den16 in T register
MOVL ACC,@Num32
; ACC = Num32
ABSTC ACC
; Take abs value, TC = sign ^ TC
MOV P,@ACC
; P = Num32
MOVU ACC,@PH
; AH = 0, AL = high 16-bits of Num32
RPT #15
; Repeat operation 16 times
||SUBCU ACC,@T
; Conditional subtract with Den16
MOV @1,AL
; Store high 16-bit in Quot32
MOV AL,@PL
; AL = low 16-bits of Num32
RPT #15
; Repeat operation 16 times
||SUBCU ACC,@T
; Conditional subtract with Den16
MOV @Rem16,AH
; Store remainder in Rem16
MOV ACC,@AL << 16
; AH = low 16-bits of Quot32, AL = 0
NEGTC ACC
; Negate if TC = 1
MOV @0,AH
; Store low 16-bit in Quot32
Summary of Contents for TMS320C28x
Page 30: ...1 12...
Page 80: ...This page intentionally left blank 2 50 This page intentionally left blank...
Page 269: ...IN loc16 PA 6 112 MOV AL 0 AL 0 UOUT IORegC AL IOspace IORegC AL 10...
Page 308: ...MAXCUL P loc32 6 151 Saturate MOVL Var64 2 ACC Store result into Var64 MOVL Var64 P...
Page 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...
Page 585: ...This page intentionally left blank 7 32 This page intentionally left blank...