1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

square root of a number

Discussion in 'Assembly Language Programming (ALP) Forum' started by nithyasj, Oct 2, 2009.

  1. nithyasj

    nithyasj New Member

    Joined:
    Oct 2, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    can you explain me how to write an assembly program in 8085 to find square root of a number
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    What algorithm are you using, and are you using floating point or integer arithmetic?
     
  3. nithyasj

    nithyasj New Member

    Joined:
    Oct 2, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    actually i dont know how to write an assembly programming.cant we use both integer & floating point numbers?
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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".
     

Share This Page