This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
inline asm and status flags on x86
- To: gcc at gcc dot gnu dot org
- Subject: inline asm and status flags on x86
- From: Geoff Berry <geoffb at bops dot com>
- Date: Tue, 2 May 2000 13:01:43 -0400
Is there any way to specify that an asm statement reads the values of the
status flags on the x86? I have tried doing the following
asm volatile ("pushf; pop %0" : "=r" (flags) : "cc")
but that doesn't parse (I guess gcc expects an expression in parenthesis
after the "cc").
The reason I'm trying to express "cc" as being read by the asm statement is
so that the statement previous to the asm statement will produce flags. For
example
#define GET_STATUS_BITS(bits) asm volatile ("pushf; pop %0" : "=r"
(bits))
...
temp = x + y;
GET_STATUS_BITS(flags);
...
uses `leal' to add x and y, which produces no flags. Also, when optimizing,
the addition is not done at all (which seems fair since temp is not used
after the assignment).
I understand that there are better ways of doing this, but I am porting a
piece of software that calls GET_STATUS_BITS >500 times so I would prefer to
change the macro rather than all of the callers.
Hacks are welcome.