This is the mail archive of the gcc-help@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: labels in inline asm


Clifford Wolf wrote:
Hi,

sorry for asking a probably dump question. I'm trying to port SDL_gfx
2.0.16 to ROCK Linux atm and running into a problem wich boils down to the
following test case:

--snip--
inline void foobar()
{
        asm volatile(
                "jz .foobar_label\n"
                ".foobar_label:\n"
                "nop"
        );
}


Probably you want something like:



asm volatile( "jz 1f\n" "1:\n" "nop" );


Look at the gas documentation for 'Local Labels'.


David Daney




int main()
{
        foobar();
        foobar();
        return 0;
}
--snap--

when compiled with optimization (inlining enabled) this sure results in an
assembler file with the .foobar_label defined three times:

	# gcc -O2 -c demo.c
	/tmp/ccx1Ibd9.s: Assembler messages:
	/tmp/ccx1Ibd9.s:29: Error: symbol `.foobar_label' is already defined
	/tmp/ccx1Ibd9.s:32: Error: symbol `.foobar_label' is already defined

maybe I'm just blind but I cant find anything in the gcc info page which
provides me with a mechanism for dynamically creating label prefixes or
something like that which would help me generating different labels in each
instances of the assembler template...

please help.

yours,
 - clifford



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