Dynamically switch getWord/setWord based on current dataSize

This commit is contained in:
Jeff Parsons 2015-01-26 17:29:19 -08:00 committed by jeffpar
commit 84572178c5
14 changed files with 1966 additions and 1958 deletions

View file

@ -360,50 +360,50 @@ function genMode(a, d, w, mrm, sGroup, sRO) {
else {
switch (reg) {
case 0:
sRegGet = "this.regEAX & this.opMask";
sRegSet = "this.regEAX = (this.regEAX & ~this.opMask) | ";
sRegGet = "this.regEAX & this.dataMask";
sRegSet = "this.regEAX = (this.regEAX & ~this.dataMask) | ";
sRegBTLo = "this.backTrack.btiAL";
sRegBTHi = "this.backTrack.btiAH";
break;
case 1:
sRegGet = "this.regECX & this.opMask";
sRegSet = "this.regECX = (this.regECX & ~this.opMask) | ";
sRegGet = "this.regECX & this.dataMask";
sRegSet = "this.regECX = (this.regECX & ~this.dataMask) | ";
sRegBTLo = "this.backTrack.btiCL";
sRegBTHi = "this.backTrack.btiCH";
break;
case 2:
sRegGet = "this.regEDX & this.opMask";
sRegSet = "this.regEDX = (this.regEDX & ~this.opMask) | ";
sRegGet = "this.regEDX & this.dataMask";
sRegSet = "this.regEDX = (this.regEDX & ~this.dataMask) | ";
sRegBTLo = "this.backTrack.btiDL";
sRegBTHi = "this.backTrack.btiDH";
break;
case 3:
sRegGet = "this.regEBX & this.opMask";
sRegSet = "this.regEBX = (this.regEBX & ~this.opMask) | ";
sRegGet = "this.regEBX & this.dataMask";
sRegSet = "this.regEBX = (this.regEBX & ~this.dataMask) | ";
sRegBTLo = "this.backTrack.btiBL";
sRegBTHi = "this.backTrack.btiBH";
break;
case 4:
sRegGet = "this.regESP & this.opMask";
sRegSet = "this.regESP = (this.regESP & ~this.opMask) | ";
sRegGet = "this.regESP & this.dataMask";
sRegSet = "this.regESP = (this.regESP & ~this.dataMask) | ";
sRegBTLo = "X86.BACKTRACK.SP_LO";
sRegBTHi = "X86.BACKTRACK.SP_HI";
break;
case 5:
sRegGet = "this.regEBP & this.opMask";
sRegSet = "this.regEBP = (this.regEBP & ~this.opMask) | ";
sRegGet = "this.regEBP & this.dataMask";
sRegSet = "this.regEBP = (this.regEBP & ~this.dataMask) | ";
sRegBTLo = "this.backTrack.btiBPLo";
sRegBTHi = "this.backTrack.btiBPHi";
break;
case 6:
sRegGet = "this.regESI & this.opMask";
sRegSet = "this.regESI = (this.regESI & ~this.opMask) | ";
sRegGet = "this.regESI & this.dataMask";
sRegSet = "this.regESI = (this.regESI & ~this.dataMask) | ";
sRegBTLo = "this.backTrack.btiSILo";
sRegBTHi = "this.backTrack.btiSIHi";
break;
case 7:
sRegGet = "this.regEDI & this.opMask";
sRegSet = "this.regEDI = (this.regEDI & ~this.opMask) | ";
sRegGet = "this.regEDI & this.dataMask";
sRegSet = "this.regEDI = (this.regEDI & ~this.dataMask) | ";
sRegBTLo = "this.backTrack.btiDILo";
sRegBTHi = "this.backTrack.btiDIHi";
break;
@ -635,50 +635,50 @@ function genMode(a, d, w, mrm, sGroup, sRO) {
else {
switch (r_m) {
case 0:
sModRegGet = "this.regEAX & this.opMask";
sModRegSet = "this.regEAX = (this.regEAX & ~this.opMask) | ";
sModRegGet = "this.regEAX & this.dataMask";
sModRegSet = "this.regEAX = (this.regEAX & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiAL";
sModRegBTHi = "this.backTrack.btiAH";
break;
case 1:
sModRegGet = "this.regECX & this.opMask";
sModRegSet = "this.regECX = (this.regECX & ~this.opMask) | ";
sModRegGet = "this.regECX & this.dataMask";
sModRegSet = "this.regECX = (this.regECX & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiCL";
sModRegBTHi = "this.backTrack.btiCH";
break;
case 2:
sModRegGet = "this.regEDX & this.opMask";
sModRegSet = "this.regEDX = (this.regEDX & ~this.opMask) | ";
sModRegGet = "this.regEDX & this.dataMask";
sModRegSet = "this.regEDX = (this.regEDX & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiDL";
sModRegBTHi = "this.backTrack.btiDH";
break;
case 3:
sModRegGet = "this.regEBX & this.opMask";
sModRegSet = "this.regEBX = (this.regEBX & ~this.opMask) | ";
sModRegGet = "this.regEBX & this.dataMask";
sModRegSet = "this.regEBX = (this.regEBX & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiBL";
sModRegBTHi = "this.backTrack.btiBH";
break;
case 4:
sModRegGet = "this.regESP & this.opMask";
sModRegSet = "this.regESP = (this.regESP & ~this.opMask) | ";
sModRegGet = "this.regESP & this.dataMask";
sModRegSet = "this.regESP = (this.regESP & ~this.dataMask) | ";
sModRegBTLo = "X86.BACKTRACK.SP_LO";
sModRegBTHi = "X86.BACKTRACK.SP_HI";
break;
case 5:
sModRegGet = "this.regEBP & this.opMask";
sModRegSet = "this.regEBP = (this.regEBP & ~this.opMask) | ";
sModRegGet = "this.regEBP & this.dataMask";
sModRegSet = "this.regEBP = (this.regEBP & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiBPLo";
sModRegBTHi = "this.backTrack.btiBPHi";
break;
case 6:
sModRegGet = "this.regESI & this.opMask";
sModRegSet = "this.regESI = (this.regESI & ~this.opMask) | ";
sModRegGet = "this.regESI & this.dataMask";
sModRegSet = "this.regESI = (this.regESI & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiSILo";
sModRegBTHi = "this.backTrack.btiSIHi";
break;
case 7:
sModRegGet = "this.regEDI & this.opMask";
sModRegSet = "this.regEDI = (this.regEDI & ~this.opMask) | ";
sModRegGet = "this.regEDI & this.dataMask";
sModRegSet = "this.regEDI = (this.regEDI & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiDILo";
sModRegBTHi = "this.backTrack.btiDIHi";
break;
@ -892,50 +892,50 @@ function genMode(a, d, w, mrm, sGroup, sRO) {
else {
switch (r_m) {
case 0:
sModRegGet = "this.regEAX & this.opMask";
sModRegSet = "this.regEAX = (this.regEAX & ~this.opMask) | ";
sModRegGet = "this.regEAX & this.dataMask";
sModRegSet = "this.regEAX = (this.regEAX & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiAL";
sModRegBTHi = "this.backTrack.btiAH";
break;
case 1:
sModRegGet = "this.regECX & this.opMask";
sModRegSet = "this.regECX = (this.regECX & ~this.opMask) | ";
sModRegGet = "this.regECX & this.dataMask";
sModRegSet = "this.regECX = (this.regECX & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiCL";
sModRegBTHi = "this.backTrack.btiCH";
break;
case 2:
sModRegGet = "this.regEDX & this.opMask";
sModRegSet = "this.regEDX = (this.regEDX & ~this.opMask) | ";
sModRegGet = "this.regEDX & this.dataMask";
sModRegSet = "this.regEDX = (this.regEDX & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiDL";
sModRegBTHi = "this.backTrack.btiDH";
break;
case 3:
sModRegGet = "this.regEBX & this.opMask";
sModRegSet = "this.regEBX = (this.regEBX & ~this.opMask) | ";
sModRegGet = "this.regEBX & this.dataMask";
sModRegSet = "this.regEBX = (this.regEBX & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiBL";
sModRegBTHi = "this.backTrack.btiBH";
break;
case 4:
sModRegGet = "this.regESP & this.opMask";
sModRegSet = "this.regESP = (this.regESP & ~this.opMask) | ";
sModRegGet = "this.regESP & this.dataMask";
sModRegSet = "this.regESP = (this.regESP & ~this.dataMask) | ";
sModRegBTLo = "X86.BACKTRACK.SP_LO";
sModRegBTHi = "X86.BACKTRACK.SP_HI";
break;
case 5:
sModRegGet = "this.regEBP & this.opMask";
sModRegSet = "this.regEBP = (this.regEBP & ~this.opMask) | ";
sModRegGet = "this.regEBP & this.dataMask";
sModRegSet = "this.regEBP = (this.regEBP & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiBPLo";
sModRegBTHi = "this.backTrack.btiBPHi";
break;
case 6:
sModRegGet = "this.regESI & this.opMask";
sModRegSet = "this.regESI = (this.regESI & ~this.opMask) | ";
sModRegGet = "this.regESI & this.dataMask";
sModRegSet = "this.regESI = (this.regESI & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiSILo";
sModRegBTHi = "this.backTrack.btiSIHi";
break;
case 7:
sModRegGet = "this.regEDI & this.opMask";
sModRegSet = "this.regEDI = (this.regEDI & ~this.opMask) | ";
sModRegGet = "this.regEDI & this.dataMask";
sModRegSet = "this.regEDI = (this.regEDI & ~this.dataMask) | ";
sModRegBTLo = "this.backTrack.btiDILo";
sModRegBTHi = "this.backTrack.btiDIHi";
break;

View file

@ -502,17 +502,17 @@ Bus.prototype.getByteDirect = function(addr)
};
/**
* getWord(addr)
* getShort(addr)
*
* The CPU could use this, but the CPU also needs to update cycle counts, along with BACKTRACK states.
* There may also be a slight performance advantage calling its own getWord() method vs. calling through another
* There may also be a slight performance advantage calling its own getShort() method vs. calling through another
* object (ie, the Bus object).
*
* @this {Bus}
* @param {number} addr is a physical (non-segmented) address
* @return {number} word (16-bit) value at that address
*/
Bus.prototype.getWord = function(addr)
Bus.prototype.getShort = function(addr)
{
var off = addr & this.blockLimit;
var iBlock = (addr & this.addrMask) >> this.blockShift;
@ -523,15 +523,15 @@ Bus.prototype.getWord = function(addr)
};
/**
* getWordDirect(addr)
* getShortDirect(addr)
*
* This is useful for the Debugger and other components that want to bypass getWord() breakpoint detection.
* This is useful for the Debugger and other components that want to bypass getShort() breakpoint detection.
*
* @this {Bus}
* @param {number} addr is a physical (non-segmented) address
* @return {number} word (16-bit) value at that address
*/
Bus.prototype.getWordDirect = function(addr)
Bus.prototype.getShortDirect = function(addr)
{
var off = addr & this.blockLimit;
var iBlock = (addr & this.addrMask) >> this.blockShift;
@ -614,17 +614,17 @@ Bus.prototype.setByteDirect = function(addr, b)
};
/**
* setWord(addr, w)
* setShort(addr, w)
*
* The CPU could use this, but the CPU also needs to update cycle counts, along with BACKTRACK states.
* There may also be a slight performance advantage calling its own setWord() method vs. calling through another
* There may also be a slight performance advantage calling its own setShort() method vs. calling through another
* object (ie, the Bus object).
*
* @this {Bus}
* @param {number} addr is a physical (non-segmented) address
* @param {number} w is the word (16-bit) value to write (we truncate it to 16 bits to be safe)
*/
Bus.prototype.setWord = function(addr, w)
Bus.prototype.setShort = function(addr, w)
{
var off = addr & this.blockLimit;
var iBlock = (addr & this.addrMask) >> this.blockShift;
@ -637,7 +637,7 @@ Bus.prototype.setWord = function(addr, w)
};
/**
* setWordDirect(addr, w)
* setShortDirect(addr, w)
*
* This is useful for the Debugger and other components that want to bypass breakpoint detection AND read-only
* memory protection (for example, this is an interface the ROM component could use to initialize ROM contents).
@ -646,7 +646,7 @@ Bus.prototype.setWord = function(addr, w)
* @param {number} addr is a physical (non-segmented) address
* @param {number} w is the word (16-bit) value to write (we truncate it to 16 bits to be safe)
*/
Bus.prototype.setWordDirect = function(addr, w)
Bus.prototype.setShortDirect = function(addr, w)
{
var off = addr & this.blockLimit;
var iBlock = (addr & this.addrMask) >> this.blockShift;

View file

@ -1336,8 +1336,8 @@ if (DEBUGGER) {
while (seg) {
var aAddr = this.newAddr(0, seg);
var bSig = this.getByte(aAddr, 1);
var wPID = this.getWord(aAddr, 2);
var wParas = this.getWord(aAddr, 5);
var wPID = this.getShort(aAddr, 2);
var wParas = this.getShort(aAddr, 5);
if (bSig != 0x4D && bSig != 0x5A) break;
this.println(str.toHexAddr(0, seg) + ": '" + String.fromCharCode(bSig) + "' PID=" + str.toHexWord(wPID) + " LEN=" + str.toHexWord(wParas) + ' "' + this.dumpSZ(aAddr, 8) + '"');
seg += 1 + wParas;
@ -1480,7 +1480,7 @@ if (DEBUGGER) {
for (var sField in Debugger.aTSSFields) {
var off = Debugger.aTSSFields[sField];
var ch = (sField.length < 8? ' ' : '');
var w = this.bus.getWordDirect(seg.base + off);
var w = this.bus.getShortDirect(seg.base + off);
if (sDump) sDump += '\n';
sDump += str.toHexWord(off) + " " + sField + ": " + ch + str.toHexWord(w);
}
@ -2344,19 +2344,19 @@ if (DEBUGGER) {
};
/**
* getWord(aAddr, inc)
* getShort(aAddr, inc)
*
* @this {Debugger}
* @param {Array} aAddr
* @param {number} [inc]
* @return {number}
*/
Debugger.prototype.getWord = function(aAddr, inc)
Debugger.prototype.getShort = function(aAddr, inc)
{
var w = 0xffff;
var addr = this.getAddr(aAddr, false, 1);
if (addr >= 0) {
w = this.bus.getWordDirect(addr);
w = this.bus.getShortDirect(addr);
this.assert((w == (w & 0xffff)), "invalid word (" + w + ") at address: " + this.hexAddr(aAddr));
if (inc !== undefined) this.incAddr(aAddr, inc);
}
@ -2386,18 +2386,18 @@ if (DEBUGGER) {
};
/**
* setWord(aAddr, w, inc)
* setShort(aAddr, w, inc)
*
* @this {Debugger}
* @param {Array} aAddr
* @param {number} w
* @param {number} [inc]
*/
Debugger.prototype.setWord = function(aAddr, w, inc)
Debugger.prototype.setShort = function(aAddr, w, inc)
{
var addr = this.getAddr(aAddr, true, 1);
if (addr >= 0) {
this.bus.setWordDirect(addr, w);
this.bus.setShortDirect(addr, w);
if (inc !== undefined) this.incAddr(aAddr, inc);
this.cpu.updateCPU();
}
@ -2734,7 +2734,7 @@ if (DEBUGGER) {
sOperand = this.getImmediateOperand(type, aAddr);
}
else if (typeMode == Debugger.TYPE_IMMOFF) {
sOperand = "[" + str.toHexWord(this.getWord(aAddr, 2)) + "]";
sOperand = "[" + str.toHexWord(this.getShort(aAddr, 2)) + "]";
}
else if (typeMode == Debugger.TYPE_IMMREL) {
var disp;
@ -2743,7 +2743,7 @@ if (DEBUGGER) {
disp = ((disp << 24) >> 24);
}
else {
disp = this.getWord(aAddr, 2);
disp = this.getShort(aAddr, 2);
}
var offset = (aAddr[0] + disp) & 0xffff;
var aSymbol = this.findSymbolAtAddr(this.newAddr(offset, aAddr[1]));
@ -2820,10 +2820,10 @@ if (DEBUGGER) {
break;
case Debugger.TYPE_WORD:
case Debugger.TYPE_VWORD:
sOperand = str.toHexWord(this.getWord(aAddr, 2));
sOperand = str.toHexWord(this.getShort(aAddr, 2));
break;
case Debugger.TYPE_FARP:
sOperand = this.hexAddr(this.newAddr(this.getWord(aAddr, 2), this.getWord(aAddr, 2)));
sOperand = this.hexAddr(this.newAddr(this.getShort(aAddr, 2), this.getShort(aAddr, 2)));
break;
default:
sOperand = "imm(" + str.toHexWord(type) + ")";
@ -2868,7 +2868,7 @@ if (DEBUGGER) {
if (bMod < 3) {
var disp;
if (!bMod && bRM == 6) {
disp = this.getWord(aAddr, 2);
disp = this.getShort(aAddr, 2);
sOperand = str.toHexWord(disp);
}
else {
@ -2884,7 +2884,7 @@ if (DEBUGGER) {
}
}
else if (bMod == 2) {
disp = this.getWord(aAddr, 2);
disp = this.getShort(aAddr, 2);
sOperand += "+" + str.toHexWord(disp);
}
}

View file

@ -890,7 +890,7 @@ Disk.prototype.doneLoad = function(sDiskFile, sDiskData, nErrorCode, sDiskPath)
* 0-based "physical" sector numbers for disk-relative block addresses (aka PBAs or Physical Block Addresses).
*
* Also, our use of the term LBA differs from that of more modern disk controllers; in the pre-modern world
* of PCjs, what we call PBA numbers are what those controllers would call LBA numbers.
* of PCjs, what we call PBA numbers are what those controllers would later call LBA numbers.
*
* @this {Disk}
*/
@ -916,7 +916,7 @@ Disk.prototype.buildFileTable = function()
* form of seek(). For development purposes, that was fine, but... TODO: Eventually change buildFileTable()
* to use async I/O.
*/
if (this.fRemote) this.log("ignore synchronous XMLHttpRequest warnings here for now....");
if (this.fRemote) this.log("ignore any synchronous XMLHttpRequest warnings here (for now)");
var sectorBoot = this.getSector(0);
if (!sectorBoot) {

View file

@ -177,7 +177,7 @@ RAM.prototype.reset = function() {
* memory storage tests. See rom.js for all RBDA definitions.
*/
if (MAXDEBUG) this.status("ROM BIOS memory test has been disabled");
this.bus.setWordDirect(ROM.BIOS.RESET_FLAG, ROM.BIOS.RESET_FLAG_WARMBOOT);
this.bus.setShortDirect(ROM.BIOS.RESET_FLAG, ROM.BIOS.RESET_FLAG_WARMBOOT);
}
if (this.chipset) this.chipset.addCMOSMemory(this.addrRAM, this.sizeRAM);
} else {

View file

@ -2577,7 +2577,7 @@ Video.prototype.reset = function()
bChar = dataRandom & 0xff;
bAttr = ((dataRandom & 0x100)? (Video.ATTRS.FGND_WHITE | Video.ATTRS.BGND_BLACK) : (Video.ATTRS.FGND_BLACK | Video.ATTRS.BGND_WHITE)) | ((Video.ATTRS.FGND_BRIGHT /* | Video.ATTRS.BGND_BLINK */) & (dataRandom >> 8));
}
this.bus.setWordDirect(addrScreen, bChar | (bAttr << 8));
this.bus.setShortDirect(addrScreen, bChar | (bAttr << 8));
}
this.updateScreen(true);
}
@ -4201,7 +4201,7 @@ Video.prototype.updateScreenText = function(addrScreen, addrScreenLimit, iCell,
}
addr = addrScreen + (iCell << 1);
while (addr < addrScreenLimit && iCell < nCells) {
data = this.bus.getWordDirect(addr);
data = this.bus.getShortDirect(addr);
data |= dataDraw;
if (data & dataBlink) {
this.cBlinkVisible++;
@ -4250,7 +4250,7 @@ Video.prototype.updateScreenGraphicsCGA = function(addrScreen, addrScreenLimit)
var x = 0, y = 0;
var xDirty = this.nCols, xMaxDirty = 0, yDirty = this.nRows, yMaxDirty = 0;
while (addr < addrScreenLimit) {
data = this.bus.getWordDirect(addr);
data = this.bus.getShortDirect(addr);
this.assert(iCell < this.aCellCache.length);
dataCache = this.aCellCache[iCell];
if (dataCache === data) {

View file

@ -962,8 +962,8 @@ X86CPU.prototype.resetRegs = function()
* for isolating the (src) bits of an OPERAND and clearing the (dst) bits of an OPERAND. These are reset to
* their segCS counterparts at the start of every new instruction, but are also set here for documentation purposes.
*/
this.opSize = this.segCS.opSize;
this.opMask = this.segCS.opMask;
this.dataSize = this.segCS.dataSize;
this.dataMask = this.segCS.dataMask;
/*
* Similarly, the following contain the (default) ADDRESS size (0 for 16 bits, 1 for 32 bits), and the corresponding
@ -985,17 +985,25 @@ X86CPU.prototype.resetRegs = function()
*/
/*
* The memory dispatch tables; opMem refers to the active set, based on the current OPERAND size (opSize),
* which is based foremost on segCS.opSize, but can also be overridden by an OPERAND size instruction prefix.
* The memory dispatch tables; opMem refers to the active set, based on the current OPERAND size (dataSize),
* which is based foremost on segCS.dataSize, but can also be overridden by an OPERAND size instruction prefix.
*/
this.aaOpMem = new Array(2);
this.aaOpMem[0] = {
getByte: this.getByte,
getWord: this.getWord,
setByte: this.setByte,
setWord: this.setWord
getByte: this.getByte.bind(this),
getWord: this.getShort.bind(this),
setByte: this.setByte.bind(this),
setWord: this.setShort.bind(this)
};
this.opMem = this.aaOpMem[this.segCS.opSize];
if (I386) {
this.aaOpMem[1] = {
getByte: this.getByte.bind(this),
getWord: this.getLong.bind(this),
setByte: this.setByte.bind(this),
setWord: this.setLong.bind(this)
};
}
this.opMem = this.aaOpMem[this.segCS.dataSize];
/*
* The ModRM dispatch tables; opMod refers to the active set, based on the current ADDRESS size (addrSize),
@ -1875,13 +1883,13 @@ X86CPU.prototype.getByte = function(addr)
};
/**
* getWord(addr)
* getShort(addr)
*
* @this {X86CPU}
* @param {number} addr is a physical (non-segmented) address
* @return {number} word (16-bit) value at that address
*/
X86CPU.prototype.getWord = function(addr)
X86CPU.prototype.getShort = function(addr)
{
var off = addr & this.blockLimit;
var iBlock = (addr & this.addrMemMask) >> this.blockShift;
@ -1937,13 +1945,13 @@ X86CPU.prototype.setByte = function(addr, b)
};
/**
* setWord(addr, w)
* setShort(addr, w)
*
* @this {X86CPU}
* @param {number} addr is a physical (non-segmented) address
* @param {number} w is the word (16-bit) value to write (which we truncate to 16 bits to be safe)
*/
X86CPU.prototype.setWord = function(addr, w)
X86CPU.prototype.setShort = function(addr, w)
{
var off = addr & this.blockLimit;
var iBlock = (addr & this.addrMemMask) >> this.blockShift;
@ -2024,9 +2032,9 @@ X86CPU.prototype.getEAByte = function(seg, off)
X86CPU.prototype.getEAWord = function(seg, off)
{
this.segEA = seg;
this.regEA = seg.checkRead(this.offEA = off, 1);
this.regEA = seg.checkRead(this.offEA = off, 1 + this.dataSize + this.dataSize);
if (this.opFlags & X86.OPFLAG.NOREAD) return 0;
var w = this.getWord(this.regEA);
var w = this.opMem.getWord(this.regEA);
if (BACKTRACK) {
this.backTrack.btiEALo = this.backTrack.btiMemLo;
this.backTrack.btiEAHi = this.backTrack.btiMemHi;
@ -2063,9 +2071,9 @@ X86CPU.prototype.modEAByte = function(seg, off)
X86CPU.prototype.modEAWord = function(seg, off)
{
this.segEA = seg;
this.regEAWrite = this.regEA = seg.checkRead(this.offEA = off, 1);
this.regEAWrite = this.regEA = seg.checkRead(this.offEA = off, 1 + this.dataSize + this.dataSize);
if (this.opFlags & X86.OPFLAG.NOREAD) return 0;
var w = this.getWord(this.regEA);
var w = this.opMem.getWord(this.regEA);
if (BACKTRACK) {
this.backTrack.btiEALo = this.backTrack.btiMemLo;
this.backTrack.btiEAHi = this.backTrack.btiMemHi;
@ -2195,7 +2203,7 @@ X86CPU.prototype.setEAWord = function(w)
this.backTrack.btiMemLo = this.backTrack.btiEALo;
this.backTrack.btiMemHi = this.backTrack.btiEAHi;
}
this.setWord(this.segEA.checkWrite(this.offEA, 1), w);
this.opMem.setWord(this.segEA.checkWrite(this.offEA, 1), w);
};
/**
@ -2225,7 +2233,7 @@ X86CPU.prototype.getSOByte = function(seg, off)
*/
X86CPU.prototype.getSOWord = function(seg, off)
{
return this.getWord(seg.checkRead(off, 1));
return this.opMem.getWord(seg.checkRead(off, 1 + this.dataSize + this.dataSize));
};
/**
@ -2255,7 +2263,7 @@ X86CPU.prototype.setSOByte = function(seg, off, b)
*/
X86CPU.prototype.setSOWord = function(seg, off, w)
{
this.setWord(seg.checkWrite(off, 1), w);
this.opMem.setWord(seg.checkWrite(off, 1), w);
};
/**
@ -2398,7 +2406,7 @@ X86CPU.prototype.getIPByte = function()
{
var b = (PREFETCH? this.getBytePrefetch(this.regLIP) : this.getByte(this.regLIP));
if (BACKTRACK) this.bus.updateBackTrackCode(this.regLIP, this.backTrack.btiMemLo);
this.regLIP = this.segCS.base + (this.regEIP = (this.regEIP + 1) & this.addrMask); // this.advanceIP(1)
this.regLIP = this.segCS.base + (this.regEIP = (this.regEIP + 1) & this.addrMask);
return b;
};
@ -2412,7 +2420,7 @@ X86CPU.prototype.getIPDisp = function()
{
var b = ((PREFETCH? this.getBytePrefetch(this.regLIP) : this.getByte(this.regLIP)) << 24) >> 24;
if (BACKTRACK) this.bus.updateBackTrackCode(this.regLIP, this.backTrack.btiMemLo);
this.regLIP = this.segCS.base + (this.regEIP = (this.regEIP + 1) & this.addrMask); // this.advanceIP(1)
this.regLIP = this.segCS.base + (this.regEIP = (this.regEIP + 1) & this.addrMask);
return b & this.addrMask;
};
@ -2424,12 +2432,12 @@ X86CPU.prototype.getIPDisp = function()
*/
X86CPU.prototype.getIPWord = function()
{
var w = (PREFETCH? this.getWordPrefetch(this.regLIP) : this.getWord(this.regLIP));
var w = (PREFETCH? this.getWordPrefetch(this.regLIP) : this.opMem.getWord(this.regLIP));
if (BACKTRACK) {
this.bus.updateBackTrackCode(this.regLIP, this.backTrack.btiMemLo);
this.bus.updateBackTrackCode(this.regLIP + 1, this.backTrack.btiMemHi);
}
this.regLIP = this.segCS.base + (this.regEIP = (this.regEIP + 2) & this.addrMask); // this.advanceIP(2)
this.regLIP = this.segCS.base + (this.regEIP = (this.regEIP + (2 << this.dataSize)) & this.addrMask);
return w;
};
@ -2451,12 +2459,12 @@ X86CPU.prototype.getSIBAddr = function(mod)
* popWord()
*
* @this {X86CPU}
* @return {number} word popped from the current SP; SP increased by 2
* @return {number} word popped from the current SP; SP increased by 2 or 4
*/
X86CPU.prototype.popWord = function()
{
var regESP = this.regESP;
this.regESP = (this.regESP + 2) & this.addrMask;
this.regESP = (this.regESP + (2 << this.dataSize)) & this.addrMask;
return this.getSOWord(this.segSS, regESP);
};
@ -2464,12 +2472,12 @@ X86CPU.prototype.popWord = function()
* pushWord(w)
*
* @this {X86CPU}
* @param {number} w is the word (16-bit) value to push at current SP; SP decreased by 2
* @param {number} w is the word (16-bit) value to push at current SP; SP decreased by 2 or 4
*/
X86CPU.prototype.pushWord = function(w)
{
this.assert((w & this.opMask) == w);
this.setSOWord(this.segSS, (this.regESP = (this.regESP - 2) & this.addrMask), w);
this.assert((w & this.dataMask) == w);
this.setSOWord(this.segSS, (this.regESP = (this.regESP - (2 << this.dataSize)) & this.addrMask), w);
};
/**
@ -2756,11 +2764,11 @@ X86CPU.prototype.stepCPU = function(nMinCycles)
this.segStack = this.segSS;
if (I386) {
this.opSize = this.segCS.opSize;
this.opMask = this.segCS.opMask;
this.dataSize = this.segCS.dataSize;
this.dataMask = this.segCS.dataMask;
this.addrSize = this.segCS.addrSize;
this.addrMask = this.segCS.addrMask;
this.opMem = this.aaOpMem[this.opSize];
this.opMem = this.aaOpMem[this.dataSize];
this.opMod = this.aaOpMod[this.addrSize];
}

View file

@ -1128,7 +1128,7 @@ var X86Grps = {
if (this.regEA < 0) {
return X86Grps.opGrpUndefined.call(this, dst, src);
}
X86Help.opHelpCALLF.call(this, dst, this.getWord(this.regEA + 2));
X86Help.opHelpCALLF.call(this, dst, this.getShort(this.regEA + 2));
this.nStepCycles -= this.CYCLES.nOpCyclesCallDM;
this.opFlags |= X86.OPFLAG.NOWRITE;
return dst;
@ -1155,7 +1155,7 @@ var X86Grps = {
if (this.regEA < 0) {
return X86Grps.opGrpUndefined.call(this, dst, src);
}
this.setCSIP(dst, this.getWord(this.regEA + 2));
this.setCSIP(dst, this.getShort(this.regEA + 2));
if (this.cIntReturn) this.checkIntReturn(this.regLIP);
this.nStepCycles -= this.CYCLES.nOpCyclesJmpDM;
this.opFlags |= X86.OPFLAG.NOWRITE;

View file

@ -202,7 +202,7 @@ var X86Help = {
X86Help.opHelpUndefined.call(this);
return dst;
}
this.setDS(this.getWord(this.regEA + 2));
this.setDS(this.getShort(this.regEA + 2));
this.nStepCycles -= this.CYCLES.nOpCyclesLS;
return src;
},
@ -217,7 +217,7 @@ var X86Help = {
X86Help.opHelpUndefined.call(this);
return dst;
}
this.setES(this.getWord(this.regEA + 2));
this.setES(this.getShort(this.regEA + 2));
this.nStepCycles -= this.CYCLES.nOpCyclesLS;
return src;
},
@ -239,8 +239,8 @@ var X86Help = {
* Note that BOUND performs signed comparisons, so we must transform all arguments into signed values.
*/
var wIndex = (dst << 16) >> 16;
var wLower = (this.getWord(this.regEA) << 16) >> 16;
var wUpper = (this.getWord(this.regEA + 2) << 16) >> 16;
var wLower = (this.getShort(this.regEA) << 16) >> 16;
var wUpper = (this.getShort(this.regEA + 2) << 16) >> 16;
this.nStepCycles -= this.CYCLES.nOpCyclesBound;
if (wIndex < wLower || wIndex > wUpper) {
/*
@ -579,15 +579,15 @@ var X86Help = {
if (this.regMSW & X86.MSW.PE) {
if (this.regPS & X86.PS.NT) {
var addrNew = this.segTSS.base;
var sel = this.getWord(addrNew + X86.TSS.PREV_TSS);
var sel = this.getShort(addrNew + X86.TSS.PREV_TSS);
X86Seg.switchTSS.call(this.segCS, sel, false);
return;
}
}
var cpl = this.segCS.cpl;
var regEIP = this.popWord();
var regCS = this.popWord();
var regPS = this.popWord();
var regCS = this.popWord();
var regPS = this.popWord();
if (this.setCSIP(regEIP, regCS, false) != null) {
this.setPS(regPS, cpl);
if (this.cIntReturn) this.checkIntReturn(this.regLIP);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -128,30 +128,30 @@ var X86Op0F = {
X86Help.opHelpFault.call(this, X86.EXCEPTION.GP_FAULT, 0, true);
return;
}
X86Help.opHelpLMSW.call(this, this.getWord(0x806));
this.regEDI = this.getWord(0x826);
this.regESI = this.getWord(0x828);
this.regEBP = this.getWord(0x82A);
this.regESP = this.getWord(0x82C);
this.regEBX = this.getWord(0x82E);
this.regEDX = this.getWord(0x830);
this.regECX = this.getWord(0x832);
this.regEAX = this.getWord(0x834);
this.segES.loadDesc6(0x836, this.getWord(0x824));
this.segCS.loadDesc6(0x83C, this.getWord(0x822));
this.segSS.loadDesc6(0x842, this.getWord(0x820));
this.segDS.loadDesc6(0x848, this.getWord(0x81E));
this.setPS(this.getWord(0x818));
this.setIP(this.getWord(0x81A));
X86Help.opHelpLMSW.call(this, this.getShort(0x806));
this.regEDI = this.getShort(0x826);
this.regESI = this.getShort(0x828);
this.regEBP = this.getShort(0x82A);
this.regESP = this.getShort(0x82C);
this.regEBX = this.getShort(0x82E);
this.regEDX = this.getShort(0x830);
this.regECX = this.getShort(0x832);
this.regEAX = this.getShort(0x834);
this.segES.loadDesc6(0x836, this.getShort(0x824));
this.segCS.loadDesc6(0x83C, this.getShort(0x822));
this.segSS.loadDesc6(0x842, this.getShort(0x820));
this.segDS.loadDesc6(0x848, this.getShort(0x81E));
this.setPS(this.getShort(0x818));
this.setIP(this.getShort(0x81A));
/*
* TODO: The bytes at 0x851 and 0x85D "should be zeroes", but do we rely on that, or do we load zeros ourselves?
*/
this.addrGDT = this.getWord(0x84E) | (this.getWord(0x850) << 16);
this.addrGDTLimit = this.addrGDT + this.getWord(0x852);
this.segLDT.loadDesc6(0x854, this.getWord(0x81C));
this.addrIDT = this.getWord(0x85A) | (this.getWord(0x85C) << 16);
this.addrIDTLimit = this.addrIDT + this.getWord(0x85E);
this.segTSS.loadDesc6(0x860, this.getWord(0x816));
this.addrGDT = this.getShort(0x84E) | (this.getShort(0x850) << 16);
this.addrGDTLimit = this.addrGDT + this.getShort(0x852);
this.segLDT.loadDesc6(0x854, this.getShort(0x81C));
this.addrIDT = this.getShort(0x85A) | (this.getShort(0x85C) << 16);
this.addrIDTLimit = this.addrIDT + this.getShort(0x85E);
this.segTSS.loadDesc6(0x860, this.getShort(0x816));
this.nStepCycles -= 195;
/*
* TODO: LOADALL operation still needs to be verified in protected mode....
@ -212,7 +212,7 @@ var X86Op0F = {
opLTR: function(dst, src) {
this.opFlags |= X86.OPFLAG.NOWRITE;
if (this.segTSS.load(dst) != X86.ADDR_INVALID) {
this.setWord(this.segTSS.addrDesc + X86.DESC.ACC.OFFSET, this.segTSS.acc |= X86.DESC.ACC.TYPE.LDT);
this.setShort(this.segTSS.addrDesc + X86.DESC.ACC.OFFSET, this.segTSS.acc |= X86.DESC.ACC.TYPE.LDT);
this.segTSS.type = X86.DESC.ACC.TYPE.TSS_BUSY;
}
this.nStepCycles -= (17 + (this.regEA < 0? 0 : 2));
@ -296,11 +296,11 @@ var X86Op0F = {
X86Help.opHelpInvalid.call(this);
} else {
/*
* We don't need to setWord() the first word of the operand, because the ModRM group decoder that calls
* us does that automatically with the value we return (dst).
* We don't need to setShort() the first word of the operand, because the ModRM group decoder that
* calls us does that automatically with the value we return (dst).
*/
dst = this.addrGDTLimit - this.addrGDT;
this.setWord(this.regEA + 2, this.addrGDT);
this.setShort(this.regEA + 2, this.addrGDT);
/*
* We previously left the 6th byte of the target operand "undefined". But it turns out we have to set
* it to *something*, because there's processor detection in PC-DOS 7.0 (at least in the SETUP portion)
@ -329,12 +329,12 @@ var X86Op0F = {
* 145E:4BC2 9D POPF
* 145E:4BC3 CB RETF
*
* This code is expecting SGDT on an 80286 to set the 6th "undefined" byte to 0xFF. So we use setWord()
* This code is expecting SGDT on an 80286 to set the 6th "undefined" byte to 0xFF. So we use setShort()
* instead of setByte() and force the upper byte to 0xFF.
*
* TODO: Remove the 0xFF00 below on post-80286 processors; also, determine whether this behavior is unique to real-mode.
*/
this.setWord(this.regEA + 4, 0xFF00 | (this.addrGDT >> 16));
this.setShort(this.regEA + 4, 0xFF00 | (this.addrGDT >> 16));
this.nStepCycles -= 11;
}
return dst;
@ -350,18 +350,18 @@ var X86Op0F = {
X86Help.opHelpInvalid.call(this);
} else {
/*
* We don't need to setWord() the first word of the operand, because the ModRM group decoder that calls
* We don't need to setShort() the first word of the operand, because the ModRM group decoder that calls
* us does that automatically with the value we return (dst).
*/
dst = this.addrIDTLimit - this.addrIDT;
this.setWord(this.regEA + 2, this.addrIDT);
this.setShort(this.regEA + 2, this.addrIDT);
/*
* As with SGDT, the 6th byte is technically "undefined" on an 80286, but we now set it to 0xFF, for the
* same reasons discussed in SGDT (above).
*
* TODO: Remove the 0xFF00 below on post-80286 processors; also, determine whether this behavior is unique to real-mode.
*/
this.setWord(this.regEA + 4, 0xFF00 | (this.addrIDT >> 16));
this.setShort(this.regEA + 4, 0xFF00 | (this.addrIDT >> 16));
this.nStepCycles -= 12;
}
return dst;
@ -382,7 +382,7 @@ var X86Op0F = {
if (this.regEA < 0) {
X86Help.opHelpInvalid.call(this);
} else {
this.addrGDT = this.getWord(this.regEA + 2) | (this.getByte(this.regEA + 4) << 16);
this.addrGDT = this.getShort(this.regEA + 2) | (this.getByte(this.regEA + 4) << 16);
this.addrGDTLimit = this.addrGDT + dst;
this.opFlags |= X86.OPFLAG.NOWRITE;
this.nStepCycles -= 11;
@ -405,7 +405,7 @@ var X86Op0F = {
if (this.regEA < 0) {
X86Help.opHelpInvalid.call(this);
} else {
this.addrIDT = this.getWord(this.regEA + 2) | (this.getByte(this.regEA + 4) << 16);
this.addrIDT = this.getShort(this.regEA + 2) | (this.getByte(this.regEA + 4) << 16);
this.addrIDTLimit = this.addrIDT + dst;
this.opFlags |= X86.OPFLAG.NOWRITE;
this.nStepCycles -= 12;

View file

@ -105,7 +105,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opADDAXw: function() {
this.regEAX = (this.regEAX & ~this.opMask) | X86Grps.opGrpADDw.call(this, this.regEAX & this.opMask, this.getIPWord());
this.regEAX = (this.regEAX & ~this.dataMask) | X86Grps.opGrpADDw.call(this, this.regEAX & this.dataMask, this.getIPWord());
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -185,7 +185,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opORAXw: function() {
this.regEAX = (this.regEAX & ~this.opMask) | X86Grps.opGrpORw.call(this, this.regEAX & this.opMask, this.getIPWord());
this.regEAX = (this.regEAX & ~this.dataMask) | X86Grps.opGrpORw.call(this, this.regEAX & this.dataMask, this.getIPWord());
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -273,7 +273,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opADCAXw: function() {
this.regEAX = (this.regEAX & ~this.opMask) | X86Grps.opGrpADCw.call(this, this.regEAX & this.opMask, this.getIPWord());
this.regEAX = (this.regEAX & ~this.dataMask) | X86Grps.opGrpADCw.call(this, this.regEAX & this.dataMask, this.getIPWord());
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -353,7 +353,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opSBBAXw: function() {
this.regEAX = (this.regEAX & ~this.opMask) | X86Grps.opGrpSBBw.call(this, this.regEAX & this.opMask, this.getIPWord());
this.regEAX = (this.regEAX & ~this.dataMask) | X86Grps.opGrpSBBw.call(this, this.regEAX & this.dataMask, this.getIPWord());
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -433,7 +433,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opANDAXw: function() {
this.regEAX = (this.regEAX & ~this.opMask) | X86Grps.opGrpANDw.call(this, this.regEAX & this.opMask, this.getIPWord());
this.regEAX = (this.regEAX & ~this.dataMask) | X86Grps.opGrpANDw.call(this, this.regEAX & this.dataMask, this.getIPWord());
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -532,7 +532,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opSUBAXw: function() {
this.regEAX = (this.regEAX & ~this.opMask) | X86Grps.opGrpSUBw.call(this, this.regEAX & this.opMask, this.getIPWord());
this.regEAX = (this.regEAX & ~this.dataMask) | X86Grps.opGrpSUBw.call(this, this.regEAX & this.dataMask, this.getIPWord());
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -631,7 +631,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opXORAXw: function() {
this.regEAX = (this.regEAX & ~this.opMask) | X86Grps.opGrpXORw.call(this, this.regEAX & this.opMask, this.getIPWord());
this.regEAX = (this.regEAX & ~this.dataMask) | X86Grps.opGrpXORw.call(this, this.regEAX & this.dataMask, this.getIPWord());
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -729,7 +729,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opCMPAXw: function() {
X86Grps.opGrpCMPw.call(this, this.regEAX & this.opMask, this.getIPWord());
X86Grps.opGrpCMPw.call(this, this.regEAX & this.dataMask, this.getIPWord());
/*
* In the absence of any EA calculations, opGrpCMPw() will deduct nOpCyclesArithRR, and for all CPUs through
* the 80286, we need deduct only one more cycle.
@ -787,7 +787,7 @@ var X86OpXX = {
*/
opINCAX: function() {
this.resultAuxOverflow = this.regEAX;
this.regEAX = (this.regEAX & ~this.opMask) | (this.resultParitySign = this.regEAX + 1) & this.opMask;
this.regEAX = (this.regEAX & ~this.dataMask) | (this.resultParitySign = this.regEAX + 1) & this.dataMask;
this.resultValue = this.regEAX | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of INC takes 2 cycles on all CPUs
@ -799,7 +799,7 @@ var X86OpXX = {
*/
opINCCX: function() {
this.resultAuxOverflow = this.regECX;
this.regECX = (this.regECX & ~this.opMask) | (this.resultParitySign = this.regECX + 1) & this.opMask;
this.regECX = (this.regECX & ~this.dataMask) | (this.resultParitySign = this.regECX + 1) & this.dataMask;
this.resultValue = this.regECX | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of INC takes 2 cycles on all CPUs
@ -811,7 +811,7 @@ var X86OpXX = {
*/
opINCDX: function() {
this.resultAuxOverflow = this.regEDX;
this.regEDX = (this.regEDX & ~this.opMask) | (this.resultParitySign = this.regEDX + 1) & this.opMask;
this.regEDX = (this.regEDX & ~this.dataMask) | (this.resultParitySign = this.regEDX + 1) & this.dataMask;
this.resultValue = this.regEDX | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of INC takes 2 cycles on all CPUs
@ -823,7 +823,7 @@ var X86OpXX = {
*/
opINCBX: function() {
this.resultAuxOverflow = this.regEBX;
this.regEBX = (this.regEBX & ~this.opMask) | (this.resultParitySign = this.regEBX + 1) & this.opMask;
this.regEBX = (this.regEBX & ~this.dataMask) | (this.resultParitySign = this.regEBX + 1) & this.dataMask;
this.resultValue = this.regEBX | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of INC takes 2 cycles on all CPUs
@ -835,7 +835,7 @@ var X86OpXX = {
*/
opINCSP: function() {
this.resultAuxOverflow = this.regESP;
this.regESP = (this.regESP & ~this.opMask) | (this.resultParitySign = this.regESP + 1) & this.opMask;
this.regESP = (this.regESP & ~this.dataMask) | (this.resultParitySign = this.regESP + 1) & this.dataMask;
this.resultValue = this.regESP | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of INC takes 2 cycles on all CPUs
@ -847,7 +847,7 @@ var X86OpXX = {
*/
opINCBP: function() {
this.resultAuxOverflow = this.regEBP;
this.regEBP = (this.regEBP & ~this.opMask) | (this.resultParitySign = this.regEBP + 1) & this.opMask;
this.regEBP = (this.regEBP & ~this.dataMask) | (this.resultParitySign = this.regEBP + 1) & this.dataMask;
this.resultValue = this.regEBP | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of INC takes 2 cycles on all CPUs
@ -859,7 +859,7 @@ var X86OpXX = {
*/
opINCSI: function() {
this.resultAuxOverflow = this.regESI;
this.regESI = (this.regESI & ~this.opMask) | (this.resultParitySign = this.regESI + 1) & this.opMask;
this.regESI = (this.regESI & ~this.dataMask) | (this.resultParitySign = this.regESI + 1) & this.dataMask;
this.resultValue = this.regESI | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of INC takes 2 cycles on all CPUs
@ -871,7 +871,7 @@ var X86OpXX = {
*/
opINCDI: function() {
this.resultAuxOverflow = this.regEDI;
this.regEDI = (this.regEDI & ~this.opMask) | (this.resultParitySign = this.regEDI + 1) & this.opMask;
this.regEDI = (this.regEDI & ~this.dataMask) | (this.resultParitySign = this.regEDI + 1) & this.dataMask;
this.resultValue = this.regEDI | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of INC takes 2 cycles on all CPUs
@ -883,7 +883,7 @@ var X86OpXX = {
*/
opDECAX: function() {
this.resultAuxOverflow = this.regEAX;
this.regEAX = (this.regEAX & ~this.opMask) | (this.resultParitySign = this.regEAX - 1) & this.opMask;
this.regEAX = (this.regEAX & ~this.dataMask) | (this.resultParitySign = this.regEAX - 1) & this.dataMask;
this.resultValue = this.regEAX | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of DEC takes 2 cycles on all CPUs
@ -895,7 +895,7 @@ var X86OpXX = {
*/
opDECCX: function() {
this.resultAuxOverflow = this.regECX;
this.regECX = (this.regECX & ~this.opMask) | (this.resultParitySign = this.regECX - 1) & this.opMask;
this.regECX = (this.regECX & ~this.dataMask) | (this.resultParitySign = this.regECX - 1) & this.dataMask;
this.resultValue = this.regECX | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of DEC takes 2 cycles on all CPUs
@ -907,7 +907,7 @@ var X86OpXX = {
*/
opDECDX: function() {
this.resultAuxOverflow = this.regEDX;
this.regEDX = (this.regEDX & ~this.opMask) | (this.resultParitySign = this.regEDX - 1) & this.opMask;
this.regEDX = (this.regEDX & ~this.dataMask) | (this.resultParitySign = this.regEDX - 1) & this.dataMask;
this.resultValue = this.regEDX | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of DEC takes 2 cycles on all CPUs
@ -919,7 +919,7 @@ var X86OpXX = {
*/
opDECBX: function() {
this.resultAuxOverflow = this.regEBX;
this.regEBX = (this.regEBX & ~this.opMask) | (this.resultParitySign = this.regEBX - 1) & this.opMask;
this.regEBX = (this.regEBX & ~this.dataMask) | (this.resultParitySign = this.regEBX - 1) & this.dataMask;
this.resultValue = this.regEBX | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of DEC takes 2 cycles on all CPUs
@ -931,7 +931,7 @@ var X86OpXX = {
*/
opDECSP: function() {
this.resultAuxOverflow = this.regESP;
this.regESP = (this.regESP & ~this.opMask) | (this.resultParitySign = this.regESP - 1) & this.opMask;
this.regESP = (this.regESP & ~this.dataMask) | (this.resultParitySign = this.regESP - 1) & this.dataMask;
this.resultValue = this.regESP | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of DEC takes 2 cycles on all CPUs
@ -943,7 +943,7 @@ var X86OpXX = {
*/
opDECBP: function() {
this.resultAuxOverflow = this.regEBP;
this.regEBP = (this.regEBP & ~this.opMask) | (this.resultParitySign = this.regEBP - 1) & this.opMask;
this.regEBP = (this.regEBP & ~this.dataMask) | (this.resultParitySign = this.regEBP - 1) & this.dataMask;
this.resultValue = this.regEBP | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of DEC takes 2 cycles on all CPUs
@ -955,7 +955,7 @@ var X86OpXX = {
*/
opDECSI: function() {
this.resultAuxOverflow = this.regESI;
this.regESI = (this.regESI & ~this.opMask) | (this.resultParitySign = this.regESI - 1) & this.opMask;
this.regESI = (this.regESI & ~this.dataMask) | (this.resultParitySign = this.regESI - 1) & this.dataMask;
this.resultValue = this.regESI | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of DEC takes 2 cycles on all CPUs
@ -967,7 +967,7 @@ var X86OpXX = {
*/
opDECDI: function() {
this.resultAuxOverflow = this.regEDI;
this.regEDI = (this.regEDI & ~this.opMask) | (this.resultParitySign = this.regEDI - 1) & this.opMask;
this.regEDI = (this.regEDI & ~this.dataMask) | (this.resultParitySign = this.regEDI - 1) & this.dataMask;
this.resultValue = this.regEDI | (((this.resultValue & this.resultSize)? 1 : 0) << 16);
this.resultSize = X86.RESULT.SIZE_WORD;
this.nStepCycles -= 2; // this form of DEC takes 2 cycles on all CPUs
@ -981,7 +981,7 @@ var X86OpXX = {
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiAL; this.backTrack.btiMemHi = this.backTrack.btiAH;
}
this.pushWord(this.regEAX & this.opMask);
this.pushWord(this.regEAX & this.dataMask);
this.nStepCycles -= this.CYCLES.nOpCyclesPushReg;
},
/**
@ -993,7 +993,7 @@ var X86OpXX = {
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiCL; this.backTrack.btiMemHi = this.backTrack.btiCH;
}
this.pushWord(this.regECX & this.opMask);
this.pushWord(this.regECX & this.dataMask);
this.nStepCycles -= this.CYCLES.nOpCyclesPushReg;
},
/**
@ -1005,7 +1005,7 @@ var X86OpXX = {
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiDL; this.backTrack.btiMemHi = this.backTrack.btiDH;
}
this.pushWord(this.regEDX & this.opMask);
this.pushWord(this.regEDX & this.dataMask);
this.nStepCycles -= this.CYCLES.nOpCyclesPushReg;
},
/**
@ -1017,7 +1017,7 @@ var X86OpXX = {
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiBL; this.backTrack.btiMemHi = this.backTrack.btiBH;
}
this.pushWord(this.regEBX & this.opMask);
this.pushWord(this.regEBX & this.dataMask);
this.nStepCycles -= this.CYCLES.nOpCyclesPushReg;
},
/**
@ -1026,7 +1026,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPUSHSP8086: function() {
var w = (this.regESP - (2 << this.opSize)) & this.opMask;
var w = (this.regESP - (2 << this.dataSize)) & this.dataMask;
this.pushWord(w);
this.nStepCycles -= this.CYCLES.nOpCyclesPushReg;
},
@ -1036,7 +1036,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPUSHSP: function() {
this.pushWord(this.regESP & this.opMask);
this.pushWord(this.regESP & this.dataMask);
this.nStepCycles -= this.CYCLES.nOpCyclesPushReg;
},
/**
@ -1048,7 +1048,7 @@ var X86OpXX = {
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiBPLo; this.backTrack.btiMemHi = this.backTrack.btiBPHi;
}
this.pushWord(this.regEBP & this.opMask);
this.pushWord(this.regEBP & this.dataMask);
this.nStepCycles -= this.CYCLES.nOpCyclesPushReg;
},
/**
@ -1060,7 +1060,7 @@ var X86OpXX = {
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiSILo; this.backTrack.btiMemHi = this.backTrack.btiSIHi;
}
this.pushWord(this.regESI & this.opMask);
this.pushWord(this.regESI & this.dataMask);
this.nStepCycles -= this.CYCLES.nOpCyclesPushReg;
},
/**
@ -1072,7 +1072,7 @@ var X86OpXX = {
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiDILo; this.backTrack.btiMemHi = this.backTrack.btiDIHi;
}
this.pushWord(this.regEDI & this.opMask);
this.pushWord(this.regEDI & this.dataMask);
this.nStepCycles -= this.CYCLES.nOpCyclesPushReg;
},
/**
@ -1081,7 +1081,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPOPAX: function() {
this.regEAX = (this.regEAX & ~this.opMask) | this.popWord();
this.regEAX = (this.regEAX & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -1093,7 +1093,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPOPCX: function() {
this.regECX = (this.regECX & ~this.opMask) | this.popWord();
this.regECX = (this.regECX & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiCL = this.backTrack.btiMemLo; this.backTrack.btiCH = this.backTrack.btiMemHi;
}
@ -1105,7 +1105,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPOPDX: function() {
this.regEDX = (this.regEDX & ~this.opMask) | this.popWord();
this.regEDX = (this.regEDX & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiDL = this.backTrack.btiMemLo; this.backTrack.btiDH = this.backTrack.btiMemHi;
}
@ -1117,7 +1117,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPOPBX: function() {
this.regEBX = (this.regEBX & ~this.opMask) | this.popWord();
this.regEBX = (this.regEBX & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiBL = this.backTrack.btiMemLo; this.backTrack.btiBH = this.backTrack.btiMemHi;
}
@ -1129,7 +1129,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPOPSP: function() {
this.regESP = (this.regESP & ~this.opMask) | this.popWord();
this.regESP = (this.regESP & ~this.dataMask) | this.popWord();
this.nStepCycles -= this.CYCLES.nOpCyclesPopReg;
},
/**
@ -1138,7 +1138,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPOPBP: function() {
this.regEBP = (this.regEBP & ~this.opMask) | this.popWord();
this.regEBP = (this.regEBP & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiBPLo = this.backTrack.btiMemLo; this.backTrack.btiBPHi = this.backTrack.btiMemHi;
}
@ -1150,7 +1150,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPOPSI: function() {
this.regESI = (this.regESI & ~this.opMask) | this.popWord();
this.regESI = (this.regESI & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiSILo = this.backTrack.btiMemLo; this.backTrack.btiSIHi = this.backTrack.btiMemHi;
}
@ -1162,7 +1162,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPOPDI: function() {
this.regEDI = (this.regEDI & ~this.opMask) | this.popWord();
this.regEDI = (this.regEDI & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiDILo = this.backTrack.btiMemLo; this.backTrack.btiDIHi = this.backTrack.btiMemHi;
}
@ -1174,36 +1174,36 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPUSHA: function() {
var temp = this.regESP & this.opMask;
var temp = this.regESP & this.dataMask;
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiAL; this.backTrack.btiMemHi = this.backTrack.btiAH;
}
this.pushWord(this.regEAX & this.opMask);
this.pushWord(this.regEAX & this.dataMask);
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiCL; this.backTrack.btiMemHi = this.backTrack.btiCH;
}
this.pushWord(this.regECX & this.opMask);
this.pushWord(this.regECX & this.dataMask);
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiDL; this.backTrack.btiMemHi = this.backTrack.btiDH;
}
this.pushWord(this.regEDX & this.opMask);
this.pushWord(this.regEDX & this.dataMask);
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiBL; this.backTrack.btiMemHi = this.backTrack.btiBH;
}
this.pushWord(this.regEBX & this.opMask);
this.pushWord(this.regEBX & this.dataMask);
this.pushWord(temp);
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiBPLo; this.backTrack.btiMemHi = this.backTrack.btiBPHi;
}
this.pushWord(this.regEBP & this.opMask);
this.pushWord(this.regEBP & this.dataMask);
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiSILo; this.backTrack.btiMemHi = this.backTrack.btiSIHi;
}
this.pushWord(this.regESI & this.opMask);
this.pushWord(this.regESI & this.dataMask);
if (BACKTRACK) {
this.backTrack.btiMemLo = this.backTrack.btiDILo; this.backTrack.btiMemHi = this.backTrack.btiDIHi;
}
this.pushWord(this.regEDI & this.opMask);
this.pushWord(this.regEDI & this.dataMask);
this.nStepCycles -= this.CYCLES.nOpCyclesPushAll;
},
/**
@ -1212,32 +1212,32 @@ var X86OpXX = {
* @this {X86CPU}
*/
opPOPA: function() {
this.regEDI = (this.regEDI & ~this.opMask) | this.popWord();
this.regEDI = (this.regEDI & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiDILo = this.backTrack.btiMemLo; this.backTrack.btiDIHi = this.backTrack.btiMemHi;
}
this.regESI = (this.regESI & ~this.opMask) | this.popWord();
this.regESI = (this.regESI & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiSILo = this.backTrack.btiMemLo; this.backTrack.btiSIHi = this.backTrack.btiMemHi;
}
this.regEBP = (this.regEBP & ~this.opMask) | this.popWord();
this.regEBP = (this.regEBP & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiBPLo = this.backTrack.btiMemLo; this.backTrack.btiBPHi = this.backTrack.btiMemHi;
}
this.regESP += (2 << this.opSize);
this.regEBX = (this.regEBX & ~this.opMask) | this.popWord();
this.regESP += (2 << this.dataSize);
this.regEBX = (this.regEBX & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiBL = this.backTrack.btiMemLo; this.backTrack.btiBH = this.backTrack.btiMemHi;
}
this.regEDX = (this.regEDX & ~this.opMask) | this.popWord();
this.regEDX = (this.regEDX & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiDL = this.backTrack.btiMemLo; this.backTrack.btiDH = this.backTrack.btiMemHi;
}
this.regECX = (this.regECX & ~this.opMask) | this.popWord();
this.regECX = (this.regECX & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiCL = this.backTrack.btiMemLo; this.backTrack.btiCH = this.backTrack.btiMemHi;
}
this.regEAX = (this.regEAX & ~this.opMask) | this.popWord();
this.regEAX = (this.regEAX & ~this.dataMask) | this.popWord();
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -1268,9 +1268,9 @@ var X86OpXX = {
*/
opOS: function() {
this.opFlags |= X86.OPFLAG.SEG;
this.opSize ^= 1; // that which is 0 shall become 1, and vice versa
this.opMask ^= 0xffff0000; // that which is 0x0000ffff shall become 0xffffffff, and vice versa
this.opMem = this.aaOpMem[this.opSize];
this.dataSize ^= 1; // that which is 0 shall become 1, and vice versa
this.dataMask ^= 0xffff0000; // that which is 0x0000ffff shall become 0xffffffff, and vice versa
this.opMem = this.aaOpMem[this.dataSize];
this.nStepCycles -= this.CYCLES.nOpCyclesPrefix;
},
/**
@ -2019,8 +2019,8 @@ var X86OpXX = {
*/
opXCHGCX: function() {
var temp = this.regEAX;
this.regEAX = (this.regEAX & ~this.opMask) | (this.regECX & this.opMask);
this.regECX = (this.regECX & ~this.opMask) | (temp & this.opMask);
this.regEAX = (this.regEAX & ~this.dataMask) | (this.regECX & this.dataMask);
this.regECX = (this.regECX & ~this.dataMask) | (temp & this.dataMask);
if (BACKTRACK) {
temp = this.backTrack.btiAL; this.backTrack.btiAL = this.backTrack.btiCL; this.backTrack.btiCL = temp;
temp = this.backTrack.btiAH; this.backTrack.btiAH = this.backTrack.btiCH; this.backTrack.btiCH = temp;
@ -2034,8 +2034,8 @@ var X86OpXX = {
*/
opXCHGDX: function() {
var temp = this.regEAX;
this.regEAX = (this.regEAX & ~this.opMask) | (this.regEDX & this.opMask);
this.regEDX = (this.regEDX & ~this.opMask) | (temp & this.opMask);
this.regEAX = (this.regEAX & ~this.dataMask) | (this.regEDX & this.dataMask);
this.regEDX = (this.regEDX & ~this.dataMask) | (temp & this.dataMask);
if (BACKTRACK) {
temp = this.backTrack.btiAL; this.backTrack.btiAL = this.backTrack.btiDL; this.backTrack.btiDL = temp;
temp = this.backTrack.btiAH; this.backTrack.btiAH = this.backTrack.btiDH; this.backTrack.btiDH = temp;
@ -2049,8 +2049,8 @@ var X86OpXX = {
*/
opXCHGBX: function() {
var temp = this.regEAX;
this.regEAX = (this.regEAX & ~this.opMask) | (this.regEBX & this.opMask);
this.regEBX = (this.regEBX & ~this.opMask) | (temp & this.opMask);
this.regEAX = (this.regEAX & ~this.dataMask) | (this.regEBX & this.dataMask);
this.regEBX = (this.regEBX & ~this.dataMask) | (temp & this.dataMask);
if (BACKTRACK) {
temp = this.backTrack.btiAL; this.backTrack.btiAL = this.backTrack.btiBL; this.backTrack.btiBL = temp;
temp = this.backTrack.btiAH; this.backTrack.btiAH = this.backTrack.btiBH; this.backTrack.btiBH = temp;
@ -2064,8 +2064,8 @@ var X86OpXX = {
*/
opXCHGSP: function() {
var temp = this.regEAX;
this.regEAX = (this.regEAX & ~this.opMask) | (this.regESP & this.opMask);
this.regESP = (this.regESP & ~this.opMask) | (temp & this.opMask);
this.regEAX = (this.regEAX & ~this.dataMask) | (this.regESP & this.dataMask);
this.regESP = (this.regESP & ~this.dataMask) | (temp & this.dataMask);
if (BACKTRACK) this.backTrack.btiAL = this.backTrack.btiAH = 0;
this.nStepCycles -= 3; // this form of XCHG takes 3 cycles on all CPUs
},
@ -2076,8 +2076,8 @@ var X86OpXX = {
*/
opXCHGBP: function() {
var temp = this.regEAX;
this.regEAX = (this.regEAX & ~this.opMask) | (this.regEBP & this.opMask);
this.regEBP = (this.regEBP & ~this.opMask) | (temp & this.opMask);
this.regEAX = (this.regEAX & ~this.dataMask) | (this.regEBP & this.dataMask);
this.regEBP = (this.regEBP & ~this.dataMask) | (temp & this.dataMask);
if (BACKTRACK) {
temp = this.backTrack.btiAL; this.backTrack.btiAL = this.backTrack.btiBPLo; this.backTrack.btiBPLo = temp;
temp = this.backTrack.btiAH; this.backTrack.btiAH = this.backTrack.btiBPHi; this.backTrack.btiBPHi = temp;
@ -2091,8 +2091,8 @@ var X86OpXX = {
*/
opXCHGSI: function() {
var temp = this.regEAX;
this.regEAX = (this.regEAX & ~this.opMask) | (this.regESI & this.opMask);
this.regESI = (this.regESI & ~this.opMask) | (temp & this.opMask);
this.regEAX = (this.regEAX & ~this.dataMask) | (this.regESI & this.dataMask);
this.regESI = (this.regESI & ~this.dataMask) | (temp & this.dataMask);
if (BACKTRACK) {
temp = this.backTrack.btiAL; this.backTrack.btiAL = this.backTrack.btiSILo; this.backTrack.btiSILo = temp;
temp = this.backTrack.btiAH; this.backTrack.btiAH = this.backTrack.btiSIHi; this.backTrack.btiSIHi = temp;
@ -2106,8 +2106,8 @@ var X86OpXX = {
*/
opXCHGDI: function() {
var temp = this.regEAX;
this.regEAX = (this.regEAX & ~this.opMask) | (this.regEDI & this.opMask);
this.regEDI = (this.regEDI & ~this.opMask) | (temp & this.opMask);
this.regEAX = (this.regEAX & ~this.dataMask) | (this.regEDI & this.dataMask);
this.regEDI = (this.regEDI & ~this.dataMask) | (temp & this.dataMask);
if (BACKTRACK) {
temp = this.backTrack.btiAL; this.backTrack.btiAL = this.backTrack.btiDILo; this.backTrack.btiDILo = temp;
temp = this.backTrack.btiAH; this.backTrack.btiAH = this.backTrack.btiDIHi; this.backTrack.btiDIHi = temp;
@ -2123,7 +2123,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opCBW: function() {
if (!this.opSize) {
if (!this.dataSize) {
/*
* CBW
*/
@ -2146,7 +2146,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opCWD: function() {
if (!this.opSize) {
if (!this.dataSize) {
/*
* CWD
*/
@ -2248,7 +2248,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opMOVAXm: function() {
this.regEAX = (this.regEAX & ~this.opMask) | this.getSOWord(this.segData, this.getIPWord());
this.regEAX = (this.regEAX & ~this.dataMask) | this.getSOWord(this.segData, this.getIPWord());
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -2799,7 +2799,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opMOVAXw: function() {
this.regEAX = (this.regEAX & ~this.opMask) | this.getIPWord();
this.regEAX = (this.regEAX & ~this.dataMask) | this.getIPWord();
if (BACKTRACK) {
this.backTrack.btiAL = this.backTrack.btiMemLo; this.backTrack.btiAH = this.backTrack.btiMemHi;
}
@ -2811,7 +2811,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opMOVCXw: function() {
this.regECX = (this.regECX & ~this.opMask) | this.getIPWord();
this.regECX = (this.regECX & ~this.dataMask) | this.getIPWord();
if (BACKTRACK) {
this.backTrack.btiCL = this.backTrack.btiMemLo; this.backTrack.btiCH = this.backTrack.btiMemHi;
}
@ -2823,7 +2823,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opMOVDXw: function() {
this.regEDX = (this.regEDX & ~this.opMask) | this.getIPWord();
this.regEDX = (this.regEDX & ~this.dataMask) | this.getIPWord();
if (BACKTRACK) {
this.backTrack.btiDL = this.backTrack.btiMemLo; this.backTrack.btiDH = this.backTrack.btiMemHi;
}
@ -2835,7 +2835,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opMOVBXw: function() {
this.regEBX = (this.regEBX & ~this.opMask) | this.getIPWord();
this.regEBX = (this.regEBX & ~this.dataMask) | this.getIPWord();
if (BACKTRACK) {
this.backTrack.btiBL = this.backTrack.btiMemLo; this.backTrack.btiBH = this.backTrack.btiMemHi;
}
@ -2847,7 +2847,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opMOVSPw: function() {
this.regESP = (this.regESP & ~this.opMask) | this.getIPWord();
this.regESP = (this.regESP & ~this.dataMask) | this.getIPWord();
this.nStepCycles -= this.CYCLES.nOpCyclesLAHF;
},
/**
@ -2856,7 +2856,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opMOVBPw: function() {
this.regEBP = (this.regEBP & ~this.opMask) | this.getIPWord();
this.regEBP = (this.regEBP & ~this.dataMask) | this.getIPWord();
if (BACKTRACK) {
this.backTrack.btiBPLo = this.backTrack.btiMemLo; this.backTrack.btiBPHi = this.backTrack.btiMemHi;
}
@ -2868,7 +2868,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opMOVSIw: function() {
this.regESI = (this.regESI & ~this.opMask) | this.getIPWord();
this.regESI = (this.regESI & ~this.dataMask) | this.getIPWord();
if (BACKTRACK) {
this.backTrack.btiSILo = this.backTrack.btiMemLo; this.backTrack.btiSIHi = this.backTrack.btiMemHi;
}
@ -2880,7 +2880,7 @@ var X86OpXX = {
* @this {X86CPU}
*/
opMOVDIw: function() {
this.regEDI = (this.regEDI & ~this.opMask) | this.getIPWord();
this.regEDI = (this.regEDI & ~this.dataMask) | this.getIPWord();
if (BACKTRACK) {
this.backTrack.btiDILo = this.backTrack.btiMemLo; this.backTrack.btiDIHi = this.backTrack.btiMemHi;
}
@ -2910,7 +2910,7 @@ var X86OpXX = {
opRETn: function() {
var n = this.getIPWord();
this.setIP(this.popWord());
this.regESP = (this.regESP & ~this.addrMask) | ((this.regESP + (n << this.opSize)) & this.addrMask);
this.regESP = (this.regESP & ~this.addrMask) | ((this.regESP + (n << this.dataSize)) & this.addrMask);
this.nStepCycles -= this.CYCLES.nOpCyclesRetn;
},
/**
@ -3004,7 +3004,7 @@ var X86OpXX = {
if (bLevel > 0) {
this.nStepCycles -= (bLevel << 2) + (bLevel > 1? 1 : 0);
while (--bLevel) {
this.regEBP = (this.regEBP & ~this.segSS.addrMask) | ((this.regEBP - (2 << this.opSize)) & this.segSS.addrMask);
this.regEBP = (this.regEBP & ~this.segSS.addrMask) | ((this.regEBP - (2 << this.dataSize)) & this.segSS.addrMask);
this.pushWord(this.getSOWord(this.segSS, this.regEBP & this.segSS.addrMask));
}
this.pushWord(wFrame);
@ -3021,7 +3021,7 @@ var X86OpXX = {
*/
opLEAVE: function() {
this.regESP = (this.regESP & ~this.segSS.addrMask) | (this.regEBP & this.segSS.addrMask);
this.regEBP = (this.regEBP & ~this.opMask) | (this.popWord() & this.opMask);
this.regEBP = (this.regEBP & ~this.dataMask) | (this.popWord() & this.dataMask);
/*
* NOTE: 5 is the cycle time for the 80286; the 80186/80188 has a cycle time of 8. However, accurate cycle
* counts for the 80186/80188 is low priority. TODO: Fix this someday.

View file

@ -118,8 +118,8 @@ X86Seg.ID = {
X86Seg.loadReal = function loadReal(sel, fSuppress)
{
this.sel = sel;
this.opSize = this.addrSize = 0;
this.opMask = this.addrMask = 0xffff;
this.dataSize = this.addrSize = 0;
this.dataMask = this.addrMask = 0xffff;
return this.base = sel << 4;
};
@ -207,9 +207,9 @@ X86Seg.loadRealIDT = function loadRealIDT(nIDT)
* TODO: Verify that 80286 real-mode actually enforces the above. See http://localhost:8088/pubs/pc/reference/intel/80286/progref/#page-260
*/
var addrIDT = cpu.addrIDT + (nIDT << 2);
cpu.regEIP = cpu.getWord(addrIDT);
cpu.regEIP = cpu.getShort(addrIDT);
cpu.regPS &= ~(X86.PS.TF | X86.PS.IF);
return this.load(cpu.getWord(addrIDT + 2));
return this.load(cpu.getShort(addrIDT + 2));
};
/**
@ -406,7 +406,7 @@ X86Seg.switchTSS = function switchTSS(selNew, fNest)
X86Help.opHelpFault.call(cpu, X86.EXCEPTION.TS_FAULT, selNew, true);
return false;
}
cpu.setWord(cpu.segTSS.addrDesc + X86.DESC.ACC.OFFSET, (cpu.segTSS.acc & ~X86.DESC.ACC.TYPE.TSS_BUSY) | X86.DESC.ACC.TYPE.TSS);
cpu.setShort(cpu.segTSS.addrDesc + X86.DESC.ACC.OFFSET, (cpu.segTSS.acc & ~X86.DESC.ACC.TYPE.TSS_BUSY) | X86.DESC.ACC.TYPE.TSS);
}
if (cpu.segTSS.load(selNew) == X86.ADDR_INVALID) {
return false;
@ -420,45 +420,45 @@ X86Seg.switchTSS = function switchTSS(selNew, fNest)
X86Help.opHelpFault.call(cpu, X86.EXCEPTION.GP_FAULT, selNew, true);
return false;
}
cpu.setWord(cpu.segTSS.addrDesc + X86.DESC.ACC.OFFSET, cpu.segTSS.acc |= X86.DESC.ACC.TYPE.TSS_BUSY);
cpu.setShort(cpu.segTSS.addrDesc + X86.DESC.ACC.OFFSET, cpu.segTSS.acc |= X86.DESC.ACC.TYPE.TSS_BUSY);
cpu.segTSS.type = X86.DESC.ACC.TYPE.TSS_BUSY;
}
cpu.setWord(addrOld + X86.TSS.TASK_IP, cpu.regEIP);
cpu.setWord(addrOld + X86.TSS.TASK_PS, cpu.getPS());
cpu.setWord(addrOld + X86.TSS.TASK_AX, cpu.regEAX);
cpu.setWord(addrOld + X86.TSS.TASK_CX, cpu.regECX);
cpu.setWord(addrOld + X86.TSS.TASK_DX, cpu.regEDX);
cpu.setWord(addrOld + X86.TSS.TASK_BX, cpu.regEBX);
cpu.setWord(addrOld + X86.TSS.TASK_SP, cpu.regESP);
cpu.setWord(addrOld + X86.TSS.TASK_BP, cpu.regEBP);
cpu.setWord(addrOld + X86.TSS.TASK_SI, cpu.regESI);
cpu.setWord(addrOld + X86.TSS.TASK_DI, cpu.regEDI);
cpu.setWord(addrOld + X86.TSS.TASK_ES, cpu.segES.sel);
cpu.setWord(addrOld + X86.TSS.TASK_CS, cpu.segCS.sel);
cpu.setWord(addrOld + X86.TSS.TASK_SS, cpu.segSS.sel);
cpu.setWord(addrOld + X86.TSS.TASK_DS, cpu.segDS.sel);
cpu.setShort(addrOld + X86.TSS.TASK_IP, cpu.regEIP);
cpu.setShort(addrOld + X86.TSS.TASK_PS, cpu.getPS());
cpu.setShort(addrOld + X86.TSS.TASK_AX, cpu.regEAX);
cpu.setShort(addrOld + X86.TSS.TASK_CX, cpu.regECX);
cpu.setShort(addrOld + X86.TSS.TASK_DX, cpu.regEDX);
cpu.setShort(addrOld + X86.TSS.TASK_BX, cpu.regEBX);
cpu.setShort(addrOld + X86.TSS.TASK_SP, cpu.regESP);
cpu.setShort(addrOld + X86.TSS.TASK_BP, cpu.regEBP);
cpu.setShort(addrOld + X86.TSS.TASK_SI, cpu.regESI);
cpu.setShort(addrOld + X86.TSS.TASK_DI, cpu.regEDI);
cpu.setShort(addrOld + X86.TSS.TASK_ES, cpu.segES.sel);
cpu.setShort(addrOld + X86.TSS.TASK_CS, cpu.segCS.sel);
cpu.setShort(addrOld + X86.TSS.TASK_SS, cpu.segSS.sel);
cpu.setShort(addrOld + X86.TSS.TASK_DS, cpu.segDS.sel);
var offSS = X86.TSS.TASK_SS;
var offSP = X86.TSS.TASK_SP;
cpu.setPS(cpu.getWord(addrNew + X86.TSS.TASK_PS) | (fNest? X86.PS.NT : 0));
cpu.setPS(cpu.getShort(addrNew + X86.TSS.TASK_PS) | (fNest? X86.PS.NT : 0));
cpu.assert(!fNest || !!(cpu.regPS & X86.PS.NT));
cpu.regEAX = cpu.getWord(addrNew + X86.TSS.TASK_AX);
cpu.regECX = cpu.getWord(addrNew + X86.TSS.TASK_CX);
cpu.regEDX = cpu.getWord(addrNew + X86.TSS.TASK_DX);
cpu.regEBX = cpu.getWord(addrNew + X86.TSS.TASK_BX);
cpu.regEBP = cpu.getWord(addrNew + X86.TSS.TASK_BP);
cpu.regESI = cpu.getWord(addrNew + X86.TSS.TASK_SI);
cpu.regEDI = cpu.getWord(addrNew + X86.TSS.TASK_DI);
cpu.segES.load(cpu.getWord(addrNew + X86.TSS.TASK_ES));
cpu.segDS.load(cpu.getWord(addrNew + X86.TSS.TASK_DS));
cpu.setCSIP(cpu.getWord(addrNew + X86.TSS.TASK_IP), cpu.getWord(addrNew + X86.TSS.TASK_CS));
cpu.regEAX = cpu.getShort(addrNew + X86.TSS.TASK_AX);
cpu.regECX = cpu.getShort(addrNew + X86.TSS.TASK_CX);
cpu.regEDX = cpu.getShort(addrNew + X86.TSS.TASK_DX);
cpu.regEBX = cpu.getShort(addrNew + X86.TSS.TASK_BX);
cpu.regEBP = cpu.getShort(addrNew + X86.TSS.TASK_BP);
cpu.regESI = cpu.getShort(addrNew + X86.TSS.TASK_SI);
cpu.regEDI = cpu.getShort(addrNew + X86.TSS.TASK_DI);
cpu.segES.load(cpu.getShort(addrNew + X86.TSS.TASK_ES));
cpu.segDS.load(cpu.getShort(addrNew + X86.TSS.TASK_DS));
cpu.setCSIP(cpu.getShort(addrNew + X86.TSS.TASK_IP), cpu.getShort(addrNew + X86.TSS.TASK_CS));
if (this.cpl < cplOld) {
offSP = (this.cpl << 2) + X86.TSS.CPL0_SP;
offSS = offSP + 2;
}
cpu.regESP = cpu.getWord(addrNew + offSP);
cpu.segSS.load(cpu.getWord(addrNew + offSS));
cpu.segLDT.load(cpu.getWord(addrNew + X86.TSS.TASK_LDT));
if (fNest) cpu.setWord(addrNew + X86.TSS.PREV_TSS, selOld);
cpu.regESP = cpu.getShort(addrNew + offSP);
cpu.segSS.load(cpu.getShort(addrNew + offSS));
cpu.segLDT.load(cpu.getShort(addrNew + X86.TSS.TASK_LDT));
if (fNest) cpu.setShort(addrNew + X86.TSS.PREV_TSS, selOld);
cpu.regMSW |= X86.MSW.TS;
return true;
};
@ -491,7 +491,7 @@ X86Seg.prototype.loadAcc = function(sel, fGDT)
if (addrDT !== undefined) {
var addrDesc = addrDT + (sel & X86.SEL.MASK);
if (addrDesc + 7 <= addrDTLimit) {
return cpu.getWord(addrDesc + X86.DESC.ACC.OFFSET);
return cpu.getShort(addrDesc + X86.DESC.ACC.OFFSET);
}
}
X86Help.opHelpFault.call(cpu, X86.EXCEPTION.GP_FAULT, sel);
@ -515,9 +515,9 @@ X86Seg.prototype.loadAcc = function(sel, fGDT)
X86Seg.prototype.loadDesc6 = function(addrDesc, sel)
{
var cpu = this.cpu;
var acc = cpu.getWord(addrDesc + 2);
var base = cpu.getWord(addrDesc) | ((acc & 0xff) << 16);
var limit = cpu.getWord(addrDesc + 4);
var acc = cpu.getShort(addrDesc + 2);
var base = cpu.getShort(addrDesc) | ((acc & 0xff) << 16);
var limit = cpu.getShort(addrDesc + 4);
this.sel = sel;
this.base = base;
@ -554,11 +554,11 @@ X86Seg.prototype.loadDesc6 = function(addrDesc, sel)
X86Seg.prototype.loadDesc8 = function(addrDesc, sel, fSuppress)
{
var cpu = this.cpu;
var limit = cpu.getWord(addrDesc + X86.DESC.LIMIT.OFFSET);
var acc = cpu.getWord(addrDesc + X86.DESC.ACC.OFFSET);
var limit = cpu.getShort(addrDesc + X86.DESC.LIMIT.OFFSET);
var acc = cpu.getShort(addrDesc + X86.DESC.ACC.OFFSET);
var type = (acc & X86.DESC.ACC.TYPE.MASK);
var base = cpu.getWord(addrDesc + X86.DESC.BASE.OFFSET) | ((acc & X86.DESC.ACC.BASE1623) << 16);
var ext = cpu.getWord(addrDesc + X86.DESC.EXT.OFFSET);
var base = cpu.getShort(addrDesc + X86.DESC.BASE.OFFSET) | ((acc & X86.DESC.ACC.BASE1623) << 16);
var ext = cpu.getShort(addrDesc + X86.DESC.EXT.OFFSET);
var selMasked = sel & X86.SEL.MASK;
while (true) {
@ -659,8 +659,8 @@ X86Seg.prototype.loadDesc8 = function(addrDesc, sel, fSuppress)
offSS = offSP + 2;
regSPPrev = cpu.regESP;
regSSPrev = cpu.segSS.sel;
cpu.regESP = cpu.getWord(addrTSS + offSP);
cpu.segSS.load(cpu.getWord(addrTSS + offSS));
cpu.regESP = cpu.getShort(addrTSS + offSP);
cpu.segSS.load(cpu.getShort(addrTSS + offSS));
cpu.pushWord(regSSPrev);
cpu.pushWord(regSPPrev);
while (i) cpu.pushWord(this.awParms[--i]);
@ -848,11 +848,11 @@ X86Seg.prototype.updateMode = function(fProt)
this.cpl = this.sel & X86.SEL.RPL;
this.dpl = (this.acc & X86.DESC.ACC.DPL.MASK) >> X86.DESC.ACC.DPL.SHIFT;
if (this.cpu.model < X86.MODEL_80386 || !(this.ext & X86.DESC.EXT.BIG)) {
this.opSize = 0;
this.opMask = 0xffff;
this.dataSize = 0;
this.dataMask = 0xffff;
} else {
this.opSize = 1;
this.opMask = 0xffffffff;
this.dataSize = 1;
this.dataMask = 0xffffffff;
}
} else {
this.load = X86Seg.loadReal;
@ -862,11 +862,11 @@ X86Seg.prototype.updateMode = function(fProt)
this.limit = 0xffff;
this.cpl = this.dpl = 0;
this.addrDesc = X86.ADDR_INVALID;
this.opSize = 0;
this.opMask = 0xffff;
this.dataSize = 0;
this.dataMask = 0xffff;
}
this.addrSize = this.opSize;
this.addrMask = this.opMask;
this.addrSize = this.dataSize;
this.addrMask = this.dataMask;
return fProt;
};