This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

inline asm and status flags on x86


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]