This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: inline asm literal constraints
- From: Segher Boessenkool <segher at koffie dot nl>
- To: Marc Tardif <marc at sitepak dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 29 Dec 2002 12:39:52 +0100
- Subject: Re: inline asm literal constraints
- References: <3E0D4DC5.8080807@sitepak.com>
Marc Tardif wrote:
>
> OS: Linux 2.4.13 i686
> gcc: 2.96
>
> When defining inline asm statements, it does not seem possible to
> specify literal constraints. For example, if I have the variable
> "offset" which contains the value "4", there is no way to use this
> literal value in the following:
>
> asm ("jmp *%0(%eax)" : : "n" (offset));
>
> This will generate the following code, which is incorrect:
>
> jmp *$4(%eax)
>
> Instead, this should generate the following code:
>
> jmp *4(%eax)
>
> The problem is that there doesn't seem to be a constraint variable for
> specifying literal values instead of immediate values.
asm ("jmp *%c0(%eax)" : : "n" (offset));
|
------------|
|
--- This should do the trick.
See section "Output Templates and Operand Substitution" in the GCC
internals manual (info gccint).
Segher