Instruction Set
Example 3
; Given X, M and B are IQ24 numbers:
; X = IQ24(+2.5) = 0x02800000
; M = IQ24(+1.5) = 0x01800000
; B = IQ24(-0.5) = 0xFF800000
;
; Calculate Y = X * M + B
;
;
_Cla1Task2:
;
; Convert M, X and B from IQ24 to float
; Convert Y from float32 to IQ24
MMPYF32 MRa, MRb, #16FHi
See also
MMPYF32 MRa, MRb, MRc
MMPYF32 MRa, MRb, MRc || MADDF32 MRd, MRe, MRf
670
Control Law Accelerator (CLA)
MI32TOF32
MR0, @_M
MI32TOF32
MR1, @_X
MI32TOF32
MR2, @_B
MMPYF32
MR0, MR0, #0x3380 ; M = 1/(1*2^24) * iqm = 1.5 (0x3FC00000)
MMPYF32
MR1, MR1, #0x3380 ; X = 1/(1*2^24) * iqx = 2.5 (0x40200000)
MMPYF32
MR2, MR2, #0x3380 ; B = 1/(1*2^24) * iqb = -.5 (0xBF000000)
MMPYF32
MR3, MR0, MR1
MADDF32
MR2, MR2, MR3
MMPYF32
MR2, MR2, #0x4B80 ; Y * 1*2^24
MF32TOI32
MR2, MR2
MMOV32 @_Y, MR2
MSTOP
Copyright © 2015–2017, Texas Instruments Incorporated
; MR0 = 0x4BC00000
; MR1 = 0x4C200000
; MR2 = 0xCB000000
; M*X
; Y=MX+B = 3.25 (0x40500000)
; IQ24(Y) = 0x03400000
; store result
; end of task
SPRUI33 – November 4 2015 – Revised January 2017
Submit Documentation Feedback
www.ti.com
Need help?
Do you have a question about the TMS320F28004x and is the answer not in the manual?