Mail Archives: djgpp/2000/03/21/15:55:06
Robert Bruce wrote:
>I really don't know if I am lying to the compiler or not, I "do" know
>that the patch in the FAQ produces code that produces an immediate GPF
>on my system. I "do" know that the code I listed in my initial reply
>produces code that executes correctly on my system. Don't know what
>else I can say.
It seems, that the original patch from the FAQ is wrong. When you
say, that your code works, it is quite probable that in the original
patch, the renumbering of the registers was forgotten. %4 should
have been changed to %5 etc, because there is one new output operand.
Now, you have commented this new output operand out. The numbering
is correct again. But gcc cannot know anymore, that the input shift
in register ecx will be clobbered. So, when gcc needs shift again,
it can assume, it is still in register ecx, but it isn't.
The produced code may work anyway, and it may even depend on
compiler options. With one option gcc may assign shift to the register
ecx outside of the loop -> failure. This is at least my interpretation
of the gcc manual.
From the gcc manual in "Assembler instructions with C operands":
: It is an error for a clobber description to overlap an input or
:output operand (for example, an operand describing a register class
:with one member, mentioned in the clobber list). Most notably, it is
:invalid to describe that an input operand is modified, but unused as
:output. It has to be specified as an input and output operand anyway.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:Note that if there are only unused output operands, you will then also
:need to specify `volatile' for the `asm' construct, as described below.
[The anyway seems misleading to me]
This paragraph is not in older versions of the gcc manual, and also
older version of gcc behave different (you can put the input
register into the clobber list). Many programmers, including
the GRX programmer(s) and the Linux kernel developers, relied on
the old behaviour ...
[...]
>As a general note if I trust the tool (a sometimes mistaken
>assumption) just removing an offending statement frequently results in
>correct behaviour.
It doesn't make any sense to me, to just remove offending statements.
Regards,
Dieter
- Raw text -