This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How reuse inline assembler conditionals?
- From: Andreas Jaeger <aj at suse dot de>
- To: "Benjamin K." <bkausbk at web dot de>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Mon, 30 Jun 2003 22:07:33 +0200
- Subject: Re: How reuse inline assembler conditionals?
- References: <002901c33f41$ce5e3350$0300a8c0@axp>
"Benjamin K." <bkausbk@web.de> writes:
> Example (need x86 compatible system):
>
> int Increment(int a){
> int tmp;
> asm volatile(
> "inc %0\n"
> : "=r" (tmp)
> : "0" (a)
> );
> return tmp;
> }
>
> x86 cpu will set conditional flags after using INC
> instruction, but this conditional will no be used by
> gcc, why?
gcc does not interpret the asm statement at all. It especially
considers condition codes as changes on most platforms.
> Gcc will produce something like:
>
> if (Increment(10)==0) {
> }
>
> mov eax,10
> inc eax
> test eax,eax
> jnz Lxx
>
> But "test eax,eax" isn't needed here.
> How can the function be declared to reuse asm conditional flags?
This is impossible AFAIK,
Andreas
--
Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
SuSE Linux AG, Deutschherrnstr. 15-19, 90429 Nürnberg, Germany
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126