Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

square root assembly and c++

Status
Not open for further replies.

Bellerofont

Programmer
Apr 19, 2008
2
GB
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:
 
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();
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top