This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Assembly constraints - offset?
- From: Ian Lance Taylor <iant at google dot com>
- To: Avi Kivity <avi at qumranet dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 27 Sep 2006 09:42:06 -0700
- Subject: Re: Assembly constraints - offset?
- References: <451A55B1.30907@qumranet.com>
Avi Kivity <avi@qumranet.com> writes:
> I'd like to access several members of a structure from inline assembly
> (x86):
>
> asm ( "mov $1, %[member1](%[base]) \n\t"
> "mov $2, %[member2](%[base]) \n\t"
> : : [base]"r"(ptr),
> [member1]"i"(offsetof(struct the_struct, member1)),
> [member2]"i"(offsetof(struct the_struct, member2)));
>
> However, the "i" constraint generates an immediate marker ('$'), so I get
>
> mov $1, $4(%ecx)
> mov $2, $8(%ecx)
>
> The second '$' is a bit unhelpful.
>
> Is there any constraint which will emit the offset without the '$'?
Using %[member1]c should work.
Ian