delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/12/17:25:22

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: Wed, 12 Apr 2000 22:30:49 +0400
Organization: MTU-Intel ISP
Lines: 76
Message-ID: <38F4C0D9.C73A8E0A@mtu-net.ru>
References: <200004121649 DOT SAA12655 AT acp3bf DOT physik DOT rwth-aachen DOT de>
NNTP-Posting-Host: ppp101-181.dialup.mtu-net.ru
Mime-Version: 1.0
X-Trace: gavrilo.mtu.ru 955573830 76135 212.188.101.181 (12 Apr 2000 21:10:30 GMT)
X-Complaints-To: usenet-abuse AT mtu DOT ru
NNTP-Posting-Date: 12 Apr 2000 21:10:30 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

Hi Hans-Bernhard!

> > Well, it still isn't compiled with the -O2 switch, although it's okay w/o it.
> 
> I somewhat doubt that. This code compiles with no -O switch I've
> tried, on gcc-2.7.2. The error messages are always the same,
> regardless what optimization level I use, including no optimization at
> all (-O0). AFAICS, your code is plainly buggy. Here's the first
> offending fragment of source code:

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???

> And this is the assembly this converts into (fstcw is line 478 of
> Tmapping.s), after treatment by gcc-2.7.2:
> 
>     fstcw   (-192(%ebp))
>     fldcw   (%edx)
>     fldl    (%ecx)
> 
> And the error messages from the assembler about it are:
> 
> Tmapping.s:478: Error: Missing ')' assumed
> Tmapping.s:478: Error: Ignoring junk '(%ebp))' after expression
> 
> Obviously, the assembler doesn't consider (-192(%ebp)) to be a correct
> address operand for fstcw. Changing the code to
> 
>         fstcw %0
> 
> helps, but may not be the correct fix. The real assembly experts in the
> will have to answer that.

"(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.

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"
  );

  printf ("%d\n", d);
  return 0;
}
----------8<----------

I simply load the above program to RHIDE instead of the previous one (which I
posted to NG recently) and it compiles while the previos not. What do you think
of it, huh?

bye.
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