This is the mail archive of the gcc@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: label value in ppc asm stmt


Johan Rydberg wrote:
> 
> Hi!
> 
> I want to get the address of a label within a asm-stmt.
> For example, I want to generate the following code:
> 
>     ...
>     __asm__ ("beq- cr0,%0" :: "?" (&&label));
>     ...
>     label:
>      ...
> 
> What I would like to know is what constrain I should use
> for the input operand.  Doing the same thing on the i386
> platform you use the "p" constrain, but that put the address
> in a register on PPC.


	__asm__ ("beq- cr0,%l0" : : "X" (&&label));

Note the "l".  See "Output Templates and Operand Substitution"
in the internals manual (info gccint).
All of "g", "i", "s", "X" work, btw;  but "X" seems the most
appropriate.  This should work on x86, too (and I guess you
were just lucky that the "p" worked).


Segher



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