Mail Archives: djgpp/2000/04/13/16:52:10
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 -