Search code examples
c++visual-studioassemblyinline-assemblysqrt

call asm sqrtsd under a c++


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


Solution

  • 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;
    }