This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: x87 register clobber returns "unknown register name" error
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Hadrien Grasland <hadrien dot grasland at neel dot cnrs dot fr>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 15 Oct 2015 04:29:01 -0500
- Subject: Re: x87 register clobber returns "unknown register name" error
- Authentication-results: sourceware.org; auth=none
- References: <561F5CC7 dot 6020308 at neel dot cnrs dot fr>
On Thu, Oct 15, 2015 at 09:59:03AM +0200, Hadrien Grasland wrote:
> I am trying to write inline assembly code that uses the x86 floating
> point stack.
>
> As far as I understood
> https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Clobbers , the
> proper register clobber to use in this case is "st(x)". For example,
> this example from the documentation uses the "st(1)" clobber :
>
> asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
>
> However, if I try it on the trivial example attached, it fails with the
> following error.
>
> $ gcc-4.8 display_representation.c
> display_representation.c: In function âmainâ:
> display_representation.c:11:5: error: unknown register name âst(0)â in âasmâ
> asm volatile ("fstps (%1)" :
> ^
>
> What am I doing wrong ?
I'm not sure you can clobber stack regs at all. You could add it as
an output and just not use the result? Like
asm ("fyl2xp1" : "=t" (result), "=u" (dummy) : "0" (x), "1" (y));
Segher