Answer the question
In order to leave comments, you need to log in
System call not working in inline assembler, what's the problem?
int main(void)
{
char *path = "tmp/path";
asm(
"movl $39, %%eax\n\t"
"movl %0, %%ecx\n\t"
"movl $0x1ff, %%ebx\n\t"
"int $0x80\n\t" : "r"(path) : "%eax" : "%ebx" : "%ecx"
);
return 0;
}
Answer the question
In order to leave comments, you need to log in
Let's start with what doesn't "doesn't work" and doesn't even compile. Because
1. you have the only in-parameter, you need to specify it after the second colon
2. you have 3 clobbered registers, you need to specify them with a comma after the third colon, i.e.
int main(void)
{
char *path = "tmp/path";
asm (
"movl $39, %%eax\n\t"
"movl %0, %%ecx\n\t"
"movl $0x1ff, %%ebx\n\t"
"int $0x80\n\t"
: : "r"(path)
: "%eax", "%ebx", "%ecx"
);
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question