This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Inline Assembly, MOV, and Memory Operand Constraint
- From: Georg-Johann Lay <avr at gjlay dot de>
- To: noloader at gmail dot com
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 15 Jun 2011 11:27:45 +0200
- Subject: Re: Inline Assembly, MOV, and Memory Operand Constraint
- References: <BANLkTikbro_abwbtovioLmRbKYSZ1ZjzuA@mail.gmail.com>
Jeffrey Walton schrieb:
> Hi All,
>
> I have a question on inline assembly. For my first experiment, I'm
> trying to read the flags register. Intuitively, I'm trying to perform
> the following:
> mov %eax, result
>
> The assembler does not take the simple syntax (see [1], [2]), andI'm
> having trouble getting the statement right. I've tried lots of
> variations on the following, but have yet to find success.
> unsigned int result;
> ...
> asm volatile("mov %eax, result" : "=m(result)");
>
> What's the trick to move from a register to memory (C variable)?
Something like
asm volatile("mov %%eax, %[result]" : [result] "=m" (result) :: "memory");
> Jeff
>
> [1]
> [2] http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
>