SRC operands must be fetched before DST operands

This commit is contained in:
Jeff 2016-10-03 16:50:39 -07:00 committed by Jeff Parsons
commit a254abc7dc
6 changed files with 382 additions and 372 deletions

View file

@ -499,7 +499,7 @@ PDP11.opASH = function(opCode)
{
/*
* NOTE: Because readWordByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* the srcMode and srcReg properties will be updated instead of the dstMode and dstReg properties.
* this.srcMode and this.srcReg must be used instead of this.dstMode and this.dstReg.
*/
var src = this.readWordByMode(opCode);
var reg = (opCode >> 6) & 7;
@ -538,7 +538,7 @@ PDP11.opASHC = function(opCode)
{
/*
* NOTE: Because readWordByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* the srcMode and srcReg properties will be updated instead of the dstMode and dstReg properties.
* this.srcMode and this.srcReg must be used instead of this.dstMode and this.dstReg.
*/
var src = this.readWordByMode(opCode);
var reg = (opCode >> 6) & 7;
@ -702,13 +702,18 @@ PDP11.opBIT = function(opCode)
{
/*
* NOTE: Because readWordByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* the srcMode and srcReg properties need to be copied before we READ the SRCMODE field of opCode.
* the srcMode and srcReg properties need to be copied before they get overwritten.
*/
var src = this.readWordByMode(opCode >> PDP11.SRCMODE.SHIFT);
var srcMode = this.srcMode;
var srcReg = this.srcReg;
/*
* NOTE: Because readWordByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* this.srcMode and this.srcReg must be used instead of this.dstMode and this.dstReg.
*/
var dst = this.readWordByMode(opCode);
var dstMode = this.srcMode;
var dstReg = this.srcReg;
this.updateNZVFlags(this.readWordByMode(opCode >> PDP11.SRCMODE.SHIFT) & dst);
this.nStepCycles -= (dstMode? (3 + 1) + (this.srcReg && dstReg >= 6? 1 : 0) : (this.srcMode? (3 + 1) : (2 + 1)) + (dstReg == 7? 2 : 0));
this.updateNZVFlags(src & dst);
this.nStepCycles -= (this.srcMode? (3 + 1) + (srcReg && this.srcReg >= 6? 1 : 0) : (srcMode? (3 + 1) : (2 + 1)) + (this.srcReg == 7? 2 : 0));
};
/**
@ -721,13 +726,18 @@ PDP11.opBITB = function(opCode)
{
/*
* NOTE: Because readByteByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* the srcMode and srcReg properties need to be copied before we READ the SRCMODE field of opCode.
* the srcMode and srcReg properties need to be copied before they get overwritten.
*/
var src = this.readByteByMode(opCode >> PDP11.SRCMODE.SHIFT);
var srcMode = this.srcMode;
var srcReg = this.srcReg;
/*
* NOTE: Because readByteByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* this.srcMode and this.srcReg must be used instead of this.dstMode and this.dstReg.
*/
var dst = this.readByteByMode(opCode);
var dstMode = this.srcMode;
var dstReg = this.srcReg;
this.updateNZVFlags((this.readByteByMode(opCode >> PDP11.SRCMODE.SHIFT) & dst) << 8);
this.nStepCycles -= (dstMode? (3 + 1) + (this.srcReg && dstReg >= 6? 1 : 0) : (this.srcMode? (3 + 1) : (2 + 1)) + (dstReg == 7? 2 : 0));
this.updateNZVFlags((src & dst) << 8);
this.nStepCycles -= (this.srcMode? (3 + 1) + (srcReg && this.srcReg >= 6? 1 : 0) : (srcMode? (3 + 1) : (2 + 1)) + (this.srcReg == 7? 2 : 0));
};
/**
@ -985,19 +995,23 @@ PDP11.opCMP = function(opCode)
{
/*
* NOTE: Because readWordByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* the srcMode and srcReg properties need to be copied before we READ the SRCMODE field of opCode.
* the srcMode and srcReg properties need to be copied before they get overwritten.
*/
var src = this.readWordByMode(opCode >> PDP11.SRCMODE.SHIFT);
var srcMode = this.srcMode;
var srcReg = this.srcReg;
/*
* NOTE: Because readWordByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* this.srcMode and this.srcReg must be used instead of this.dstMode and this.dstReg.
*/
var dst = this.readWordByMode(opCode);
var dstMode = this.srcMode;
var dstReg = this.srcReg;
var src = this.readWordByMode(opCode >> PDP11.SRCMODE.SHIFT);
var result = src - dst;
/*
* NOTE: CMP calculates (src - dst) rather than (dst - src), so when we call updateSubFlags(),
* we must reverse the order of the src and dst parameters.
*/
this.updateSubFlags(result, dst, src);
this.nStepCycles -= (dstMode? (3 + 1) + (this.srcReg && dstReg >= 6? 1 : 0) : (this.srcMode? (3 + 1) : (2 + 1)) + (dstReg == 7? 2 : 0));
this.nStepCycles -= (this.srcMode? (3 + 1) + (srcReg && this.srcReg >= 6? 1 : 0) : (srcMode? (3 + 1) : (2 + 1)) + (this.srcReg == 7? 2 : 0));
};
/**
@ -1010,19 +1024,23 @@ PDP11.opCMPB = function(opCode)
{
/*
* NOTE: Because readByteByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* the srcMode and srcReg properties need to be copied before we READ the SRCMODE field of opCode.
* the srcMode and srcReg properties need to be copied before they get overwritten.
*/
var src = this.readByteByMode(opCode >> PDP11.SRCMODE.SHIFT) << 8;
var srcMode = this.srcMode;
var srcReg = this.srcReg;
/*
* NOTE: Because readByteByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* this.srcMode and this.srcReg must be used instead of this.dstMode and this.dstReg.
*/
var dst = this.readByteByMode(opCode) << 8;
var dstMode = this.srcMode;
var dstReg = this.srcReg;
var src = this.readByteByMode(opCode >> PDP11.SRCMODE.SHIFT) << 8;
var result = src - dst;
/*
* NOTE: CMP calculates (src - dst) rather than (dst - src), so when we call updateSubFlags(),
* we must reverse the order of the src and dst parameters.
*/
this.updateSubFlags(result, dst, src);
this.nStepCycles -= (dstMode? (3 + 1) + (this.srcReg && dstReg >= 6? 1 : 0) : (this.srcMode? (3 + 1) : (2 + 1)) + (dstReg == 7? 2 : 0));
this.nStepCycles -= (this.srcMode? (3 + 1) + (srcReg && this.srcReg >= 6? 1 : 0) : (srcMode? (3 + 1) : (2 + 1)) + (this.srcReg == 7? 2 : 0));
};
/**
@ -1698,7 +1716,7 @@ PDP11.opTST = function(opCode)
{
/*
* NOTE: Because readWordByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* the srcMode and srcReg properties will be updated instead of the dstMode and dstReg properties.
* this.srcMode and this.srcReg must be used instead of this.dstMode and this.dstReg.
*/
var result = this.readWordByMode(opCode);
this.assert(!(result & ~0xffff)); // assert that C flag will be clear
@ -1716,7 +1734,7 @@ PDP11.opTSTB = function(opCode)
{
/*
* NOTE: Because readByteByMode() is being used to READ (not WRITE) the DSTMODE field of opCode,
* the srcMode and srcReg properties will be updated instead of the dstMode and dstReg properties.
* this.srcMode and this.srcReg must be used instead of this.dstMode and this.dstReg.
*/
var result = this.readByteByMode(opCode);
this.assert(!(result & ~0xff)); // assert that C flag will be clear

View file

@ -216,7 +216,7 @@ CPUStatePDP11.prototype.resetRegs = function()
/**
* initMemoryAccess()
*
* Define getAddr(), readWord(), etc, handlers appropriate for the current MMU mode, in order to
* Define getAddr() handlers appropriate for the current MMU mode, in order to
* eliminate unnecessary calls to mapVirtualToPhysical().
*
* @this {CPUStatePDP11}
@ -226,11 +226,9 @@ CPUStatePDP11.prototype.initMemoryAccess = function()
if (this.mmuEnable) {
this.addrDSpace = PDP11.ACCESS.DSPACE;
this.getAddr = this.getAddrVirtual;
this.readWord = this.readWordFromVirtual;
} else {
this.addrDSpace = 0;
this.getAddr = this.getAddrPhysical;
this.readWord = this.readWordFromPhysical;
}
};
@ -1563,12 +1561,7 @@ CPUStatePDP11.prototype.readWordByMode = function(addressMode)
this.srcMode = 0;
result = this.regsGen[this.srcReg = addressMode & PDP11.OPREG.MASK];
} else {
/*
* NOTE: This used to call readWordFromPhysical(), after calling getAddrVirtual(), but the latter is
* just a wrapper around mapVirtualToPhysical() on the result from getVirtualByMode(), so now we call
* getVirtualByMode() directly, knowing that the current readWord() will call the correct function.
*/
result = this.readWord(this.getVirtualByMode(addressMode, PDP11.ACCESS.READ_WORD));
result = this.readWordFromPhysical(this.getAddr(addressMode, PDP11.ACCESS.READ_WORD));
}
return result;
};

View file

@ -2878,13 +2878,12 @@ if (DEBUGGER) {
{
var sMsg;
if (this.flags.running) {
sMsg = "halting";
if (!fQuiet) this.println("halting");
this.stopCPU();
} else {
if (this.isBusy(true)) return;
sMsg = "already halted";
if (!fQuiet) this.println("already halted");
}
if (!fQuiet) this.println(sMsg);
};
/**