|
CLA库中,有个这种计算,但它是建立在MEISQRTF32这条指令基础上的,
;; Equation: y = sqrt(x)
CLAsqrt .macro y, x
MMOV32 MR0,@_:x: ; MR0 = X
MEISQRTF32 MR1,MR0 ; MR1 = Ye = Estimate(1/sqrt(X))
MMOV32 MR1,@_:x:,EQ ; if(X == 0.0) Ye = 0.0
MMPYF32 MR3,MR0,#0.5 ; MR3 = X*0.5
MMPYF32 MR2,MR1,MR3 ; MR2 = Ye*X*0.5
MMPYF32 MR2,MR1,MR2 ; MR2 = Ye*Ye*X*0.5
MSUBF32 MR2,#1.5,MR2 ; MR2 = 1.5 - Ye*Ye*X*0.5
MMPYF32 MR1,MR1,MR2 ; MR1 = Ye = Ye*(1.5 - Ye*Ye*X*0.5)
MMPYF32 MR2,MR1,MR3 ; MR2 = Ye*X*0.5
MMPYF32 MR2,MR1,MR2 ; MR2 = Ye*Ye*X*0.5
MSUBF32 MR2,#1.5,MR2 ; MR2 = 1.5 - Ye*Ye*X*0.5
MMPYF32 MR1,MR1,MR2 ; MR1 = Ye = Ye*(1.5 - Ye*Ye*X*0.5)
MMPYF32 MR0,MR1,MR0 ; MR0 = Y = Ye*X
MMOV32 @_:y:,MR0 ; Store Y = sqrt(X)
.endm |
|