This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Address of label which is defined within an asm statement?
- From: David Fernandez <dfernandez at cct dot co dot uk>
- To: "Ioannis E. Venetis" <venetis at capsl dot udel dot edu>
- Cc: Ian Lance Taylor <iant at google dot com>, gcc-help at gcc dot gnu dot org
- Date: Wed, 28 Jun 2006 17:00:23 +0100
- Subject: Re: Address of label which is defined within an asm statement?
- References: <44A2960C.6040709@capsl.udel.edu>
On Wed, 2006-06-28 at 10:45 -0400, Ioannis E. Venetis wrote:
> Hello Ian,
>
> Thanks for answering this. I need to access the address of the label
> within the assembly code that I write. This means that I will have to
> check again the documentation of this architecture. I hope that I will
> find something.
>
> Best regards,
>
> Ioannis
>
> >
> > If you have a label in assembly code, and you want to use it in
> > assembly code, then you need to write whatever is appropriate for your
> > assembly language (e.g., "mov #MyLabel,r0"). That is not really a
> > compiler issue.
> >
> > If you have a label in assembly code, and you want to use it in C code
> > (e.g., by doing "goto MyLabel;"), then, sorry, you can't do that.
> >
> > Ian
To obtain the label address could be somthing like "mov #MyLabel, %<n>"
or "mov $MyLabel, %<n>" with <n> the output parameter number where you
get the result like : "=g" (MyLabelAddressVar).
To call a label from C code can be done using
goto *MyLabelAddressVar
I think that is a C Extension feature of gcc... You cold also pass the
value to another assembler block to do the trick, but that would be
architectural dependent some way...
"jmp *%0"
:
: "r" (MyLabelAddressVar)
David.