Im trying to use inline asm with mingw and intel syntax.
I get "undefined reference to x and y" which means its coming from the asm
function meaning it cant see the values x,y passed to Add().
Code:
#include <windows.h>
#include <iostream.h>
using namespace std;
int Add(int x, int y)
{
asm
(
".intel_syntax noprefix\n\t"
"mov eax,x\n\t"
"mov ebx,y\n\t"
"add eax,ebx\n\t"
"mov x,eax\n\t"
".att_syntax\n"
);
return x;
}
int main ()
{
int x,y;
cout<<"Enter first number\n";
cin>>x; //enter first number
cout<<"Enter second number\n";
cin>>y; //enter second number
cout<<Add(x,y)<<endl;
return 0;
}