Fix opcode 0x6A (PUSH imm8)

This commit is contained in:
Jeff Parsons 2015-07-09 18:28:22 -07:00
commit 74bb240255
128 changed files with 138 additions and 129 deletions

View file

@ -3559,7 +3559,16 @@ X86CPU.prototype.popWord = function()
*/
X86CPU.prototype.pushWord = function(w)
{
this.assert((w & this.dataMask) == w);
/*
* This assertion is no longer valid, now that we've fixed opPUSH8() to use getIPDisp() instead of getIPByte(),
* thus sign-extending the byte as appropriate. And since sign-extension necessarily affects the entire 32-bit
* value, this assertion could fail when dataMask is 16 bits.
*
* this.assert((w & this.dataMask) == w);
*
* setWord() calls setShort() or setLong() as appropriate, and setShort() truncates incoming values, so the fact
* that any incoming signed values will not be truncated to 16 bits should not be a concern.
*/
this.regLSP = (this.regLSP - (I386? this.dataSize : 2))|0;
/*
* Properly comparing regLSP to regLSPLimitLow would normally require coercing both to unsigned

View file

@ -889,8 +889,8 @@ X86.fnIDIVw = function IDIVw(dst, src)
*/
X86.fnIMUL8 = function IMUL8(dst, src)
{
dst = this.getIPByte();
var result = (((src << 16) >> 16) * ((dst << 24) >> 24))|0;
dst = this.getIPDisp();
var result = (((src << 16) >> 16) * dst)|0;
if (result > 32767 || result < -32768) {
this.setCF(); this.setOF();

View file

@ -1432,7 +1432,7 @@ X86.opIMULn = function IMULn()
X86.opPUSH8 = function PUSH8()
{
if (BACKTRACK) this.backTrack.btiMemHi = 0;
this.pushWord(this.getIPByte());
this.pushWord(this.getIPDisp());
this.nStepCycles -= this.cycleCounts.nOpCyclesPushReg;
};