I am in need of such a inline assembly code:
- I have a pair(so, it is balanced) of push/pop operation inside the assembly
- I also have a variable in memory (so, not register) as input
like this:
__asm__ __volatile__ ("push %%eax\n\t"
// ... some operations that use ECX as a temporary
"mov %0, %%ecx\n\t"
// ... some other operation
"pop %%eax"
: : "m"(foo));
// foo is my local variable, that is to say, on stack
When disassembling the compiled code, the compiler give the memory address like 0xc(%esp)
, it is relative to esp
, hence, this fragment of code will not works correctly since I have a push
operation before mov
.
Therefore, how can I tell the compile I do not like the foo
relative to esp
, but any thing like -8(%ebp)
relative to ebp.
P.S. You may suggest that I can put eax
inside the Clobbers, but it is just a sample code. I don't like to show the full reason why I don't accept this solution.