Simple inline assembly program won't compile
This is driving me insane... I'm sure there's something very small I'm doing wrong here, but I can't figure out what it is after trying for 30 minutes and go开发者_如何学Pythonogling. I am trying to compile a very simple C program with some inline assembly, then disassemble it, in order to get the machine code for the instructions. This is for a school programming project. Here is my most recent attempt:
int main()
{
asm(
"movl $0x5bc1229f,0x0804c1e8"
"movl $0x08048f9c,%edx"
"push %edx"
"ret"
);
}
When I compile this, I get the errors:
/var/folders/kI/kIAe03vJFdClYy0r0mmBp++++TI/-Tmp-//cc2xKnoz.s:9:junk `movl $0x08048f9c' after expression
/var/folders/kI/kIAe03vJFdClYy0r0mmBp++++TI/-Tmp-//cc2xKnoz.s:9:bad register name `%edxpush%edxret'
Thanks for your help :)
Try
int main()
{
asm(
"movl $0x5bc1229f,0x0804c1e8\n\t"
"movl $0x08048f9c,%edx\n\t"
"push %edx\n\t"
"ret\n\t"
);
}
精彩评论