This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: inline asm literal constraints


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]