(editor's note: this is a debugging question about what's wrong with this attempted implementation (nearly everything), and thus not a duplicate of How to write a short block of inline gnu extended assembly to swap the values of two integer variables? But see that Q&A and https://stackoverflow.com/tags/inline-assembly/info if you want a working example.)
I'm trying to swap two integer variables using gnu extended assembly, here's what I have for now:
int main()
{
int a = 2;
int b = 1;
printf("a is %d, b is %d\n", a, b);
// TODO (student): swap a and b using inline assembly
printf("a is %d, b is %d\n", a, b);
asm ("mov ebx, b;"
"mov ecx, b;"
"mov c, ecx;"
"mov d, ebx;"
);
I get the error message: asmPractice.c:17: Error: too many memory references for mov
.
How do I solve this?