×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

square root assembly and c++

square root assembly and c++

square root assembly and c++

(OP)
Hi
I'm new in assembly and was trying to get this program to work, it supposed to calculate the square root of any integer but i don't know how to load the ax into the stack, get the square root and return the value to the c++ variable, that was the closest i could come up with, it's really killing me this cuz i can't find it anywhere
plz help

void squareroot(int intA, float Result)
{
asm{
finit
mov ax,intA
mov ss,ax
fsqrt //Compute sqrt(intA).
fstsw ax
mov Result,ax


}
cout<<"Square root of: "<<intA<<"="<<Result;
getch();
asm{
JMP End
}
End:
 

RE: square root assembly and c++

(OP)
i've found the answer, and i've learned a lot about the assembly while looking for thx anyway and soz for bothering
void square_root(int intA, float Result)
{

    asm {



    fild intA
    fsqrt
    fst Result

    jmp End
    }
  End:
cout<<Result;
getch();
}

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close