Fix 32-bit segment-register MOVs (they write 32 bits to a register, but only 16 bits to memory)

This commit is contained in:
Jeff Parsons 2015-05-08 13:36:02 -07:00 committed by jeffpar
commit 07530c7e58
3 changed files with 24 additions and 16 deletions

View file

@ -1702,6 +1702,14 @@ X86.fnMOVn = function MOVn(dst, src)
*/
X86.fnMOVxx = function MOVxx(dst, src)
{
if (this.regEAWrite !== X86.ADDR_INVALID) {
/*
* When a 32-bit OPERAND size is in effect, opMOVwsr() will write 32 bits (zero-extended) if the destination
* is a register, but only 16 bits if the destination is memory. The only other caller, opMOVrc(), is not
* affected, because it writes only to register destinations.
*/
this.setDataSize(2);
}
return X86.fnMOV.call(this, dst, this.regXX);
};

View file

@ -2098,10 +2098,6 @@ X86.opMOVwsr = function MOVwsr()
}
/*
* Like other MOV operations, the destination does not need to be read, just written.
*
* TODO: Confirm this instruction's behavior on the 80386; ie, if a 32-bit OPERAND size is
* in effect, does it still write only 16 bits? If so, we must add a setDataSize(2) override.
* Confirm for both register and memory destinations.
*/
this.opFlags |= X86.OPFLAG.NOREAD;
this.aOpModMemWord[bModRM].call(this, X86.fnMOVxx);