![background image](http://html.mh-extra.com/html/texas-instruments/tms320c28-series/tms320c28-series_reference-manual_1094726050.webp)
Instructions
www.ti.com
Example
Calculate the square root of X. A square-root routine similar to that shown below can be
found in the
C28x FPU Fast RTS Library
(
; Y = sqrt(X)
; Ye = Estimate(1/sqrt(X));
; Ye = Ye*(1.5 - Ye*Ye*X*0.5)
; Ye = Ye*(1.5 - Ye*Ye*X*0.5)
; Y
= X*Ye
_sqrt:
; R0H = X on entry
EISQRTF32
R1H, R0H
; R1H = Ye = Estimate(1/sqrt(X))
MPYF32
R2H, R0H, #0.5
; R2H = X*0.5
MPYF32
R3H, R1H, R1H
; R3H = Ye*Ye
NOP
MPYF32
R3H, R3H, R2H
; R3H = Ye*Ye*X*0.5
NOP
SUBF32
R3H, #1.5, R3H
; R3H = 1.5 - Ye*Ye*X*0.5
NOP
MPYF32
R1H, R1H, R3H
; R2H = Ye = Ye*(1.5 - Ye*Ye*X*0.5)
NOP
MPYF32
R3H, R1H, R2H
; R3H = Ye*X*0.5
NOP
MPYF32
R3H, R1H, R3H
; R3H = Ye*Ye*X*0.5
NOP
SUBF32
R3H, #1.5, R3H
; R3H = 1.5 - Ye*Ye*X*0.5
CMPF32
R0H, #0.0
; Check if X == 0
MPYF32
R1H, R1H, R3H
; R2H = Ye = Ye*(1.5 - Ye*Ye*X*0.5)
NOP
MOV32
R1H, R0H, EQ
; If X is zero, change the Ye estimate to 0
MPYF32
R0H, R0H, R1H
; R0H = Y = X*Ye = sqrt(X)
LRETR
See also
Instruction Set
50
SPRUEO2A – June 2007 – Revised August 2008
Summary of Contents for TMS320C28 series
Page 2: ...2 SPRUEO2A June 2007 Revised August 2008 Submit Documentation Feedback ...
Page 12: ...Introduction 12 SPRUEO2A June 2007 Revised August 2008 Submit Documentation Feedback ...
Page 20: ...CPU Register Set 20 SPRUEO2A June 2007 Revised August 2008 Submit Documentation Feedback ...
Page 136: ...Instruction Set 136 SPRUEO2A June 2007 Revised August 2008 Submit Documentation Feedback ...