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);
};
/**

View file

@ -578,8 +578,8 @@ if (DEBUGGER) {
*/
C1PDebugger.prototype.setPower = function(fOn, cmp)
{
if (fOn && !this.aFlags.fPowered) {
this.aFlags.fPowered = true;
if (fOn && !this.bitField.fPowered) {
this.bitField.fPowered = true;
this.cpu = cmp.getComponentByType("cpu");
}
};

View file

@ -217,7 +217,7 @@ function C1PDiskController(parmsDC)
{
Component.call(this, "C1PDiskController", parmsDC);
this.aFlags.fPowered = false;
this.bitField.fPowered = false;
/*
* Our DiskController simulates the combination of an MC6820 PIA and an MC6850 ACIA.
@ -735,8 +735,8 @@ C1PDiskController.prototype.setBuffer = function(abMemory, start, end, cpu)
*/
C1PDiskController.prototype.setPower = function(fOn, cmp)
{
if (fOn && !this.aFlags.fPowered) {
this.aFlags.fPowered = true;
if (fOn && !this.bitField.fPowered) {
this.bitField.fPowered = true;
if (DEBUGGER) this.dbg = cmp.getComponentByType("debugger");
}
};

View file

@ -122,7 +122,7 @@ function C1PKeyboard(parmsKbd)
{
Component.call(this, "C1PKeyboard", parmsKbd);
this.aFlags.fPowered = false;
this.bitField.fPowered = false;
this.nDefaultModel = parmsKbd['model'];
/*
@ -515,8 +515,8 @@ C1PKeyboard.prototype.setModel = function(nModel)
*/
C1PKeyboard.prototype.setPower = function(fOn, cmp)
{
if (fOn && !this.aFlags.fPowered) {
this.aFlags.fPowered = true;
if (fOn && !this.bitField.fPowered) {
this.bitField.fPowered = true;
this.cmp = cmp;
if (DEBUGGER) this.dbg = cmp.getComponentByType("debugger");
}

View file

@ -44,7 +44,7 @@ function C1PPanel(parmsPanel)
{
Component.call(this, "C1PPanel", parmsPanel);
this.aFlags.fPowered = false;
this.bitField.fPowered = false;
}
Component.subclass(Component, C1PPanel);
@ -76,8 +76,8 @@ C1PPanel.prototype.setBinding = function(sHTMLType, sBinding, control)
*/
C1PPanel.prototype.setPower = function(fOn, cmp)
{
if (fOn && !this.aFlags.fPowered) {
this.aFlags.fPowered = true;
if (fOn && !this.bitField.fPowered) {
this.bitField.fPowered = true;
this.cmp = cmp;
this.cpu = cmp.getComponentByType("cpu");
this.kbd = cmp.getComponentByType("keyboard");

View file

@ -108,8 +108,8 @@ C1PROM.prototype.setBuffer = function(abMemory, start, end, cpu)
*/
C1PROM.prototype.setPower = function(fOn, cmp)
{
if (fOn && !this.aFlags.fPowered) {
this.aFlags.fPowered = true;
if (fOn && !this.bitField.fPowered) {
this.bitField.fPowered = true;
if (DEBUGGER) this.dbg = cmp.getComponentByType("debugger");
}
};

View file

@ -44,7 +44,7 @@ function C1PSerialPort(parmsSerial)
{
Component.call(this, "C1PSerialPort", parmsSerial);
this.aFlags.fPowered = false;
this.bitField.fPowered = false;
this.fDemo = parmsSerial['demo'];
this.STATUS_NONE = 0x00;
@ -202,8 +202,8 @@ C1PSerialPort.prototype.setBuffer = function(abMemory, start, end, cpu)
*/
C1PSerialPort.prototype.setPower = function(fOn, cmp)
{
if (fOn && !this.aFlags.fPowered) {
this.aFlags.fPowered = true;
if (fOn && !this.bitField.fPowered) {
this.bitField.fPowered = true;
this.cmp = cmp;
this.kbd = cmp.getComponentByType("keyboard");
if (DEBUGGER) this.dbg = cmp.getComponentByType("debugger");

View file

@ -307,8 +307,8 @@ C1PVideo.prototype.setPower = function(fOn, cmp)
* it ourselves, too. This also means that updateScreen() need check only fPower and not isReady(),
* since we guarantee that the former implies the latter.
*/
if (fOn && !this.aFlags.fPowered && this.isReady()) {
this.aFlags.fPowered = true;
if (fOn && !this.bitField.fPowered && this.isReady()) {
this.bitField.fPowered = true;
if (DEBUGGER) this.dbg = cmp.getComponentByType("debugger");
/*
* If we have an associated keyboard, then ensure that the keyboard will be notified whenever
@ -327,8 +327,8 @@ C1PVideo.prototype.setPower = function(fOn, cmp)
}
}
else
if (!fOn && this.aFlags.fPowered) {
this.aFlags.fPowered = false;
if (!fOn && this.bitField.fPowered) {
this.bitField.fPowered = false;
/*
* This is where we would add some method of blanking the display, without the disturbing the video
* buffer contents, and blocking all further updates to the display.
@ -441,7 +441,7 @@ C1PVideo.prototype.initScreen = function()
C1PVideo.prototype.updateScreen = function()
{
var offset = 0;
if (this.aFlags.fPowered) {
if (this.bitField.fPowered) {
while (offset < this.cbScreen) {
var b = this.abMem[this.offVideo + offset];
if (this.abScreen[offset] != b) {