From 3bc37d6e2a7b7eb0f6e31dfa333d244f52e8c4bc Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 2 Feb 2010 11:37:08 -0700 Subject: [PATCH] fix encoding of single byte register-to-memory moves on x86_64 We need to prefix instructions of the form "mov R,M" with a REX byte when R is %spl, %bpl, %sil, or %dil. Such moves are unencodable on 32-bit x86, and, because of the order in which we pick registers, pretty rare on 64-bit systems, which is why this took so long to notice. --- src/x86.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x86.cpp b/src/x86.cpp index 4021c86e6d..2d4d3e55f7 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -518,7 +518,7 @@ void maybeRex(Context* c, unsigned size, Assembler::Register* a, Assembler::Memory* b) { - maybeRex(c, size, a->low, b->index, b->base, false); + maybeRex(c, size, a->low, b->index, b->base, size == 1 and (a->low & 4)); } void