China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 21:05
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » How to calculate the square root in assembly language? (Seeking help) View 1,648 Replies 2
Original Poster Posted 2006-09-14 21:35 ·  中国 江苏 苏州 电信
初级用户
Credits 52
Posts 19
Joined 2006-09-02 23:35
19-year member
UID 61734
Status Offline
Dear experts! I would like to ask, how to calculate the square root in assembly language? It is best to provide the source code! Thanks!
Floor 2 Posted 2006-09-15 04:18 ·  中国 湖南 长沙 电信
中级用户
★★
Credits 282
Posts 126
Joined 2006-05-17 22:29
20-year member
UID 55724
Status Offline
Is it an integer or a floating-point number?

What kind of assembly? Is it x86? Does it have a floating-point coprocessor?

If it has an x87 floating-point coprocessor (CPUs after 486DX integrate a floating-point coprocessor), you can use the floating-point instruction FSQRT.

If there is no floating-point coprocessor, you can only write your own program to calculate the square root using the Newton iteration method.

When the value is not large, array look-up is a very good choice.
人类存在的目的就是试图理解人类为何存在
Floor 3 Posted 2006-09-16 12:05 ·  中国 江苏 苏州 电信
初级用户
Credits 52
Posts 19
Joined 2006-09-02 23:35
19-year member
UID 61734
Status Offline
Forum Jump: