This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
How to make asm constraints for member variables?
- From: Christian SchÃler <gcchelp dot 5 dot adept at 0sg dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 16 Sep 2007 22:18:14 +0000 (UTC)
- Subject: How to make asm constraints for member variables?
Hi list,
I'd like to make an asm statement emit offset-register addressing like this:
movl 0x80(eax), ebx
where eax contains the pointer to a class (this) and 0x80 is the offset to a
member variable.
I get an error when assigning the member variable to a memory reference.
asm( "mov %[source], %[dest]"
: [dest] "=r" (...)
: [souce] "m" (this->member) ); // ERROR "memory input is not directly
addressable"
Also, decomposing by hand always put a "$" in front of the offset rendering it
unusable, eg.
asm( "mov %[offset](%[base]), %[dest]"
: [dest] "=r" (...)
: [base] "r" (this), [offset] "p" (offsetof(member)) );
generates
movl $0x80(eax), ebx // ERROR "Junk..."
where assembler complains about the dollar sign.
What is the correct way to auto-generate addressing for member variables?