The fallowing program must print 3 , but 'buff' is not seen from asm.
#include <stdio.h>
char buff[] = "%d\n";
int main (void)
{
asm("mov eax, 3");
asm("mov esi,eax");
asm("mov edi,buff");
asm("mov eax, 0");
asm("call printf");
return 0;
}
I try to use the asm intel syntax .
it compile with : gcc -masm=intel -o test2 test2.c
The line
asm("mov edi,buff");
Is wrong , how do i must to write the buff here? I tried [buff] but do not works.Thank you
**Update:
next program works , BUT is using AT&T syntax :
#include <stdio.h>
char Format[] = "%d\n";
int main (void)
{
asm
(
// Make stack space for arguments to printf
"movl $3, %eax\n"
"movl %eax, %esi\n"
"movl $Format, %edi\n"
"movl $0, %eax\n"
"call printf\n"
);
return 0;
} //compile with gcc -o test2 test2.c
I try to do same using intel syntax , but I do not know how to access the global variable ,from asm corectly