All PDP-11 opcode decoders implemented now

This commit is contained in:
Jeff 2016-09-28 13:45:36 -07:00 committed by Jeff Parsons
commit 0ad98dc68b
9 changed files with 408 additions and 389 deletions

View file

@ -1159,22 +1159,9 @@ PDP11.opMARK = function(opCode)
*/
PDP11.opMFPD = function(opCode)
{
var src;
if (!(opCode & PDP11.OPMODE.MASK)) {
var reg = opCode & 7;
if (reg != 6 || ((this.regPSW >> 2) & PDP11.PSW.PMODE) === (this.regPSW & PDP11.PSW.PMODE)) {
src = this.regsGen[reg];
} else {
src = this.regsAltStack[(this.regPSW >> 12) & 3];
}
} else {
var addr = this.getVirtualByMode(opCode, PDP11.ACCESS.WORD);
this.mmuMode = (this.regPSW >> 12) & 3;
src = this.readWordFromVirtual(addr | 0x10000);
this.mmuMode = (this.regPSW >> 14) & 3;
}
this.pushWord(src);
this.updateNZFlags(src);
var data = this.readWordFromPrevSpace(opCode, PDP11.ACCESS.DSPACE);
this.pushWord(data);
this.updateNZFlags(data);
this.nStepCycles -= 1;
};
@ -1186,40 +1173,9 @@ PDP11.opMFPD = function(opCode)
*/
PDP11.opMFPI = function(opCode)
{
/*
* TODO: Implement
*/
this.regOp = -1;
this.nStepCycles -= 1;
};
/**
* opMFPS(opCode)
*
* @this {CPUStatePDP11}
* @param {number} opCode
*/
PDP11.opMFPS = function(opCode)
{
/*
* TODO: Implement
*/
this.regOp = -1;
this.nStepCycles -= 1;
};
/**
* opMFPT(opCode)
*
* @this {CPUStatePDP11}
* @param {number} opCode
*/
PDP11.opMFPT = function(opCode)
{
/*
* TODO: Implement
*/
this.regOp = -1;
var data = this.readWordFromPrevSpace(opCode, PDP11.ACCESS.ISPACE);
this.pushWord(data);
this.updateNZFlags(data);
this.nStepCycles -= 1;
};
@ -1256,10 +1212,9 @@ PDP11.opMOVB = function(opCode)
*/
PDP11.opMTPD = function(opCode)
{
/*
* TODO: Implement
*/
this.regOp = -1;
var data = this.popWord();
this.writeWordToPrevSpace(opCode, PDP11.ACCESS.DSPACE, data);
this.updateNZFlags(data);
this.nStepCycles -= 1;
};
@ -1271,25 +1226,9 @@ PDP11.opMTPD = function(opCode)
*/
PDP11.opMTPI = function(opCode)
{
/*
* TODO: Implement
*/
this.regOp = -1;
this.nStepCycles -= 1;
};
/**
* opMTPS(opCode)
*
* @this {CPUStatePDP11}
* @param {number} opCode
*/
PDP11.opMTPS = function(opCode)
{
/*
* TODO: Implement
*/
this.regOp = -1;
var data = this.popWord();
this.writeWordToPrevSpace(opCode, PDP11.ACCESS.ISPACE, data);
this.updateNZFlags(data);
this.nStepCycles -= 1;
};
@ -1649,10 +1588,7 @@ PDP11.opTSTB = function(opCode)
*/
PDP11.opWAIT = function(opCode)
{
/*
* TODO: Implement
*/
this.regOp = -1;
this.checkInterruptDelay();
this.nStepCycles -= 1;
};
@ -1969,7 +1905,7 @@ PDP11.aOps000X_1170 = [
PDP11.opIOT, // 0x0004
PDP11.opRESET, // 0x0005
PDP11.opRTT, // 0x0006
PDP11.opMFPT, // 0x0007
PDP11.opUndefined, // 0x0007
PDP11.opUndefined, // 0x0008
PDP11.opUndefined, // 0x0009
PDP11.opUndefined, // 0x000A
@ -2068,8 +2004,8 @@ PDP11.aOps8CXn_1170 = [
];
PDP11.aOps8DXn_1170 = [
PDP11.opMTPS, // 0x8D0n
PDP11.opUndefined, // 0x8D0n
PDP11.opMFPD, // 0x8D4n
PDP11.opMTPD, // 0x8D8n
PDP11.opMFPS // 0x8DCn
PDP11.opUndefined // 0x8DCn
];

View file

@ -601,6 +601,24 @@ CPUStatePDP11.prototype.interrupt = function(delay, priority, vector, callback)
this.priorityReview = 2;
};
/**
* checkInterruptDelay()
*
* @this {CPUStatePDP11}
*/
CPUStatePDP11.prototype.checkInterruptDelay = function()
{
var delay = 0;
for (var i = this.interruptQueue.length; --i >= 0;) {
delay += this.interruptQueue[i].delay;
this.interruptQueue[i].delay = 0;
}
if (!delay && this.runState === 0) {
this.runState = 2; // wait
this.endBurst();
}
};
/**
* checkInterruptQueue()
*
@ -1410,6 +1428,68 @@ CPUStatePDP11.prototype.getAddrVirtual = function(addressMode, accessFlags)
return this.mapVirtualToPhysical(this.getVirtualByMode(addressMode, accessFlags), accessFlags);
};
/**
* readWordFromPrevSpace(opCode, accessFlags)
*
* @this {CPUStatePDP11}
* @param {number} opCode
* @param {number} accessFlags (really just PDP11.ACCESS.DSPACE or PDP11.ACCESS.ISPACE)
* @return {number}
*/
CPUStatePDP11.prototype.readWordFromPrevSpace = function(opCode, accessFlags)
{
var src;
if (!(opCode & PDP11.OPMODE.MASK)) {
var reg = opCode & 7;
if (reg != 6 || ((this.regPSW >> 2) & PDP11.PSW.PMODE) === (this.regPSW & PDP11.PSW.PMODE)) {
src = this.regsGen[reg];
} else {
src = this.regsAltStack[(this.regPSW >> 12) & 3];
}
} else {
var addr = this.getVirtualByMode(opCode, PDP11.ACCESS.WORD);
if (!(accessFlags & PDP11.ACCESS.DSPACE)) {
if ((this.regPSW & 0xf000) !== 0xf000) addr &= 0xffff;
}
this.mmuMode = (this.regPSW >> 12) & 3;
src = this.readWordFromVirtual(addr | (accessFlags & PDP11.ACCESS.DSPACE));
this.mmuMode = (this.regPSW >> 14) & 3;
}
return src;
};
/**
* writeWordToPrevSpace(opCode, accessFlags, data)
*
* @this {CPUStatePDP11}
* @param {number} opCode
* @param {number} accessFlags (really just PDP11.ACCESS.DSPACE or PDP11.ACCESS.ISPACE)
* @param {number} data
* @return {number}
*/
CPUStatePDP11.prototype.writeWordToPrevSpace = function(opCode, accessFlags, data)
{
if (!(this.MMR0 & 0xe000)) {
this.MMR1 = 0x16;
}
if (!(opCode & 0x38)) {
var reg = opCode & 7;
if (reg != 6 || ((this.regPSW >> 2) & PDP11.PSW.PMODE) === (this.regPSW & PDP11.PSW.PMODE)) {
this.regsGen[reg] = data;
} else {
this.regsAltStack[(this.regPSW >> 12) & 3] = data;
}
} else {
var addr = this.getVirtualByMode(opCode, PDP11.ACCESS.WORD);
if (!(accessFlags & PDP11.ACCESS.DSPACE)) addr &= 0xffff;
this.mmuMode = (this.regPSW >> 12) & 3;
addr = this.mapVirtualToPhysical(addr | (accessFlags & PDP11.ACCESS.DSPACE), PDP11.ACCESS.WRITE);
this.mmuMode = (this.regPSW >> 14) & 3;
this.writeWordToPhysical(addr, data);
}
return data;
};
/**
* readWordByMode(addressMode)
*

View file

@ -383,7 +383,7 @@ if (DEBUGGER) {
0x0004: [DebuggerPDP11.OPS.IOT], // 000004
0x0005: [DebuggerPDP11.OPS.RESET], // 000005
0x0006: [DebuggerPDP11.OPS.RTT], // 000006
0x0007: [DebuggerPDP11.OPS.MFPT], // 000007
0x0007: [DebuggerPDP11.OPS.MFPT], // 000007 (only on PDP-11/44 & KB11-EM?)
0x00A0: [DebuggerPDP11.OPS.NOP],
0x00A1: [DebuggerPDP11.OPS.CLC],
0x00A2: [DebuggerPDP11.OPS.CLV],

View file

@ -228,7 +228,8 @@ var PDP11 = {
WRITE: 0x04,
UPDATE: 0x06,
VIRT: 0x08, // getVirtualByMode() leaves bit 17 clear if this is set (otherwise the caller would have to clear it again)
DSPACE: 0x10000, // getVirtualByMode() sets bit 17 in any 16-bit virtual address that refers to D space (as opposed to I space)
ISPACE: 0x00000,
DSPACE: 0x10000 // getVirtualByMode() sets bit 17 in any 16-bit virtual address that refers to D space (as opposed to I space)
},
/*
* Internal flags passed to writeByteByMode(), etc.