Protected-mode interrupt/trap gate fixes

This commit is contained in:
Jeff Parsons 2014-11-28 13:35:01 -08:00 committed by jeffpar
commit 311868bc95
19 changed files with 442 additions and 407 deletions

View file

@ -57,8 +57,8 @@ function C1PCPU(parmsCPU)
Component.call(this, "C1PCPU", parmsCPU);
this.clearRegs();
this.aFlags.fPowered = false;
this.aFlags.fRunning = false;
this.bitField.fPowered = false;
this.bitField.fRunning = false;
this.fAutoStart = parmsCPU["autoStart"];
/*
@ -482,8 +482,9 @@ Component.subclass(Component, C1PCPU);
*/
C1PCPU.prototype.reset = function(fPowerOn)
{
if (this.aFlags.fRunning)
if (this.bitField.fRunning) {
this.halt();
}
this.clearRegs();
this.regPC = this.getWord(this.VECTOR_RESET);
this.clearError(); // clear any fatal error/exception
@ -515,10 +516,11 @@ C1PCPU.prototype.setBinding = function(sHTMLType, sBinding, control)
this.bindings[sBinding] = control;
control.onclick = function(cpu) {
return function() {
if (!cpu.aFlags.fRunning)
if (!cpu.bitField.fRunning) {
cpu.run();
else
} else {
cpu.halt();
}
};
}(this);
fBound = true;
@ -578,7 +580,7 @@ C1PCPU.prototype.setBuffer = function(abMemory, start, end)
*/
C1PCPU.prototype.setPower = function(fOn, cmp)
{
if (fOn && !this.aFlags.fPowered) {
if (fOn && !this.bitField.fPowered) {
this.cmp = cmp;
/*
* Attach the Debugger, if any, to the CPU, so that the CPU can periodically
@ -606,7 +608,7 @@ C1PCPU.prototype.setPower = function(fOn, cmp)
};
}(video);
}
this.aFlags.fPowered = true;
this.bitField.fPowered = true;
this.reset(true);
this.update();
}
@ -879,7 +881,7 @@ C1PCPU.prototype.displayStatus = function()
*/
C1PCPU.prototype.isRunning = function()
{
return this.aFlags.fRunning;
return this.bitField.fRunning;
};
/**
@ -1050,7 +1052,7 @@ C1PCPU.prototype.run = function()
if (this.cmp) this.cmp.stop(this.msRunStart, this.nRunCycles);
return;
}
if (!this.aFlags.fRunning) {
if (!this.bitField.fRunning) {
/*
* setSpeed() without a speed parameter leaves the selected speed in place, but also resets the
* cycle counter and timestamp for the current series of run() calls, calculates the maximum number
@ -1059,7 +1061,7 @@ C1PCPU.prototype.run = function()
*/
this.setSpeed();
if (this.cmp) this.cmp.start();
this.aFlags.fRunning = true;
this.bitField.fRunning = true;
if (this.bindings["run"]) this.bindings["run"].innerHTML = "Halt";
this.setFocus();
}
@ -1106,7 +1108,7 @@ C1PCPU.prototype.run = function()
this.nCyclesNextYield += this.nCyclesPerYield;
break;
}
} while (this.aFlags.fRunning);
} while (this.bitField.fRunning);
}
catch (e) {
this.halt();
@ -1267,8 +1269,8 @@ C1PCPU.prototype.halt = function()
this.isBusy(true);
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
if (this.aFlags.fRunning) {
this.aFlags.fRunning = false;
if (this.bitField.fRunning) {
this.bitField.fRunning = false;
if (this.bindings["run"]) this.bindings["run"].innerHTML = "Run";
}
};
@ -1302,7 +1304,7 @@ C1PCPU.prototype.update = function()
*/
C1PCPU.prototype.getCycles = function()
{
return (this.aFlags.fRunning? this.nRunCycles + this.nBurstCycles - this.nStepCycles : 0);
return (this.bitField.fRunning? this.nRunCycles + this.nBurstCycles - this.nStepCycles : 0);
};
/**