Answer the question
In order to leave comments, you need to log in
How to work with c++ strings in Inline Assembler (AT&T gcc syntax compiler)?
In general, I found very little sensible information about Inline Assembler and about AT&T syntax in general.
Material on the wiki
English-language manual
There is a working piece on which I experimented, but did not get the desired result.
#include <iostream>
int add(int a, int b){
int res;
asm("movl %1, %%eax\n\
inc %%eax\n\
addl %2, %%eax":"=a"(res):"m"(a),"m"(b));//AT&T
return res;
}
int main()
{
using namespace std;
int a=5, b=5;
printf("a = %d\nb = %d\n", a, b);
int c = add(a, b);
printf("%d + %d + 1 = %d\n", a, b, c);
system("PAUSE");
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question