Fixed MOVSX,MOVZX, and passed initial paging test

This commit is contained in:
Jeff Parsons 2015-05-07 16:00:38 -07:00 committed by jeffpar
commit f3646d206f
10 changed files with 403 additions and 128 deletions

View file

@ -78,6 +78,7 @@
"debugger": {
"id": "pc386.debugger",
"name": "",
"commands": "",
"messages": ""
}
}

View file

@ -744,9 +744,9 @@ if (DEBUGGER) {
/* 0x89 */ [Debugger.INS.MOV, Debugger.TYPE_MODRM | Debugger.TYPE_WORDV | Debugger.TYPE_OUT, Debugger.TYPE_REG | Debugger.TYPE_WORDV | Debugger.TYPE_IN],
/* 0x8A */ [Debugger.INS.MOV, Debugger.TYPE_REG | Debugger.TYPE_BYTE | Debugger.TYPE_OUT, Debugger.TYPE_MODRM | Debugger.TYPE_BYTE | Debugger.TYPE_IN],
/* 0x8B */ [Debugger.INS.MOV, Debugger.TYPE_REG | Debugger.TYPE_WORDV | Debugger.TYPE_OUT, Debugger.TYPE_MODRM | Debugger.TYPE_WORDV | Debugger.TYPE_IN],
/* 0x8C */ [Debugger.INS.MOV, Debugger.TYPE_MODRM | Debugger.TYPE_WORD | Debugger.TYPE_OUT, Debugger.TYPE_SEGREG | Debugger.TYPE_WORD | Debugger.TYPE_IN],
/* 0x8C */ [Debugger.INS.MOV, Debugger.TYPE_MODRM | Debugger.TYPE_WORDV | Debugger.TYPE_OUT, Debugger.TYPE_SEGREG | Debugger.TYPE_WORD | Debugger.TYPE_IN],
/* 0x8D */ [Debugger.INS.LEA, Debugger.TYPE_REG | Debugger.TYPE_WORDV | Debugger.TYPE_OUT, Debugger.TYPE_MEM | Debugger.TYPE_WORDV],
/* 0x8E */ [Debugger.INS.MOV, Debugger.TYPE_SEGREG | Debugger.TYPE_WORD | Debugger.TYPE_OUT, Debugger.TYPE_MODRM | Debugger.TYPE_WORD | Debugger.TYPE_IN],
/* 0x8E */ [Debugger.INS.MOV, Debugger.TYPE_SEGREG | Debugger.TYPE_WORD | Debugger.TYPE_OUT, Debugger.TYPE_MODRM | Debugger.TYPE_WORDV | Debugger.TYPE_IN],
/* 0x8F */ [Debugger.INS.POP, Debugger.TYPE_MODRM | Debugger.TYPE_WORDV | Debugger.TYPE_OUT],
/* 0x90 */ [Debugger.INS.NOP],
@ -883,8 +883,8 @@ if (DEBUGGER) {
0x03: [Debugger.INS.LSL, Debugger.TYPE_REG | Debugger.TYPE_WORD | Debugger.TYPE_OUT | Debugger.TYPE_80286, Debugger.TYPE_MEM | Debugger.TYPE_WORD | Debugger.TYPE_IN],
0x05: [Debugger.INS.LOADALL,Debugger.TYPE_80286],
0x06: [Debugger.INS.CLTS, Debugger.TYPE_80286],
0x20: [Debugger.INS.MOV, Debugger.TYPE_REG | Debugger.TYPE_DWORD | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_CTLREG | Debugger.TYPE_DWORD | Debugger.TYPE_IN],
0x22: [Debugger.INS.MOV, Debugger.TYPE_CTLREG | Debugger.TYPE_DWORD | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_REG | Debugger.TYPE_DWORD | Debugger.TYPE_IN],
0x20: [Debugger.INS.MOV, Debugger.TYPE_MODRM | Debugger.TYPE_DWORD | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_CTLREG | Debugger.TYPE_DWORD | Debugger.TYPE_IN],
0x22: [Debugger.INS.MOV, Debugger.TYPE_CTLREG | Debugger.TYPE_DWORD | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_MODRM | Debugger.TYPE_DWORD | Debugger.TYPE_IN],
0x80: [Debugger.INS.JO, Debugger.TYPE_IMMREL | Debugger.TYPE_WORDV | Debugger.TYPE_IN | Debugger.TYPE_80386],
0x81: [Debugger.INS.JNO, Debugger.TYPE_IMMREL | Debugger.TYPE_WORDV | Debugger.TYPE_IN | Debugger.TYPE_80386],
0x82: [Debugger.INS.JC, Debugger.TYPE_IMMREL | Debugger.TYPE_WORDV | Debugger.TYPE_IN | Debugger.TYPE_80386],
@ -910,7 +910,9 @@ if (DEBUGGER) {
0xAC: [Debugger.INS.SHRD, Debugger.TYPE_MODRM | Debugger.TYPE_WORDV | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_REG | Debugger.TYPE_WORDV | Debugger.TYPE_IN, Debugger.TYPE_IMM | Debugger.TYPE_BYTE | Debugger.TYPE_IN],
0xAD: [Debugger.INS.SHRD, Debugger.TYPE_MODRM | Debugger.TYPE_WORDV | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_REG | Debugger.TYPE_WORDV | Debugger.TYPE_IN, Debugger.TYPE_IMPREG | Debugger.TYPE_CL | Debugger.TYPE_IN],
0xB6: [Debugger.INS.MOVZX, Debugger.TYPE_REG | Debugger.TYPE_WORDV | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_MODRM | Debugger.TYPE_BYTE | Debugger.TYPE_IN],
0xB7: [Debugger.INS.MOVZX, Debugger.TYPE_REG | Debugger.TYPE_DWORD | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_MODRM | Debugger.TYPE_WORD | Debugger.TYPE_IN]
0xB7: [Debugger.INS.MOVZX, Debugger.TYPE_REG | Debugger.TYPE_DWORD | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_MODRM | Debugger.TYPE_WORD | Debugger.TYPE_IN],
0xBE: [Debugger.INS.MOVSX, Debugger.TYPE_REG | Debugger.TYPE_WORDV | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_MODRM | Debugger.TYPE_BYTE | Debugger.TYPE_IN],
0xBF: [Debugger.INS.MOVSX, Debugger.TYPE_REG | Debugger.TYPE_DWORD | Debugger.TYPE_OUT | Debugger.TYPE_80386, Debugger.TYPE_MODRM | Debugger.TYPE_WORD | Debugger.TYPE_IN]
};
Debugger.aaGrpDescs = [
@ -1243,12 +1245,6 @@ if (DEBUGGER) {
this.messageDump(Messages.DOS, function onDumpDOS(s) { dbg.dumpDOS(s); });
this.setReady();
if (this.sInitCommands) {
var a = this.parseCommand(this.sInitCommands);
delete this.sInitCommands;
for (var s in a) this.doCommand(a[s]);
}
};
/**
@ -1514,7 +1510,7 @@ if (DEBUGGER) {
this.println("id physaddr blkaddr used size type");
this.println("-------- --------- -------- ------ ------ ----");
for (var i = 0; i < this.cpu.aMemBlocks.length; i++) {
var block = this.cpu.aMemBlocks[i];
var block = this.cpu.aBusBlocks[i];
if (block.type === Memory.TYPE.NONE) continue;
this.println(str.toHex(block.id) + " %" + str.toHex(i << this.cpu.blockShift) + ": " + str.toHex(block.addr) + " " + str.toHexWord(block.used) + " " + str.toHexWord(block.size) + " " + Memory.TYPE.NAMES[block.type]);
}
@ -2046,6 +2042,11 @@ if (DEBUGGER) {
{
this.println("Type ? for list of debugger commands");
this.updateStatus();
if (this.sInitCommands) {
var a = this.parseCommand(this.sInitCommands);
delete this.sInitCommands;
for (var s in a) this.doCommand(a[s]);
}
};
/**
@ -2225,7 +2226,9 @@ if (DEBUGGER) {
* we always reset and then perform a (potentially limited) restore.
*/
this.reset(true);
this.println(data? "resuming" : "powering up");
// this.println(data? "resuming" : "powering up");
if (data && this.restore) {
if (!this.restore(data)) return false;
}
@ -5358,7 +5361,7 @@ if (DEBUGGER) {
}
}
} catch(e) {
this.println("debugger sad: " + e.message);
this.println("debugger error: " + (e.stack || e.message));
result = false;
}
return result;

View file

@ -793,7 +793,7 @@ X86CPU.prototype.mapPageBlock = function(addr, fWrite)
* Now we can create a new PAGED Memory block and record the physical block info using setPhysBlock().
*/
var addrPage = addr & ~X86.LADDR.OFFSET;
var blockPage = new Memory(addrPage, 0, this.blockSize, Memory.TYPE.PAGED);
var blockPage = new Memory(addrPage, 0, 0, Memory.TYPE.PAGED);
blockPage.setPhysBlock(blockPhys, blockPDE, offPDE, blockPTE, offPTE);
var iBlock = addr >>> this.blockShift;

View file

@ -313,11 +313,9 @@ X86.opMOVcr = function MOVcr()
break;
case 0x2:
temp = this.regEDX;
if (DEBUG) this.stopCPU();
break;
case 0x3:
temp = this.regEBX;
if (DEBUG) this.stopCPU();
break;
default:
X86.opInvalid.call(this);
@ -1128,6 +1126,7 @@ X86.opMOVZXb = function MOVZXb()
X86.opMOVZXw = function MOVZXw()
{
var bModRM = this.getIPByte();
this.setDataSize(2);
this.aOpModRegWord[bModRM].call(this, X86.fnMOVX);
switch((bModRM & 0x38) >> 3) {
case 0x0:
@ -1287,6 +1286,7 @@ X86.opMOVSXb = function MOVSXb()
X86.opMOVSXw = function MOVSXw()
{
var bModRM = this.getIPByte();
this.setDataSize(2);
this.aOpModRegWord[bModRM].call(this, X86.fnMOVX);
switch((bModRM & 0x38) >> 3) {
case 0x0:

View file

@ -887,22 +887,15 @@ X86Seg.prototype.updateMode = function(fLoad, fProt)
if (fProt === undefined) {
fProt = !!(this.cpu.regCR0 & X86.CR0.MSW.PE);
}
/*
* The following properties are used for STACK segments only (ie, segSS); we want to make it easier
* for setSS() to set stack lower and upper limits, which requires knowing whether or not the segment is
* marked as EXPDOWN.
*/
this.fExpDown = false;
if (fProt) {
/*
* If we've just transitioned from real-mode, then CPL (which is meaningful for segCS only)
* should be left alone (ie, should remain at zero). On the first protected-mode CS selector
* load (normally an intersegment JMP immediately following the protected-mode switch), CPL
* (along with the rest of the segment settings) will be properly set.
*/
if (this.load !== this.loadReal) {
this.cpl = this.sel & X86.SEL.RPL;
}
this.load = this.loadProt;
this.loadIDT = this.loadIDTProt;
this.checkRead = this.checkReadProt;
@ -929,13 +922,13 @@ X86Seg.prototype.updateMode = function(fLoad, fProt)
this.fExpDown = true;
}
}
this.dpl = (this.acc & X86.DESC.ACC.DPL.MASK) >> X86.DESC.ACC.DPL.SHIFT;
if (fLoad) {
/*
* Any update to the OPERAND and ADDRESS sizes should happen only on segment loads, not simply when
* we're updating the segment register as part of a mode change. Note that there is no counterpart to
* this for real-mode, because real-mode segment loads never change these attributes.
* Any update to the following properties must occur only on segment loads, not simply when
* we're updating segment registers as part of a mode change.
*/
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.dataSize = 2;
this.dataMask = 0xffff;
@ -957,19 +950,15 @@ X86Seg.prototype.updateMode = function(fLoad, fProt)
*
* See http://www.os2museum.com/wp/himem-sys-unreal-mode-and-loadall/ for more details.
*
* Ditto for other attributes such as acc, type, ext, and the OPERAND and ADDRESS sizes, which are derived
* from the ext property. Even an explicit segment load in real-mode does not alter these properties.
*
* this.limit = 0xffff;
* this.acc = this.type = this.ext = 0;
* this.dataSize = this.addrSize = 2;
* this.dataMask = this.addrMask = 0xffff;
* Ditto for other attributes such as acc, type, and ext (and the OPERAND and ADDRESS sizes, which
* are derived from the ext property). Even an explicit segment load in real-mode does not alter those
* properties.
*
* TODO: The checkReadReal() and checkWriteReal() functions need to generate GP faults for offsets
* beyond the current real-mode limit.
*/
this.addrDesc = X86.ADDR_INVALID;
this.cpl = this.dpl = 0;
this.addrDesc = X86.ADDR_INVALID;
}
return fProt;
};