seedr
fmpy.s
fmpy.s
fmpy
fmpy.s
fmpy.s
fmpy.s
fmpy
fmpy.s
B.1.30 Newton-Raphson Approximation for SQRT(x)
The approximation of sqrt(x) may be performed by using the Newton-Raphson iteration to first find 1.0/
sqrt(x). The sqrt(x) then can be approximated by x * (1.0/sqrt(x)).
Newton-Raphson Approximation
seedr
fmpy.s
fmpy.s
fmpy
fmpy.s
fmpy.s
fmpy.s
fmpy
fmpy.s
fmpy.s
B.1.31 Unsigned Integer Divide
The unsigned integer divide operation divides two 32 bit unsigned integers. The following code divides d0/
d2 with the resulting quotient in d0 and the remainder in d1.
MOTOROLA
d5,d4
d4,d4,d2
#.5,d7.s
d5,d2,d2
#3.0,d3.s ;x * y * y, get 3.0
d4,d7,d2
fsub.s d2,d3
d2,d3,d4
d6.s,d3.s ;y/2 * (3-x * y * y)
d4,d4,d2
d5,d2,d2
d4,d7,d2
fsub.s d2,d3
d2,d3,d4
of SQRT(x)
d5,d4
d4,d4,d2
#.5,d7.s
d5,d2,d2
#3.0,d3.s ;x * y * y, get 3.0
d4,d7,d2
fsub.s d2,d3
d2,d3,d4
d6.s,d3.s ;y/2 * (3-x * y * y)
d4,d4,d2
d5,d2,d2
d4,d7,d2
fsub.s d2,d3
d2,d3,d4
d5,d4,d4
DSP96002 USER'S MANUAL
;y approx 1/sqrt(x)
;y * y, get .5
d3.s,d6.s ;y/2, 3-x * y * y 1
;y * y
;x * y * y
d3.s,d6.s ;y/2, 3-x * y * y 1
;y/2 * (3-x * y * y)
Totals:
;y approx 1/sqrt(x)
;y * y, get .5
d3.s,d6.s ;y/2, 3-x * y * y 1
;y * y
;x * y * y
d3.s,d6.s ;y/2, 3-x * y * y 1
;y/2 * (3-x * y * y)
;x * (1/sqrt(x))
Totals:
1
1
2
2
2
2
1
1
1
1
1
1
1
1
1
1
---
---
11
11
Program
ICycles
Words
1
1
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
---
---
12
12
B-55