I am trying to convert this piece of code as to work with the AT&T assembly that g++ uses:
double sqrt13(double n)
{
__asm{
fld n
fsqrt
}
}
Based on this link: https://ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html: I tried this:
double raiz (double n)
__asm__ ( "fld n\n\t"
"fsqrt\n\t" );
but I keep receiving:
/tmp/cc2AQhHj.s|662|Error: junk `n' after expression|
The same error messages happens four more times in other lines of this file
I downloaded a program called "intel2gas" and he says to me that the code shall be this one:
__asm__ volatile__ (
"fld %0\n"
"fsqrt\n"
:"=m"(n)
:
:"memory", "esi", "edi", "eax", "ebx", "ecx", "edx"
);
putting it inside the function and trying to run it, I receive:
|39|error: expected ‘(’ before ‘volatile__’|
|42|error: expected ‘)’ before ‘:’ token|
|45|error: ‘volatile__’ was not declared in this scope|
plus a |46|warning: no return statement in function returning non-void|
So, any suggestions?
volatile. Per the docs,asmcan be__asm__, but I think volatile is just supposed to bevolatile.double raiz (double n) { __asm__ ("fsqrt" : "+t"(n)); return n; }