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: Ian Lance Taylor <ian at airs dot com>
- To: "Martin Payne" <martin at microcosm dot co dot uk>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: 22 Dec 2004 15:43:50 -0500
- Subject: Re: FW: Inline Assembler for PPC
- References: <003301c4e849$4f1ddbb0$0401a8c0@martin>
"Martin Payne" <martin@microcosm.co.uk> writes:
> 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.
OK, that error is coming from the assembler, not the compiler. Note
that the file name is the .s file, not the .c file.
First I'll note that the error message is not from the mainline GNU
assembler. My understanding is that Apple uses an assembler based on
very very old version of the GNU assembler. I don't have access to
any Apple development systems.
That said, the above C source code will generate something like this
in the assembler file (you can check yourself by using the
--save-temps option to get the assembler file):
stw %r3, 3
That of course won't work. The stw instruction doesn't expect the
second parameter to be a register.
Ian