Feature request: Set the direction flag on x86/x64 register->register operations

Stefan Dösinger stefan@codeweavers.com
Tue Dec 9 12:52:00 GMT 2008


Hi,

Here is another version of my patch to set the direction flag on
register->register operations.

The main change is that it is now controlled by a per-instruction suffix
instead of a command line switch. Alexandre Julliard didn't like the idea of
the command line switch, he prefers gcc to control the bit. I have to modify
gcc to make it generate a "movl %edi, %edi" like Windows has it anyway, so
going this route is ok for me.

I added a test for this feature which specifically tests the instructions
that are important to me(mov %edi, %edi and mov %esp, %ebp) and a few more.
I ran the existing tests with the flag forced on for all instructions, and
they pass. There are a few false positives obviously because the patch
changes the encoding, but I checked all of those cases and the code works
correctly.

I verified the behavior against msvc, and it does set the flag on 8, 16 and
32 bit operations for sure. I didn't check 64 bit ones because I do not have
a 64 bit Windows installation to test, but this is moot now anyway because
gcc controls the flag. It doesn't affect this patch any longer.

On Mon, Dec 1, 2008 at 1:42 PM, H.J. Lu <hjl dot tools at gmail dot com>
wrote:
> Your new patch still doesn't handle movdqu and other instructions,
> like instructions with more than 1 source operands.
movdqu doesn't have the D flag set in the opcode table. Still my patch now
doesn't care about the operand types and just looks at the D flag and the
possible operands for the template, so from my code's point of view it works
with movdqu now.

As for more than 1 source operand: It doesn't seem to me that the existing
code that deals with the direction flag can works with such instructions. In
the branch that sets the flag only 2 operands are handled.

Thanks again for your help,
Stefan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: reverse.patch
Type: text/x-patch
Size: 8544 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20081209/890f1ecb/attachment.bin>


More information about the Binutils mailing list