I know this is a very basic question but I am really stuck on it. In fact I am absolutely newbie in GCC syntax.
I want to have local variables (Stack addresses with labels) without using extended inline assembly. Something like the following code in Intel syntax:
DATA1 DB 100
MOV AL, DATA1
This is the code I guess may substitute in GCC:
int someFunction(int x)
{
__asm__ volatile(
"function1:"
".data;"
".2byte $4 data1 ;"
".text;"
"pushq %rbp;"
"movq %rsp , %rbp ;"
"movl var , %eax;" // this is source of error
"popq %rbp;"
"leaveq;"
"retq ; "
);
}
But this code results in this error:
symbol(s) not found for architecture x86_64
I can use global variables in x86 but the same result comes in x64 or x86_x64.
Setting: LLVM 4.1; Cocoa used in Xcode 4
What is the correct syntax?
GCC inline assembler doesn't support local variables, use GCC's extended syntax.
If you are uncomfortable with AT&T syntax there are ways to use Intel syntax on GCC.
This is an excellent how-to on GCC asm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With