This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: FW: Inline Assembler for PPC
- From: "Martin Payne" <martin at microcosm dot co dot uk>
- To: "Ian Lance Taylor" <ian at airs dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Wed, 22 Dec 2004 17:11:43 -0000
- Subject: RE: FW: Inline Assembler for PPC
Well, that same code does not work for me.
If I have this code:
main(int argc, char* argv[]) {
int i;
asm("stw %%r3, %0" : : "r" (i));
return 0;
}
and compile it by running:
gcc mytest.c
it gives the following output:
/var/tmp//ccOB6jdo.s:16:Parameter syntax error (parameter 1)
I am using gcc 3.3 20030304 by Apple, build 1666.
Thanks for showing an interest.
> -----Original Message-----
> From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
> Behalf Of Ian Lance Taylor
> Sent: 22 December 2004 16:26
> To: Martin Payne
> Cc: gcc-help@gcc.gnu.org
> Subject: Re: FW: Inline Assembler for PPC
>
>
>
> > I have read that but it does not tell me how to specify a
> register in the assembler command.
> >
> > I want to get the value of r3 into my local C variable: i.
> >
> > I have tried: asm ("stw %%r3, %0" : : "r" (i) : "r3")
> >
> > However, that does not compile giving error "parameter syntax
> error (parameter 1)".
>
> First, there is no need to put "r3" in the list of clobbered
> registers, as your instruction does not clobber r3.
>
> Second, please send a complete example. I tried this, and it appeared
> to work fine.
>
> int foo (int i)
> {
> asm ("stw %%r3, %0" : : "r" (i));
> }
>
> Ian
>
> ---
>
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004
>
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004