Started executing basic PDP-10 instruction diagnostic #1

This commit is contained in:
Jeff 2017-03-17 00:01:49 -07:00 • committed by Jeff Parsons
commit 9c96ec14ad
7 changed files with 362 additions and 288 deletions

View file

@ -2232,7 +2232,31 @@ PDP10.opAOBJN = function(op, acc)
*/
PDP10.opJRST = function(op, acc)
{
this.opUndefined(op);
if (acc & 0b0001) {
/*
* Enter user mode.
*/
this.setUserMode();
}
if (acc & 0b0010) {
/*
* Restore the flags.
*/
this.setPS(this.regLA);
}
if (acc & 0b0100) {
/*
* Halt the processor.
*/
this.stopCPU();
}
if (acc & 0b1000) {
/*
* Restore interrupt channel.
*/
this.opUndefined(op);
}
this.setPC(this.regEA);
};
/**

View file

@ -174,7 +174,12 @@ class CPUStatePDP10 extends CPUPDP10 {
*/
initCPU()
{
this.regEA = this.regRA = this.regOP = 0;
/*
* regEA is the last effective address, while regLA is the last fetch from an effective address
* calculation. regRA is the last reference address used to calculate the last effective address.
*/
this.regEA = this.regRA = 0;
this.regLA = this.regOP = 0;
this.regPC = this.lastPC = this.addrReset;
this.regXC = -1; // if >= 0 this supersedes regPC (refers to an opcode from XCT)
this.regBP = -1; // active byte pointer (-1 if none)
@ -287,6 +292,7 @@ class CPUStatePDP10 extends CPUPDP10 {
state.set(0, [
this.regEA,
this.regRA,
this.regLA,
this.regOP,
this.regPC,
this.regXC,
@ -320,6 +326,7 @@ class CPUStatePDP10 extends CPUPDP10 {
[
this.regEA,
this.regRA,
this.regLA,
this.regOP,
this.regPC,
this.regXC,
@ -355,6 +362,38 @@ class CPUStatePDP10 extends CPUPDP10 {
return (this.regPS & PDP10.HALF_MASK) * PDP10.HALF_SHIFT;
}
/**
* setPS(w)
*
* Sets the processor state flags in the format used by various program control operations (eg, JRST).
*
* @this {CPUStatePDP10}
* @param {number} w
*/
setPS(w)
{
w = (w / PDP10.HALF_SHIFT)|0;
this.regPS = (this.regPS & ~PDP10.PSFLAG.SET_MASK) | (w & PDP10.PSFLAG.SET_MASK);
this.regPS |= (w & PDP10.PSFLAG.USER_MODE);
if (!(w & PDP10.PSFLAG.USER_IO)) {
this.regPS &= ~PDP10.PSFLAG.USER_IO;
} else {
if (!(this.regPS & PDP10.PSFLAG.USER_MODE)) this.regPS |= PDP10.PSFLAG.USER_IO;
}
}
/**
* setUserMode()
*
* Sets the processor's USER_MODE flag.
*
* @this {CPUStatePDP10}
*/
setUserMode()
{
this.regPS |= PDP10.PSFLAG.USER_MODE;
}
/**
* readFlags()
*
@ -401,7 +440,7 @@ class CPUStatePDP10 extends CPUPDP10 {
getOpcode()
{
if ((this.regRA & PDP10.OPCODE.I_BIT)) {
this.regRA = this.readWord(this.regEA);
this.regRA = this.regLA = this.readWord(this.regEA);
} else if (this.regXC >= 0) {
this.regRA = this.regOP = this.readWord(this.regXC);
this.regXC = -1;
@ -429,7 +468,7 @@ class CPUStatePDP10 extends CPUPDP10 {
*/
this.regEA = this.regRA & PDP10.OPCODE.Y_MASK;
var x = (this.regRA >> PDP10.OPCODE.X_SHIFT) & PDP10.OPCODE.X_MASK;
if (x) this.regEA = (this.regEA + this.readWord(x)) & PDP10.ADDR_MASK;
if (x) this.regEA = (this.regEA + (this.regLA = this.readWord(x))) & PDP10.ADDR_MASK;
return (this.regRA & PDP10.OPCODE.I_BIT)? -1 : ((this.regOP / PDP10.OPCODE.A_SCALE)|0);
}

View file

@ -1546,14 +1546,13 @@ class DebuggerPDP10 extends Debugger {
} else {
n = (opCode >> PDP10.OPCODE.A_SHIFT) & PDP10.OPCODE.A_MASK;
sOperand = this.toStrBase(n, -1);
if (n) {
for (var m = 0; m < DebuggerPDP10.ALTOPS.length; m++) {
if (opNum == DebuggerPDP10.ALTOPS[m][0]) {
var opAlt = DebuggerPDP10.ALTOPS[m][n];
if (opAlt) {
sOperation = DebuggerPDP10.OPNAMES[opAlt];
sOperand = "";
}
for (var m = 0; sOperand && m < DebuggerPDP10.ALTOPS.length; m++) {
if (opNum == DebuggerPDP10.ALTOPS[m][0]) {
var opAlt = DebuggerPDP10.ALTOPS[m][n];
if (opAlt) {
sOperation = DebuggerPDP10.OPNAMES[opAlt];
sOperand = "";
break;
}
}
}
@ -2476,20 +2475,20 @@ class DebuggerPDP10 extends Debugger {
*/
loadBin(aWords, addrLoad)
{
/*
* TODO: Decide what to do about addrLoad; either drop it or use it.
*/
var nWords = 0;
var bus = this.bus;
var dbg = this.dbg;
aWords.forEach(function(w, addr) {
bus.setWordDirect(addr, w);
if (addrLoad == null) addrLoad = addr;
nWords++;
});
if (!nWords) {
this.println("no data");
} else {
this.println(nWords + " words loaded at " + this.toStrBase(addrLoad) + '-' + this.toStrBase(addrLoad + nWords - 1));
this.cpu.setPC(addrLoad || 0);
this.updateStatus();
}
}
@ -2850,7 +2849,7 @@ class DebuggerPDP10 extends Debugger {
if (dbgAddr.nBase) this.nBase = dbgAddr.nBase;
var size = (sCmd == "db"? 1 : 2);
var nWords = len || 16;
var nWords = len || 32;
var nWordsPerLine = (size == 1? 1 : 4);
var nLines = (((nWords + nWordsPerLine - 1) / nWordsPerLine)|0) || 1;
@ -2875,7 +2874,7 @@ class DebuggerPDP10 extends Debugger {
var shift = 36 - nBits;
for (var i = 0; size == 1 && shift >= 0; i++) {
var c = ((w / Math.pow(2, shift)) % Math.pow(2, nBits));
sData += this.toStrBase(c, nBits) + ' ';
sData += this.toStrBase(c, nBits);
c += (nBits == 6? 0x20 : 0);
sChars += (c < 0x20? '.' : String.fromCharCode(c));
shift -= nBits;

View file

@ -201,15 +201,16 @@ var PDP10 = {
* binary, the only options you can set relate to the operating system to be run -- which seems very hacky.
*/
PSFLAG: {
OVFL: 0o400000, // Overflow
CARRY0: 0o200000, // Carry 0
CARRY1: 0o100000, // Carry 1
FP_OVFL: 0o040000, // Floating-Point Overflow
BYTE_INT: 0o020000, // Byte Interrupt
USER_MODE: 0o010000, // Processor is in User Mode
USER_IO: 0o004000, // User I/O
FP_UNFL: 0o000100, // Floating-Point Underflow
NO_DIVIDE: 0o000040, // No Divide
OVFL: 0o400000, // Overflow
CARRY0: 0o200000, // Carry 0
CARRY1: 0o100000, // Carry 1
FP_OVFL: 0o040000, // Floating-Point Overflow
BYTE_INT: 0o020000, // Byte Interrupt
USER_MODE: 0o010000, // Processor is in User Mode
USER_IO: 0o004000, // User I/O
FP_UNFL: 0o000100, // Floating-Point Underflow
NO_DIVIDE: 0o000040, // No Divide
SET_MASK: 0o760140, // the flags that are always settable/clearable
/*
* Only the low 18 bits (above) are returned by getPS(); the following (bits 18 to 31)
* are defined for internal use only.