Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   square root of a number (http://www.go4expert.com/forums/square-root-t19647/)

nithyasj 2Oct2009 09:30

square root of a number
 
can you explain me how to write an assembly program in 8085 to find square root of a number

xpi0t0s 2Oct2009 12:53

Re: square root of a number
 
What algorithm are you using, and are you using floating point or integer arithmetic?

nithyasj 3Oct2009 09:58

Re: square root of a number
 
actually i dont know how to write an assembly programming.cant we use both integer & floating point numbers?

xpi0t0s 4Oct2009 22:51

Re: square root of a number
 
So why do you want us to explain how to write an assembly program to do square roots? Are you on a course and haven't been paying attention?

Before you can write a program you need to know how to do what your program will do. You can't just say to the computer "do a square root" cos it won't know what that means. So you need to start with an algorithm for working out square roots (and I don't mean "enter the number then press the square root key"). Once you know how to work out square roots you can then start learning assembly and in the process of that, see what instructions you will need to implement that algorithm,

One way to work out the square root of X is to start with N=1 and see if N*N is less than or equal to X. If it is then increment it and repeat. When N*N is greater than X you know you've gone past it, so decrement N and that is the closest integer to the true square root of X. This is a fairly easy program do to in any language, but of course you need to know how to write programs, which you should already know how to do if you're on a programming course and your teacher has just said "Right, now write a program to do square roots".


All times are GMT +5.5. The time now is 13:08.