Mail Archives: djgpp/2000/04/13/10:55:46
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.
>> 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.
>"(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.
>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". With minor changes in main, that do
not touch your variables and your __asm__ (...), this will produce wrong
code.
> printf ("%d\n", d);
> return 0;
>}
--
Regards, Dieter
- Raw text -