www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/13/16:52:10

From: "Alexei A. Frounze" <alex DOT fru AT mtu-net DOT ru>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: inefficiency of GCC output code & -O problem
Date: Thu, 13 Apr 2000 22:20:20 +0400
Organization: MTU-Intel ISP
Lines: 86
Message-ID: <38F60FE4.31BF32BB@mtu-net.ru>
References: <200004121649 DOT SAA12655 AT acp3bf DOT physik DOT rwth-aachen DOT de> <38F4C0D9 DOT C73A8E0A AT mtu-net DOT ru> <8d4rse DOT 3vvrn3d DOT 0 AT buerssner-17104 DOT user DOT cis DOT dfn DOT de>
NNTP-Posting-Host: ppp103-131.dialup.mtu-net.ru
Mime-Version: 1.0
X-Trace: gavrilo.mtu.ru 955656362 66507 212.188.103.131 (13 Apr 2000 20:06:02 GMT)
X-Complaints-To: usenet-abuse AT mtu DOT ru
NNTP-Posting-Date: 13 Apr 2000 20:06:02 GMT
X-Mailer: Mozilla 4.61 [en] (Win95; I)
X-Accept-Language: en,ru
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Dieter Buerssner wrote:
> 
> Alexei A. Frounze wrote:
> 
> >Better try it under 2.95.2. You'll encounter the same thingy.
> >AND THE CODE IS DEFINETELY NOT BUGGY!!! the program compiles and works
> >as it should. Don't you think if program works normally, source is okay
> >too? Or you think EXE is no made out of the source at all???
> 
> Why are you shouting. You'd do better, trying to understand
> the answers. Hans-Bernhard tried to be helpful, and your code
> is buggy. That it can compile to and executable and work as
> expected, is no proof at all.

OKay guys, please explain me what do you mean by BUGGY? Plese explain what
*exactly* do you mean. 

I've aways though that buggy code means program doesn't do what the programmer
wanted to because of his fault, i.e. he has put wrong algorithm instead of
proper one.

Maybe i don't understand you?

> 
> >> Obviously, the assembler doesn't consider (-192(%ebp)) to be a correct
> >> address operand for fstcw. Changing the code to
> 
> And the assembler is obviously correct to show an error.
> 
> >>         fstcw %0
> 
> IHMO, this alone won't work though.

As far as I remember it didn't work with (). But parhaps there is no difference
and the program works normally.

> >"(address)" means reference to RAM in AT&T syntax, so I always keep
> >these parentheses. IMO GCC doesn't convert inline ASM to the ASM
> >recognized by AS.
> 
> Gcc will do fine, with correct inline code. Also your use of
> references throughout your code will make many code snippets
> less efficient, than the straightforward C implementation.

I'm not sure. Btw, there is CPU and FPU code mixed. Since they work independant
(whyle FPU is computing floating point, CPU is computing memory address),
difference is unnoticeable.

> 
> >Btw, the following program compiles both with -O2 and w/o -O at all:
> >----------8<----------
> >#include <stdlib.h>
> >#include <stdio.h>
> >#include <conio.h>
> >
> >int main() {
> >  int a=1, b=2, c=3, d;
> >
> >  clrscr();
> >
> >  __asm__ __volatile__ ("
> >    fstcw (%3)
> >    movl  (%0), %%eax
> >    addl  (%1), %%eax
> >    addl  (%2), %%eax
> >    movl  %%eax, (%3)"
> >  :
> >  : "g" (&a), "g" (&b), "g" (&c), "g" (&d)
> >  : "eax"
> >  );
> 
> And this is as wrong, as the other code. If it works as expected,
> you are just lucky, that gcc has four free registers, so that
> all "g" are actually treated as "r". 

It must notify me if it lacks of free registers. Don't you think?
Btw, this program works as it should. Try yourself. I bet you'll get the same
result as mine (if you use the latest GCC).

thanks,
Alexei A. Frounze
-----------------------------------------
Homepage: http://alexfru.chat.ru
Mirror:   http://members.xoom.com/alexfru


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019