Under visual 2012 how can I call the sqrtsd asm function in a c++ project
I can't find it via google
something like :
double mySqrt(double val)
{
__asm
{
...
sqrstd...
}
}
EDIT:
in 32bit mode
Under visual 2012 how can I call the sqrtsd asm function in a c++ project
I can't find it via google
something like :
double mySqrt(double val)
{
__asm
{
...
sqrstd...
}
}
EDIT:
in 32bit mode
I think doing this is a somewhat academic excercise, as it's unlikely to have any actual benefit, and quite likely a penalty. However:
double mySqrt(double val)
{
double retu;
__asm
{
sqrtsd xmm1, val
movsd retu, xmm1
}
return retu;
}
Why not using sqrt function http://www.cplusplus.com/reference/cmath/sqrt/ which will be portable ?
By default VS 2012 will replace sqrt() by __libm_sse2_sqrt_precise
. But if you compile with /fp:fast
it will replace by sqrtsd
You may or may not be able to use inline assembler, as other answers have indicated.
There are, however so called intrinsics for SSE (and MMX and others):
The one for sqrtsd
is _mm_sqrt_sd
You'll obviously have to read a few of the other pages as well to be able to put together the whole thing. Intrinsics is the recommended way by Microsoft to solve this.
I think doing this is a somewhat academic excercise, as it's unlikely to have any actual benefit, and quite likely a penalty. However:
double mySqrt(double val)
{
double retu;
__asm
{
sqrtsd xmm1, val
movsd retu, xmm1
}
return retu;
}
what you want, the feature that you are looking for, it's called "inline assembly", meaning assembly inside a C/C++ program basically, Visual Studio doesn't offer a good support for this, for x64 bit platform it doesn't offer this feature at all.
http://www.viva64.com/en/k/0015/
You probably want to switch to a better compiler.
© 2022 - 2024 — McMap. All rights reserved.
push argument \r\n call sqrt
, however you'll need 1. the mangled name ofstd::sqrt()
, 2. a good assembly tutorial. – Wraparound