More PDP-11 debugger work
This commit is contained in:
parent
6f349612d8
commit
cc70c05c07
6 changed files with 545 additions and 456 deletions
|
|
@ -22,7 +22,7 @@ indent_style = space
|
|||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{xml,xsl}]
|
||||
[*.{php,xml,xsl}]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
|
|
|||
|
|
@ -131,13 +131,13 @@ CPUStatePDP11.prototype.initRegs = function()
|
|||
this.flagV = 0x8000; // PSW V bit
|
||||
this.flagZ = 0xffff; // ~ PSW Z bit
|
||||
this.PSW = 0xf; // PSW other bits
|
||||
this.regsCur = [ // Current R0 - R7
|
||||
this.regsGen = [ // General R0 - R7
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
];
|
||||
this.regsAlt = [ // Alternate R0 - R5
|
||||
0, 0, 0, 0, 0, 0
|
||||
];
|
||||
this.regsStack = [ // Alternate R6 (kernel, super, illegal, user)
|
||||
this.regsAltStack = [ // Alternate R6 (kernel, super, illegal, user)
|
||||
0, 0, 0, 0
|
||||
];
|
||||
this.memory = []; // Main memory (words)
|
||||
|
|
@ -258,8 +258,9 @@ CPUStatePDP11.prototype.setBinding = function(sHTMLType, sBinding, control, sVal
|
|||
switch (sBinding) {
|
||||
case "PC":
|
||||
case "PSW":
|
||||
case "SF":
|
||||
case "NF":
|
||||
case "ZF":
|
||||
case "VF":
|
||||
case "CF":
|
||||
this.bindings[sBinding] = control;
|
||||
this.cLiveRegs++;
|
||||
|
|
@ -279,18 +280,18 @@ CPUStatePDP11.prototype.setBinding = function(sHTMLType, sBinding, control, sVal
|
|||
*/
|
||||
CPUStatePDP11.prototype.clearCF = function()
|
||||
{
|
||||
this.resultZeroCarry &= 0xff;
|
||||
// this.resultZeroCarry &= 0xff;
|
||||
};
|
||||
|
||||
/**
|
||||
* getCF()
|
||||
*
|
||||
* @this {CPUStatePDP11}
|
||||
* @return {number} 0 or 1 (PDP11.PSW.CF)
|
||||
* @return {number} 0 or PDP11.PSW.CF
|
||||
*/
|
||||
CPUStatePDP11.prototype.getCF = function()
|
||||
{
|
||||
return (this.resultZeroCarry & 0x100)? PDP11.PSW.CF : 0;
|
||||
return (this.flagC & 0x10000)? PDP11.PSW.CF: 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -300,18 +301,38 @@ CPUStatePDP11.prototype.getCF = function()
|
|||
*/
|
||||
CPUStatePDP11.prototype.setCF = function()
|
||||
{
|
||||
this.resultZeroCarry |= 0x100;
|
||||
// this.resultZeroCarry |= 0x100;
|
||||
};
|
||||
|
||||
/**
|
||||
* updateCF(CF)
|
||||
* clearVF()
|
||||
*
|
||||
* @this {CPUStatePDP11}
|
||||
* @param {number} CF (0x000 or 0x100)
|
||||
*/
|
||||
CPUStatePDP11.prototype.updateCF = function(CF)
|
||||
CPUStatePDP11.prototype.clearVF = function()
|
||||
{
|
||||
this.resultZeroCarry = (this.resultZeroCarry & 0xff) | CF;
|
||||
// this.resultZeroCarry |= 0xff;
|
||||
};
|
||||
|
||||
/**
|
||||
* getVF()
|
||||
*
|
||||
* @this {CPUStatePDP11}
|
||||
* @return {number} 0 or PDP11.PSW.VF
|
||||
*/
|
||||
CPUStatePDP11.prototype.getVF = function()
|
||||
{
|
||||
return (this.flagV & 0x8000)? PDP11.PSW.VF: 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* setVF()
|
||||
*
|
||||
* @this {CPUStatePDP11}
|
||||
*/
|
||||
CPUStatePDP11.prototype.setVF = function()
|
||||
{
|
||||
// this.resultZeroCarry &= ~0xff;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -321,7 +342,7 @@ CPUStatePDP11.prototype.updateCF = function(CF)
|
|||
*/
|
||||
CPUStatePDP11.prototype.clearZF = function()
|
||||
{
|
||||
this.resultZeroCarry |= 0xff;
|
||||
// this.resultZeroCarry |= 0xff;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -332,7 +353,7 @@ CPUStatePDP11.prototype.clearZF = function()
|
|||
*/
|
||||
CPUStatePDP11.prototype.getZF = function()
|
||||
{
|
||||
return (this.resultZeroCarry & 0xff)? 0 : PDP11.PSW.ZF;
|
||||
return (this.flagZ & 0xffff)? 0 : PDP11.PSW.ZF;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -342,39 +363,38 @@ CPUStatePDP11.prototype.getZF = function()
|
|||
*/
|
||||
CPUStatePDP11.prototype.setZF = function()
|
||||
{
|
||||
this.resultZeroCarry &= ~0xff;
|
||||
// this.resultZeroCarry &= ~0xff;
|
||||
};
|
||||
|
||||
/**
|
||||
* clearSF()
|
||||
* clearNF()
|
||||
*
|
||||
* @this {CPUStatePDP11}
|
||||
*/
|
||||
CPUStatePDP11.prototype.clearSF = function()
|
||||
CPUStatePDP11.prototype.clearNF = function()
|
||||
{
|
||||
// if (this.getSF()) this.resultParitySign ^= 0xc0;
|
||||
// if (this.getNF()) this.resultParitySign ^= 0xc0;
|
||||
};
|
||||
|
||||
/**
|
||||
* getSF()
|
||||
* getNF()
|
||||
*
|
||||
* @this {CPUStatePDP11}
|
||||
* @return {number} 0 or PDP11.PSW.SF
|
||||
* @return {number} 0 or PDP11.PSW.NF
|
||||
*/
|
||||
CPUStatePDP11.prototype.getSF = function()
|
||||
CPUStatePDP11.prototype.getNF = function()
|
||||
{
|
||||
// return (this.resultParitySign & 0x80)? PDP11.PSW.SF : 0;
|
||||
return 0;
|
||||
return (this.flagN >> (15 - PDP11.PSW.NF_SHIFT)) & PDP11.PSW.NF;
|
||||
};
|
||||
|
||||
/**
|
||||
* setSF()
|
||||
* setNF()
|
||||
*
|
||||
* @this {CPUStatePDP11}
|
||||
*/
|
||||
CPUStatePDP11.prototype.setSF = function()
|
||||
CPUStatePDP11.prototype.setNF = function()
|
||||
{
|
||||
// if (!this.getSF()) this.resultParitySign ^= 0xc0;
|
||||
// if (!this.getNF()) this.resultParitySign ^= 0xc0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -385,7 +405,7 @@ CPUStatePDP11.prototype.setSF = function()
|
|||
*/
|
||||
CPUStatePDP11.prototype.getPC = function()
|
||||
{
|
||||
return this.regsCur[7];
|
||||
return this.regsGen[7];
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -396,7 +416,7 @@ CPUStatePDP11.prototype.getPC = function()
|
|||
*/
|
||||
CPUStatePDP11.prototype.setPC = function(addr)
|
||||
{
|
||||
this.regsCur[7] = addr;
|
||||
this.regsGen[7] = addr;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -407,7 +427,7 @@ CPUStatePDP11.prototype.setPC = function(addr)
|
|||
*/
|
||||
CPUStatePDP11.prototype.getPSW = function()
|
||||
{
|
||||
return (this.PSW & ~PDP11.PSW.RESULT) | (this.getSF() | this.getZF() | this.getCF());
|
||||
return (this.PSW & ~PDP11.PSW.FLAGS) | (this.getNF() | this.getZF() | this.getVF() | this.getCF());
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -418,7 +438,7 @@ CPUStatePDP11.prototype.getPSW = function()
|
|||
*/
|
||||
CPUStatePDP11.prototype.getSP = function()
|
||||
{
|
||||
return this.regsCur[6];
|
||||
return this.regsGen[6];
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -481,11 +501,11 @@ CPUStatePDP11.prototype.requestHALT = function()
|
|||
* @this {CPUStatePDP11}
|
||||
* @param {string} sReg
|
||||
* @param {number} nValue
|
||||
* @param {number} [cch] (default is 2 hex digits)
|
||||
* @param {number} [cch] (default is 4 hex digits)
|
||||
*/
|
||||
CPUStatePDP11.prototype.updateReg = function(sReg, nValue, cch)
|
||||
{
|
||||
this.displayValue(sReg, nValue, cch || 2);
|
||||
this.displayValue(sReg, nValue, cch || 4);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -503,8 +523,9 @@ CPUStatePDP11.prototype.updateStatus = function(fForce)
|
|||
if (fForce || !this.flags.running || this.flags.displayLiveRegs) {
|
||||
var regPSW = this.getPSW();
|
||||
this.updateReg("PSW", regPSW, 4);
|
||||
this.updateReg("SF", (regPSW & PDP11.PSW.SF)? 1 : 0, 1);
|
||||
this.updateReg("NF", (regPSW & PDP11.PSW.NF)? 1 : 0, 1);
|
||||
this.updateReg("ZF", (regPSW & PDP11.PSW.ZF)? 1 : 0, 1);
|
||||
this.updateReg("VF", (regPSW & PDP11.PSW.VF)? 1 : 0, 1);
|
||||
this.updateReg("CF", (regPSW & PDP11.PSW.CF)? 1 : 0, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -568,38 +589,46 @@ CPUStatePDP11.prototype.interrupt = function(delay, priority, vector, callback)
|
|||
/**
|
||||
* writePSW(newPSW)
|
||||
*
|
||||
* writePSW() is used to update the CPU Processor Status Word. The PSW should generally
|
||||
* be written through this routine so that changes can be tracked properly, for example
|
||||
* the correct register set, the current memory management mode, etc. An exception is
|
||||
* SPL which writes the priority directly. Note that that N, Z, V, and C flags are
|
||||
* actually stored separately to the PSW property for performance reasons.
|
||||
* This updates the CPU Processor Status Word. The PSW should generally be written through
|
||||
* this routine so that changes can be tracked properly, for example the correct register set,
|
||||
* the current memory management mode, etc. An exception is SPL which writes the priority directly.
|
||||
* Note that that N, Z, V, and C flags are actually stored separately for performance reasons.
|
||||
*
|
||||
* PSW 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
|
||||
* CM | PM |RS| |PRIORITY| T| N| Z| V| C
|
||||
* mode 0 kernel 1 super 3 user
|
||||
* CMODE PMODE RS -------- PRIORITY T N Z V C
|
||||
*
|
||||
* @this {CPUStatePDP11}
|
||||
* @param {number} newPSW
|
||||
*/
|
||||
CPUStatePDP11.prototype.writePSW = function(newPSW)
|
||||
{
|
||||
var i, j;
|
||||
this.flagN = newPSW << 12;
|
||||
this.flagZ = (~newPSW) & 4;
|
||||
this.flagV = newPSW << 14;
|
||||
this.flagC = newPSW << 16;
|
||||
if ((newPSW ^ this.PSW) & 0x800) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
j = this.regsCur[i];
|
||||
this.regsCur[i] = this.regsAlt[i];
|
||||
this.regsAlt[i] = j; // swap to alternate register set
|
||||
if ((newPSW ^ this.PSW) & PDP11.PSW.REGSET) {
|
||||
/*
|
||||
* Swap register sets
|
||||
*/
|
||||
for (var i = this.regsAlt.length; --i >= 0;) {
|
||||
var tmp = this.regsGen[i];
|
||||
this.regsGen[i] = this.regsAlt[i];
|
||||
this.regsAlt[i] = tmp;
|
||||
}
|
||||
}
|
||||
if ((this.mmuMode = (newPSW >> 14) & 3) !== ((this.PSW >> 14) & 3)) {
|
||||
this.regsStack[j] = this.regsCur[6];
|
||||
this.regsCur[6] = this.regsStack[this.mmuMode]; // swap to new mode SP
|
||||
this.mmuMode = (newPSW >> PDP11.PSW.CMODE_SHIFT) & PDP11.MODE.MASK;
|
||||
var oldMode = (this.PSW >> PDP11.PSW.CMODE_SHIFT) & PDP11.MODE.MASK;
|
||||
if (this.mmuMode != oldMode) {
|
||||
/*
|
||||
* Swap stack pointers
|
||||
*/
|
||||
this.regsAltStack[oldMode] = this.regsGen[6];
|
||||
this.regsGen[6] = this.regsAltStack[this.mmuMode];
|
||||
}
|
||||
this.priorityReview = 2; // trigger check of priority levels
|
||||
/*
|
||||
* Trigger check of priority levels
|
||||
*/
|
||||
this.priorityReview = 2;
|
||||
this.PSW = newPSW;
|
||||
};
|
||||
|
||||
|
|
@ -611,9 +640,8 @@ CPUStatePDP11.prototype.writePSW = function(newPSW)
|
|||
*/
|
||||
CPUStatePDP11.prototype.readPSW = function()
|
||||
{
|
||||
this.PSW = (this.PSW & 0xf8f0) | ((this.flagN >> 12) & 8) | ((this.flagV >> 14) & 2) | ((this.flagC >> 16) & 1);
|
||||
if (!(this.flagZ & 0xffff)) this.PSW |= 4;
|
||||
return this.PSW;
|
||||
var mask = PDP11.PSW.CMODE | PDP11.PSW.PMODE | PDP11.PSW.REGSET | PDP11.PSW.PRI | PDP11.PSW.TF;
|
||||
return this.PSW = (this.PSW & mask) | this.getNF() | this.getZF() | this.getVF() | this.getCF();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -663,10 +691,10 @@ CPUStatePDP11.prototype.trap = function(vector, reason)
|
|||
this.writePSW((newPSW & 0xcfff) | ((this.trapPSW >> 2) & 0x3000)); // set new this.PSW with previous mode
|
||||
if (doubleTrap) {
|
||||
this.CPU_Error |= 4;
|
||||
this.regsCur[6] = 4;
|
||||
this.regsGen[6] = 4;
|
||||
}
|
||||
if (this.pushWord(this.trapPSW) >= 0 && this.pushWord(this.regsCur[7]) >= 0) {
|
||||
this.regsCur[7] = newPC;
|
||||
if (this.pushWord(this.trapPSW) >= 0 && this.pushWord(this.regsGen[7]) >= 0) {
|
||||
this.regsGen[7] = newPC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -860,7 +888,7 @@ CPUStatePDP11.prototype.mapVirtualToPhysical = function(virtualAddress, accessMa
|
|||
CPUStatePDP11.prototype.readWordByAddr = function(physicalAddress)
|
||||
{
|
||||
if (physicalAddress >= PDP11.MAX_ADDRESS) {
|
||||
return this.regsCur[physicalAddress - PDP11.MAX_ADDRESS];
|
||||
return this.regsGen[physicalAddress - PDP11.MAX_ADDRESS];
|
||||
} else {
|
||||
if (physicalAddress >= PDP11.IOBASE_UNIBUS) {
|
||||
return this.bus.access_iopage(physicalAddress, -1, 0);
|
||||
|
|
@ -885,7 +913,7 @@ CPUStatePDP11.prototype.writeWordByAddr = function(physicalAddress, data)
|
|||
{
|
||||
data &= 0xffff;
|
||||
if (physicalAddress >= PDP11.MAX_ADDRESS) {
|
||||
return (this.regsCur[physicalAddress - PDP11.MAX_ADDRESS] = data);
|
||||
return (this.regsGen[physicalAddress - PDP11.MAX_ADDRESS] = data);
|
||||
} else {
|
||||
if (physicalAddress >= PDP11.IOBASE_UNIBUS) {
|
||||
return this.bus.access_iopage(physicalAddress, data, 0);
|
||||
|
|
@ -909,7 +937,7 @@ CPUStatePDP11.prototype.readByteByAddr = function(physicalAddress)
|
|||
{
|
||||
var result;
|
||||
if (physicalAddress >= PDP11.MAX_ADDRESS) {
|
||||
return (this.regsCur[physicalAddress - PDP11.MAX_ADDRESS] & 0xff);
|
||||
return (this.regsGen[physicalAddress - PDP11.MAX_ADDRESS] & 0xff);
|
||||
} else {
|
||||
if (physicalAddress >= PDP11.IOBASE_UNIBUS) {
|
||||
return this.bus.access_iopage(physicalAddress, -1, 1);
|
||||
|
|
@ -938,7 +966,7 @@ CPUStatePDP11.prototype.writeByteByAddr = function(physicalAddress, data)
|
|||
{
|
||||
data &= 0xff;
|
||||
if (physicalAddress >= PDP11.MAX_ADDRESS) {
|
||||
return (this.regsCur[physicalAddress - PDP11.MAX_ADDRESS] = (this.regsCur[physicalAddress - PDP11.MAX_ADDRESS] & 0xff00) | data);
|
||||
return (this.regsGen[physicalAddress - PDP11.MAX_ADDRESS] = (this.regsGen[physicalAddress - PDP11.MAX_ADDRESS] & 0xff00) | data);
|
||||
} else {
|
||||
if (physicalAddress >= PDP11.IOBASE_UNIBUS) {
|
||||
return this.bus.access_iopage(physicalAddress, data, 1);
|
||||
|
|
@ -974,9 +1002,9 @@ CPUStatePDP11.prototype.readWordByVirtual = function(virtualAddress)
|
|||
*/
|
||||
CPUStatePDP11.prototype.popWord = function()
|
||||
{
|
||||
var result = this.readWordByVirtual(this.regsCur[6] | 0x10000);
|
||||
var result = this.readWordByVirtual(this.regsGen[6] | 0x10000);
|
||||
if (result >= 0) {
|
||||
this.regsCur[6] = (this.regsCur[6] + 2) & 0xffff;
|
||||
this.regsGen[6] = (this.regsGen[6] + 2) & 0xffff;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
|
@ -991,14 +1019,14 @@ CPUStatePDP11.prototype.popWord = function()
|
|||
CPUStatePDP11.prototype.pushWord = function(data)
|
||||
{
|
||||
var physicalAddress, virtualAddress;
|
||||
this.regsCur[6] = virtualAddress = (this.regsCur[6] - 2) & 0xffff; // BSD needs SP updated before any fault :-(
|
||||
this.regsGen[6] = virtualAddress = (this.regsGen[6] - 2) & 0xffff; // BSD needs SP updated before any fault :-(
|
||||
if (!(this.MMR0 & 0xe000)) {
|
||||
this.MMR1 = (this.MMR1 << 8) | 0xf6;
|
||||
}
|
||||
if ((!this.mmuMode) && virtualAddress <= this.stackLimit && virtualAddress > 4) {
|
||||
if (virtualAddress <= this.stackLimit - 32) {
|
||||
this.CPU_Error |= 4; // Red stack
|
||||
this.regsCur[6] = 4;
|
||||
this.regsGen[6] = 4;
|
||||
return this.trap(4, 32);
|
||||
}
|
||||
this.CPU_Error |= 8; // Yellow
|
||||
|
|
@ -1048,19 +1076,19 @@ CPUStatePDP11.prototype.getVirtualByMode = function(addressMode, accessMode)
|
|||
return this.trap(4, 34); // trap for invalid virtual address
|
||||
case 1: // Mode 1: (R)
|
||||
if (reg === 6 && (!this.mmuMode) && (accessMode & PDP11.WRITE_MODE) &&
|
||||
(this.regsCur[6] <= this.stackLimit || this.regsCur[6] >= 0xfffe)) {
|
||||
if (this.regsCur[6] <= this.stackLimit - 32 || this.regsCur[6] >= 0xfffe) {
|
||||
(this.regsGen[6] <= this.stackLimit || this.regsGen[6] >= 0xfffe)) {
|
||||
if (this.regsGen[6] <= this.stackLimit - 32 || this.regsGen[6] >= 0xfffe) {
|
||||
this.CPU_Error |= 4; // Red stack
|
||||
this.regsCur[6] = 4;
|
||||
this.regsGen[6] = 4;
|
||||
return this.trap(4, 36);
|
||||
}
|
||||
this.CPU_Error |= 8; // Yellow
|
||||
this.trapMask |= 4;
|
||||
}
|
||||
return (reg === 7 ? this.regsCur[reg] : (this.regsCur[reg] | 0x10000));
|
||||
return (reg === 7 ? this.regsGen[reg] : (this.regsGen[reg] | 0x10000));
|
||||
case 2: // Mode 2: (R)+
|
||||
stepSize = 2;
|
||||
virtualAddress = this.regsCur[reg];
|
||||
virtualAddress = this.regsGen[reg];
|
||||
if (reg !== 7) {
|
||||
virtualAddress |= 0x10000;
|
||||
if (reg < 6 && (accessMode & PDP11.BYTE_MODE)) {
|
||||
|
|
@ -1070,7 +1098,7 @@ CPUStatePDP11.prototype.getVirtualByMode = function(addressMode, accessMode)
|
|||
break;
|
||||
case 3: // Mode 3: @(R)+
|
||||
stepSize = 2;
|
||||
virtualAddress = this.regsCur[reg];
|
||||
virtualAddress = this.regsGen[reg];
|
||||
if (reg !== 7) virtualAddress |= 0x10000;
|
||||
if ((virtualAddress = this.readWordByVirtual(virtualAddress)) < 0) {
|
||||
return virtualAddress;
|
||||
|
|
@ -1081,14 +1109,14 @@ CPUStatePDP11.prototype.getVirtualByMode = function(addressMode, accessMode)
|
|||
case 4: // Mode 4: -(R)
|
||||
stepSize = -2;
|
||||
if (reg < 6 && (accessMode & PDP11.BYTE_MODE)) stepSize = -1;
|
||||
virtualAddress = (this.regsCur[reg] + stepSize) & 0xffff;
|
||||
virtualAddress = (this.regsGen[reg] + stepSize) & 0xffff;
|
||||
if (reg !== 7) {
|
||||
virtualAddress |= 0x10000;
|
||||
}
|
||||
break;
|
||||
case 5: // Mode 5: @-(R)
|
||||
stepSize = -2;
|
||||
virtualAddress = (this.regsCur[reg] - 2) & 0xffff;
|
||||
virtualAddress = (this.regsGen[reg] - 2) & 0xffff;
|
||||
if (reg !== 7) virtualAddress |= 0x10000;
|
||||
if ((virtualAddress = this.readWordByVirtual(virtualAddress)) < 0) {
|
||||
return virtualAddress;
|
||||
|
|
@ -1096,28 +1124,28 @@ CPUStatePDP11.prototype.getVirtualByMode = function(addressMode, accessMode)
|
|||
virtualAddress |= 0x10000;
|
||||
break;
|
||||
case 6: // Mode 6: d(R)
|
||||
if ((virtualAddress = this.readWordByVirtual(this.regsCur[7])) < 0) {
|
||||
if ((virtualAddress = this.readWordByVirtual(this.regsGen[7])) < 0) {
|
||||
return virtualAddress;
|
||||
}
|
||||
this.regsCur[7] = (this.regsCur[7] + 2) & 0xffff;
|
||||
this.regsGen[7] = (this.regsGen[7] + 2) & 0xffff;
|
||||
if (reg < 7) {
|
||||
//LOG_ADDRESS(virtualAddress);
|
||||
virtualAddress = (virtualAddress + this.regsCur[reg]) & 0xffff;
|
||||
virtualAddress = (virtualAddress + this.regsGen[reg]) & 0xffff;
|
||||
} else {
|
||||
virtualAddress = (virtualAddress + this.regsCur[reg]) & 0xffff;
|
||||
virtualAddress = (virtualAddress + this.regsGen[reg]) & 0xffff;
|
||||
//LOG_ADDRESS(virtualAddress);
|
||||
}
|
||||
return virtualAddress | 0x10000;
|
||||
case 7: // Mode 7: @d(R)
|
||||
if ((virtualAddress = this.readWordByVirtual(this.regsCur[7])) < 0) {
|
||||
if ((virtualAddress = this.readWordByVirtual(this.regsGen[7])) < 0) {
|
||||
return virtualAddress;
|
||||
}
|
||||
this.regsCur[7] = (this.regsCur[7] + 2) & 0xffff;
|
||||
this.regsGen[7] = (this.regsGen[7] + 2) & 0xffff;
|
||||
if (reg < 7) {
|
||||
//LOG_ADDRESS(virtualAddress);
|
||||
virtualAddress = (virtualAddress + this.regsCur[reg]) & 0xffff;
|
||||
virtualAddress = (virtualAddress + this.regsGen[reg]) & 0xffff;
|
||||
} else {
|
||||
virtualAddress = (virtualAddress + this.regsCur[reg]) & 0xffff;
|
||||
virtualAddress = (virtualAddress + this.regsGen[reg]) & 0xffff;
|
||||
//LOG_ADDRESS(virtualAddress);
|
||||
}
|
||||
if ((virtualAddress = this.readWordByVirtual(virtualAddress | 0x10000)) < 0) {
|
||||
|
|
@ -1125,15 +1153,15 @@ CPUStatePDP11.prototype.getVirtualByMode = function(addressMode, accessMode)
|
|||
}
|
||||
return virtualAddress | 0x10000; // @x
|
||||
}
|
||||
this.regsCur[reg] = (this.regsCur[reg] + stepSize) & 0xffff;
|
||||
this.regsGen[reg] = (this.regsGen[reg] + stepSize) & 0xffff;
|
||||
if (!(this.MMR0 & 0xe000)) {
|
||||
this.MMR1 = (this.MMR1 << 8) | ((stepSize << 3) & 0xf8) | reg;
|
||||
}
|
||||
if (reg === 6 && (!this.mmuMode) && (accessMode & PDP11.WRITE_MODE) && stepSize <= 0 &&
|
||||
(this.regsCur[6] <= this.stackLimit || this.regsCur[6] >= 0xfffe)) {
|
||||
if (this.regsCur[6] <= this.stackLimit - 32) {
|
||||
(this.regsGen[6] <= this.stackLimit || this.regsGen[6] >= 0xfffe)) {
|
||||
if (this.regsGen[6] <= this.stackLimit - 32) {
|
||||
this.CPU_Error |= 4; // Red stack
|
||||
this.regsCur[6] = 4;
|
||||
this.regsGen[6] = 4;
|
||||
return this.trap(4, 38);
|
||||
}
|
||||
this.CPU_Error |= 8; // Yellow
|
||||
|
|
@ -1174,7 +1202,7 @@ CPUStatePDP11.prototype.readWordByMode = function(addressMode)
|
|||
{
|
||||
var result;
|
||||
if (!(addressMode & 0x38)) {
|
||||
result = this.regsCur[addressMode & 7];
|
||||
result = this.regsGen[addressMode & 7];
|
||||
//LOG_SOURCE(result);
|
||||
} else {
|
||||
if ((result = this.getAddrByMode(addressMode, PDP11.READ_MODE)) >= 0) {
|
||||
|
|
@ -1197,7 +1225,7 @@ CPUStatePDP11.prototype.readByteByMode = function(addressMode)
|
|||
{
|
||||
var result;
|
||||
if (!(addressMode & 0x38)) {
|
||||
result = this.regsCur[addressMode & 7] & 0xff;
|
||||
result = this.regsGen[addressMode & 7] & 0xff;
|
||||
//LOG_SOURCE(result);
|
||||
} else {
|
||||
if ((result = this.getAddrByMode(addressMode, PDP11.READ_MODE | PDP11.BYTE_MODE)) >= 0) {
|
||||
|
|
@ -1340,25 +1368,25 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
}
|
||||
}
|
||||
}
|
||||
//if (this.regsCur[7] === this.debugPC) {
|
||||
//if (this.regsGen[7] === this.debugPC) {
|
||||
//LOG_PRINT();
|
||||
//
|
||||
//}
|
||||
// Initialize this.memory before getting an instruction
|
||||
if (!(this.MMR0 & 0xe000)) {
|
||||
this.MMR1 = 0;
|
||||
this.MMR2 = this.regsCur[7];
|
||||
this.MMR2 = this.regsGen[7];
|
||||
}
|
||||
// If needed T-bit trap at the end of this instruction
|
||||
this.trapMask = this.PSW & 0x10;
|
||||
if ((instruction = this.readWordByVirtual(this.regsCur[7])) >= 0) {
|
||||
this.regsCur[7] = (this.regsCur[7] + 2) & 0xffff;
|
||||
if ((instruction = this.readWordByVirtual(this.regsGen[7])) >= 0) {
|
||||
this.regsGen[7] = (this.regsGen[7] + 2) & 0xffff;
|
||||
switch (instruction & 0xF000) /*0170000*/ { // Double operand instructions xxSSDD
|
||||
case 0x1000: /*0010000*/ // MOV 01SSDD
|
||||
//LOG_INSTRUCTION(instruction, 2, "MOV");
|
||||
if ((src = this.readWordByMode(instruction >> 6)) >= 0) {
|
||||
if (!(instruction & 0x38)) {
|
||||
this.regsCur[instruction & 7] = src;
|
||||
this.regsGen[instruction & 7] = src;
|
||||
this.flagN = this.flagZ = src;
|
||||
this.flagV = 0;
|
||||
} else {
|
||||
|
|
@ -1394,7 +1422,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 2, "BIC");
|
||||
if ((src = this.readWordByMode(instruction >> 6)) >= 0) {
|
||||
if (!(instruction & 0x38)) {
|
||||
result = this.regsCur[instruction & 7] &= ~src;
|
||||
result = this.regsGen[instruction & 7] &= ~src;
|
||||
this.flagN = this.flagZ = result;
|
||||
this.flagV = 0;
|
||||
} else {
|
||||
|
|
@ -1412,7 +1440,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 2, "BIS");
|
||||
if ((src = this.readWordByMode(instruction >> 6)) >= 0) {
|
||||
if (!(instruction & 0x38)) {
|
||||
result = this.regsCur[instruction & 7] |= src;
|
||||
result = this.regsGen[instruction & 7] |= src;
|
||||
this.flagN = this.flagZ = result;
|
||||
this.flagV = 0;
|
||||
} else {
|
||||
|
|
@ -1431,8 +1459,8 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
if ((src = this.readWordByMode(instruction >> 6)) >= 0) {
|
||||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
dst = this.regsCur[reg];
|
||||
this.regsCur[reg] = (result = src + dst) & 0xffff;
|
||||
dst = this.regsGen[reg];
|
||||
this.regsGen[reg] = (result = src + dst) & 0xffff;
|
||||
this.flagN = this.flagZ = this.flagC = result;
|
||||
this.flagV = (src ^ result) & (dst ^ result);
|
||||
} else {
|
||||
|
|
@ -1451,7 +1479,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
if ((src = this.readByteByMode(instruction >> 6)) >= 0) {
|
||||
if (!(instruction & 0x38)) {
|
||||
if (src & 0x80) /*0200*/ src |= 0xff00; // movb sign extends register to word size
|
||||
this.regsCur[instruction & 7] = src;
|
||||
this.regsGen[instruction & 7] = src;
|
||||
this.flagN = this.flagZ = src;
|
||||
this.flagV = 0;
|
||||
} else {
|
||||
|
|
@ -1512,8 +1540,8 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
if ((src = this.readWordByMode(instruction >> 6)) >= 0) {
|
||||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
dst = this.regsCur[reg];
|
||||
this.regsCur[reg] = (result = dst - src) & 0xffff;
|
||||
dst = this.regsGen[reg];
|
||||
this.regsGen[reg] = (result = dst - src) & 0xffff;
|
||||
this.flagN = this.flagZ = this.flagC = result;
|
||||
this.flagV = (src ^ dst) & (dst ^ result);
|
||||
} else {
|
||||
|
|
@ -1533,9 +1561,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 3, "JSR");
|
||||
if ((virtualAddress = this.getVirtualByMode(instruction, 0)) >= 0) {
|
||||
reg = (instruction >> 6) & 7;
|
||||
if (this.pushWord(this.regsCur[reg]) >= 0) {
|
||||
this.regsCur[reg] = this.regsCur[7];
|
||||
this.regsCur[7] = virtualAddress & 0xffff;
|
||||
if (this.pushWord(this.regsGen[reg]) >= 0) {
|
||||
this.regsGen[reg] = this.regsGen[7];
|
||||
this.regsGen[7] = virtualAddress & 0xffff;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -1544,11 +1572,11 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
if ((src = this.readWordByMode(instruction)) >= 0) {
|
||||
reg = (instruction >> 6) & 7;
|
||||
if (src & 0x8000) src |= ~0xffff;
|
||||
dst = this.regsCur[reg];
|
||||
dst = this.regsGen[reg];
|
||||
if (dst & 0x8000) dst |= ~0xffff;
|
||||
result = ~~(src * dst);
|
||||
this.regsCur[reg] = (result >> 16) & 0xffff;
|
||||
this.regsCur[reg | 1] = result & 0xffff;
|
||||
this.regsGen[reg] = (result >> 16) & 0xffff;
|
||||
this.regsGen[reg | 1] = result & 0xffff;
|
||||
this.flagN = result >> 16;
|
||||
this.flagZ = this.flagN | result;
|
||||
this.flagC = this.flagV = 0;
|
||||
|
|
@ -1565,21 +1593,21 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
this.flagC = 0x10000; // divide by zero
|
||||
} else {
|
||||
reg = (instruction >> 6) & 7;
|
||||
dst = (this.regsCur[reg] << 16) | this.regsCur[reg | 1];
|
||||
dst = (this.regsGen[reg] << 16) | this.regsGen[reg | 1];
|
||||
this.flagC = this.flagV = 0;
|
||||
if (src & 0x8000) src |= ~0xffff;
|
||||
result = ~~(dst / src);
|
||||
if (result >= -32768 && result <= 32767) {
|
||||
this.regsCur[reg] = result & 0xffff;
|
||||
this.regsCur[reg | 1] = (dst - (result * src)) & 0xffff;
|
||||
this.regsGen[reg] = result & 0xffff;
|
||||
this.regsGen[reg | 1] = (dst - (result * src)) & 0xffff;
|
||||
this.flagZ = (result >> 16) | result;
|
||||
this.flagN = result >> 16;
|
||||
} else {
|
||||
this.flagV = 0x8000; // overflow - following are indeterminate
|
||||
this.flagZ = (result >> 15) | result; // dodgy
|
||||
this.flagN = dst >> 16; // just as dodgy
|
||||
if (src === -1 && this.regsCur[reg] ===
|
||||
0xfffe) this.regsCur[reg] = this.regsCur[reg | 1] = 1; // etc
|
||||
if (src === -1 && this.regsGen[reg] ===
|
||||
0xfffe) this.regsGen[reg] = this.regsGen[reg | 1] = 1; // etc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1588,7 +1616,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 3, "ASH");
|
||||
if ((src = this.readWordByMode(instruction)) >= 0) {
|
||||
reg = (instruction >> 6) & 7;
|
||||
result = this.regsCur[reg];
|
||||
result = this.regsGen[reg];
|
||||
if (result & 0x8000) result |= 0xffff0000;
|
||||
this.flagC = this.flagV = 0;
|
||||
src &= 0x3F; /*077*/
|
||||
|
|
@ -1610,7 +1638,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
}
|
||||
}
|
||||
}
|
||||
this.regsCur[reg] = result & 0xffff;
|
||||
this.regsGen[reg] = result & 0xffff;
|
||||
this.flagN = this.flagZ = result;
|
||||
}
|
||||
break;
|
||||
|
|
@ -1618,7 +1646,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 3, "ASHC");
|
||||
if ((src = this.readWordByMode(instruction)) >= 0) {
|
||||
reg = (instruction >> 6) & 7;
|
||||
dst = (this.regsCur[reg] << 16) | this.regsCur[reg | 1];
|
||||
dst = (this.regsGen[reg] << 16) | this.regsGen[reg | 1];
|
||||
this.flagC = this.flagV = 0;
|
||||
src &= 0x3F; /*077*/
|
||||
if (src & 0x20) /*040*/ {
|
||||
|
|
@ -1643,8 +1671,8 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
result = dst;
|
||||
}
|
||||
}
|
||||
this.regsCur[reg] = (result >> 16) & 0xffff;
|
||||
this.regsCur[reg | 1] = result & 0xffff;
|
||||
this.regsGen[reg] = (result >> 16) & 0xffff;
|
||||
this.regsGen[reg | 1] = result & 0xffff;
|
||||
this.flagN = result >> 16;
|
||||
this.flagZ = result >> 16 | result;
|
||||
}
|
||||
|
|
@ -1652,12 +1680,12 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
case 0x7800: /*0074000*/ // XOR 074RSS
|
||||
//LOG_INSTRUCTION(instruction, 3, "XOR");
|
||||
if (!(instruction & 0x38)) {
|
||||
dst = this.regsCur[instruction & 7] ^= this.regsCur[(instruction >> 6) & 7];
|
||||
dst = this.regsGen[instruction & 7] ^= this.regsGen[(instruction >> 6) & 7];
|
||||
this.flagN = this.flagZ = dst;
|
||||
this.flagV = 0;
|
||||
} else {
|
||||
if ((dst = this.readWordByAddr(dstAddr = this.getAddrByMode(instruction, PDP11.MODIFY_WORD))) >= 0) {
|
||||
dst ^= this.regsCur[(instruction >> 6) & 7];
|
||||
dst ^= this.regsGen[(instruction >> 6) & 7];
|
||||
if (this.writeWordByAddr(dstAddr, dst) >= 0) {
|
||||
this.flagN = this.flagZ = dst;
|
||||
this.flagV = 0;
|
||||
|
|
@ -1668,78 +1696,78 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
case 0x7E00: /*0077000*/ // SOB 077Rnn
|
||||
//LOG_INSTRUCTION(instruction, 5, "SOB");
|
||||
reg = (instruction >> 6) & 7;
|
||||
if ((this.regsCur[reg] = ((this.regsCur[reg] - 1) & 0xffff))) {
|
||||
this.regsCur[7] = (this.regsCur[7] - ((instruction & 0x3F) /*077*/ << 1)) & 0xffff;
|
||||
if ((this.regsGen[reg] = ((this.regsGen[reg] - 1) & 0xffff))) {
|
||||
this.regsGen[7] = (this.regsGen[7] - ((instruction & 0x3F) /*077*/ << 1)) & 0xffff;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (instruction & 0xFF00) /*0177400*/ { // Program control instructions & traps
|
||||
case 0x100: /*0000400*/ // BR
|
||||
//LOG_INSTRUCTION(instruction, 4, "BR");
|
||||
this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x200: /*0001000*/ // BNE
|
||||
//LOG_INSTRUCTION(instruction, 4, "BNE");
|
||||
if (this.flagZ & 0xffff) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
if (this.flagZ & 0xffff) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x300: /*0001400*/ // BEQ
|
||||
//LOG_INSTRUCTION(instruction, 4, "BEQ");
|
||||
if (!(this.flagZ & 0xffff)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
if (!(this.flagZ & 0xffff)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x400: /*0002000*/ // BGE
|
||||
//LOG_INSTRUCTION(instruction, 4, "BGE");
|
||||
if ((this.flagN & 0x8000) ===
|
||||
(this.flagV & 0x8000)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
(this.flagV & 0x8000)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x500: /*0002400*/ // BLT
|
||||
//LOG_INSTRUCTION(instruction, 4, "BLT");
|
||||
if ((this.flagN & 0x8000) !==
|
||||
(this.flagV & 0x8000)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
(this.flagV & 0x8000)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x600: /*0003000*/ // BGT
|
||||
//LOG_INSTRUCTION(instruction, 4, "BGT");
|
||||
if ((this.flagZ & 0xffff) && ((this.flagN & 0x8000) ===
|
||||
(this.flagV & 0x8000))) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
(this.flagV & 0x8000))) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x700: /*0003400*/ // BLE
|
||||
//LOG_INSTRUCTION(instruction, 4, "BLE");
|
||||
if (!(this.flagZ & 0xffff) || ((this.flagN & 0x8000) !==
|
||||
(this.flagV & 0x8000))) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
(this.flagV & 0x8000))) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x8000: /*0100000*/ // BPL
|
||||
//LOG_INSTRUCTION(instruction, 4, "BPL");
|
||||
if (!(this.flagN & 0x8000)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
if (!(this.flagN & 0x8000)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x8200: /*0101000*/ // BHI
|
||||
//LOG_INSTRUCTION(instruction, 4, "BHI");
|
||||
if (!(this.flagC & 0x10000) &&
|
||||
(this.flagZ & 0xffff)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
(this.flagZ & 0xffff)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x8100: /*0100400*/ // BMI
|
||||
//LOG_INSTRUCTION(instruction, 4, "BMI");
|
||||
if ((this.flagN & 0x8000)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
if ((this.flagN & 0x8000)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x8300: /*0101400*/ // BLOS
|
||||
//LOG_INSTRUCTION(instruction, 4, "BLOS");
|
||||
if ((this.flagC & 0x10000) ||
|
||||
!(this.flagZ & 0xffff)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
!(this.flagZ & 0xffff)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x8400: /*0102000*/ // BVC
|
||||
//LOG_INSTRUCTION(instruction, 4, "BVC");
|
||||
if (!(this.flagV & 0x8000)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
if (!(this.flagV & 0x8000)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x8500: /*0102400*/ // BVS
|
||||
//LOG_INSTRUCTION(instruction, 4, "BVS");
|
||||
if ((this.flagV & 0x8000)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
if ((this.flagV & 0x8000)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x8600: /*0103000*/ // BCC
|
||||
//LOG_INSTRUCTION(instruction, 4, "BCC");
|
||||
if (!(this.flagC &
|
||||
0x10000)) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
0x10000)) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x8700: /*0103400*/ // BCS
|
||||
//LOG_INSTRUCTION(instruction, 4, "BCS");
|
||||
if (this.flagC & 0x10000) this.regsCur[7] = this.branch(this.regsCur[7], instruction);
|
||||
if (this.flagC & 0x10000) this.regsGen[7] = this.branch(this.regsGen[7], instruction);
|
||||
break;
|
||||
case 0x8800: /*0104000*/ // EMT 104000 -> 104377
|
||||
//LOG_INSTRUCTION(instruction, 7, "EMT");
|
||||
|
|
@ -1754,15 +1782,15 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
case 0x40: /*0000100*/ // JMP 0001DD
|
||||
//LOG_INSTRUCTION(instruction, 1, "JMP");
|
||||
if ((virtualAddress = this.getVirtualByMode(instruction, 0)) >= 0) {
|
||||
this.regsCur[7] = virtualAddress & 0xffff;
|
||||
this.regsGen[7] = virtualAddress & 0xffff;
|
||||
}
|
||||
break;
|
||||
case 0xC0: /*0000300*/ // SWAB 0003DD
|
||||
//LOG_INSTRUCTION(instruction, 1, "SWAB");
|
||||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
dst = this.regsCur[reg];
|
||||
this.regsCur[reg] = ((dst << 8) | (dst >> 8)) & 0xffff;
|
||||
dst = this.regsGen[reg];
|
||||
this.regsGen[reg] = ((dst << 8) | (dst >> 8)) & 0xffff;
|
||||
this.flagN = this.flagZ = dst & 0xff00;
|
||||
this.flagV = this.flagC = 0;
|
||||
} else {
|
||||
|
|
@ -1779,7 +1807,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
case 0xA00: /*0005000*/ // CLR 0050DD
|
||||
//LOG_INSTRUCTION(instruction, 1, "CLR");
|
||||
if (!(instruction & 0x38)) {
|
||||
this.regsCur[instruction & 7] = 0;
|
||||
this.regsGen[instruction & 7] = 0;
|
||||
this.flagN = this.flagC = this.flagV = this.flagZ = 0;
|
||||
} else {
|
||||
if ((dstAddr = this.getAddrByMode(instruction, PDP11.WRITE_MODE)) >= 0) { // write word
|
||||
|
|
@ -1805,9 +1833,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 1, "INC");
|
||||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
dst = this.regsCur[reg];
|
||||
dst = this.regsGen[reg];
|
||||
result = dst + 1;
|
||||
this.regsCur[reg] = result & 0xffff;
|
||||
this.regsGen[reg] = result & 0xffff;
|
||||
this.flagN = this.flagZ = result;
|
||||
this.flagV = result & (result ^ dst);
|
||||
} else {
|
||||
|
|
@ -1825,9 +1853,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 1, "DEC");
|
||||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
dst = this.regsCur[reg];
|
||||
dst = this.regsGen[reg];
|
||||
result = dst - 1;
|
||||
this.regsCur[reg] = result & 0xffff;
|
||||
this.regsGen[reg] = result & 0xffff;
|
||||
this.flagN = this.flagZ = result;
|
||||
this.flagV = (result ^ dst) & dst;
|
||||
} else {
|
||||
|
|
@ -1885,9 +1913,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 1, "ROR");
|
||||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
dst = this.regsCur[reg];
|
||||
dst = this.regsGen[reg];
|
||||
result = ((this.flagC & 0x10000) | dst) >> 1;
|
||||
this.regsCur[reg] = result & 0xffff;
|
||||
this.regsGen[reg] = result & 0xffff;
|
||||
this.flagC = (dst << 16);
|
||||
this.flagN = this.flagZ = result;
|
||||
this.flagV = result ^ (this.flagC >> 1);
|
||||
|
|
@ -1907,9 +1935,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 1, "ROL");
|
||||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
dst = this.regsCur[reg];
|
||||
dst = this.regsGen[reg];
|
||||
result = (dst << 1) | ((this.flagC >> 16) & 1);
|
||||
this.regsCur[reg] = result & 0xffff;
|
||||
this.regsGen[reg] = result & 0xffff;
|
||||
this.flagC = this.flagN = this.flagZ = result;
|
||||
this.flagV = result ^ dst;
|
||||
} else {
|
||||
|
|
@ -1927,9 +1955,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 1, "ASR");
|
||||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
dst = this.regsCur[reg];
|
||||
dst = this.regsGen[reg];
|
||||
result = (dst & 0x8000) | (dst >> 1);
|
||||
this.regsCur[reg] = result & 0xffff;
|
||||
this.regsGen[reg] = result & 0xffff;
|
||||
this.flagC = dst << 16;
|
||||
this.flagN = this.flagZ = result;
|
||||
this.flagV = this.flagN ^ (this.flagC >> 1);
|
||||
|
|
@ -1949,9 +1977,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 1, "ASL");
|
||||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
dst = this.regsCur[reg];
|
||||
dst = this.regsGen[reg];
|
||||
result = dst << 1;
|
||||
this.regsCur[reg] = result & 0xffff;
|
||||
this.regsGen[reg] = result & 0xffff;
|
||||
this.flagC = this.flagN = this.flagZ = result;
|
||||
this.flagV = result ^ dst;
|
||||
} else {
|
||||
|
|
@ -1967,11 +1995,11 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
break;
|
||||
case 0xD00: /*0006400*/ // MARK 0064nn
|
||||
//LOG_INSTRUCTION(instruction, 8, "MARK");
|
||||
virtualAddress = (this.regsCur[7] + ((instruction & 0x3F) /*077*/ << 1)) & 0xffff;
|
||||
virtualAddress = (this.regsGen[7] + ((instruction & 0x3F) /*077*/ << 1)) & 0xffff;
|
||||
if ((src = this.readWordByVirtual(virtualAddress | 0x10000)) >= 0) {
|
||||
this.regsCur[7] = this.regsCur[5];
|
||||
this.regsCur[5] = src;
|
||||
this.regsCur[6] = (virtualAddress + 2) & 0xffff;
|
||||
this.regsGen[7] = this.regsGen[5];
|
||||
this.regsGen[5] = src;
|
||||
this.regsGen[6] = (virtualAddress + 2) & 0xffff;
|
||||
}
|
||||
break;
|
||||
case 0xD40: /*0006500*/ // MFPI 0065SS
|
||||
|
|
@ -1979,9 +2007,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
if (6 !== reg || ((this.PSW >> 2) & 0x3000) === (this.PSW & 0x3000)) {
|
||||
src = this.regsCur[reg];
|
||||
src = this.regsGen[reg];
|
||||
} else {
|
||||
src = this.regsStack[(this.PSW >> 12) & 3];
|
||||
src = this.regsAltStack[(this.PSW >> 12) & 3];
|
||||
}
|
||||
if (this.pushWord(src) >= 0) {
|
||||
this.flagN = this.flagZ = src;
|
||||
|
|
@ -2008,9 +2036,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
if (6 !== reg || ((this.PSW >> 2) & 0x3000) === (this.PSW & 0x3000)) {
|
||||
this.regsCur[reg] = dst;
|
||||
this.regsGen[reg] = dst;
|
||||
} else {
|
||||
this.regsStack[(this.PSW >> 12) & 3] = dst;
|
||||
this.regsAltStack[(this.PSW >> 12) & 3] = dst;
|
||||
}
|
||||
this.flagN = this.flagZ = dst;
|
||||
this.flagV = 0;
|
||||
|
|
@ -2042,7 +2070,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
case 0x8A00: /*0105000*/ // CLRB 1050DD
|
||||
//LOG_INSTRUCTION(instruction, 1, "CLRB");
|
||||
if (!(instruction & 0x38)) {
|
||||
this.regsCur[instruction & 7] &= 0xff00;
|
||||
this.regsGen[instruction & 7] &= 0xff00;
|
||||
this.flagN = this.flagC = this.flagV = this.flagZ = 0;
|
||||
} else {
|
||||
if ((dstAddr = this.getAddrByMode(instruction, PDP11.WRITE_MODE | PDP11.BYTE_MODE)) >= 0) { // write byte
|
||||
|
|
@ -2183,9 +2211,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
if (6 !== reg || ((this.PSW >> 2) & 0x3000) === (this.PSW & 0x3000)) {
|
||||
src = this.regsCur[reg];
|
||||
src = this.regsGen[reg];
|
||||
} else {
|
||||
src = this.regsStack[(this.PSW >> 12) & 3];
|
||||
src = this.regsAltStack[(this.PSW >> 12) & 3];
|
||||
}
|
||||
if (this.pushWord(src) >= 0) {
|
||||
this.flagN = this.flagZ = src;
|
||||
|
|
@ -2211,9 +2239,9 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
if (!(instruction & 0x38)) {
|
||||
reg = instruction & 7;
|
||||
if (6 !== reg || ((this.PSW >> 2) & 0x3000) === (this.PSW & 0x3000)) {
|
||||
this.regsCur[reg] = dst;
|
||||
this.regsGen[reg] = dst;
|
||||
} else {
|
||||
this.regsStack[(this.PSW >> 12) & 3] = dst;
|
||||
this.regsAltStack[(this.PSW >> 12) & 3] = dst;
|
||||
}
|
||||
this.flagN = this.flagZ = dst;
|
||||
this.flagV = 0;
|
||||
|
|
@ -2244,7 +2272,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
// }
|
||||
// } else {
|
||||
// if (src & 0200) src |= 0xff00;
|
||||
// this.regsCur[instruction & 7] = src;
|
||||
// this.regsGen[instruction & 7] = src;
|
||||
// this.flagN = this.flagZ = src << 8;
|
||||
// this.flagV = 0;
|
||||
// } // Temporary PDP 11/34A
|
||||
|
|
@ -2255,8 +2283,8 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
//LOG_INSTRUCTION(instruction, 6, "RTS");
|
||||
if ((src = this.popWord()) >= 0) {
|
||||
reg = instruction & 7;
|
||||
this.regsCur[7] = this.regsCur[reg];
|
||||
this.regsCur[reg] = src;
|
||||
this.regsGen[7] = this.regsGen[reg];
|
||||
this.regsGen[reg] = src;
|
||||
}
|
||||
break;
|
||||
case 0x98: /*0000230*/ // SPL 00023N
|
||||
|
|
@ -2293,7 +2321,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
this.runState = 3; // halt
|
||||
this.endBurst();
|
||||
//LOG_PRINT();
|
||||
console.log("HALT at " + this.regsCur[7].toString(8));
|
||||
console.log("HALT at " + this.regsGen[7].toString(8));
|
||||
}
|
||||
break;
|
||||
case 0x1: /*0000001*/ // WAIT 000001
|
||||
|
|
@ -2323,23 +2351,23 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
if (!(this.PSW & 0xc000)) {
|
||||
this.resetRegs();
|
||||
this.bus.reset_iopage();
|
||||
// display.data = this.regsCur[0]; // TODO: Review
|
||||
// display.data = this.regsGen[0]; // TODO: Review
|
||||
}
|
||||
break;
|
||||
case 0x2: /*0000002*/ // RTI 000002
|
||||
case 0x6: /*0000006*/ // RTT 000006
|
||||
//LOG_INSTRUCTION(instruction, 0, "RTT");
|
||||
dstAddr = this.regsCur[6];
|
||||
dstAddr = this.regsGen[6];
|
||||
if ((virtualAddress = this.readWordByVirtual(dstAddr | 0x10000)) >= 0) {
|
||||
dstAddr = (dstAddr + 2) & 0xffff;
|
||||
if ((savePSW = this.readWordByVirtual(dstAddr | 0x10000)) >= 0) {
|
||||
this.regsCur[6] = (dstAddr + 2) & 0xffff;
|
||||
this.regsGen[6] = (dstAddr + 2) & 0xffff;
|
||||
savePSW &= 0xf8ff;
|
||||
if (this.PSW & 0xc000) { // user / super restrictions
|
||||
// keep SPL and allow lower only for modes and register set
|
||||
savePSW = (savePSW & 0xf81f) | (this.PSW & 0xf8e0);
|
||||
}
|
||||
this.regsCur[7] = virtualAddress;
|
||||
this.regsGen[7] = virtualAddress;
|
||||
this.writePSW(savePSW);
|
||||
this.trapMask &= ~0x10; // turn off Trace trap
|
||||
if (instruction === 2) this.trapMask |= this.PSW & 0x10; // RTI enables immediate trace
|
||||
|
|
@ -2348,7 +2376,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
|
|||
break;
|
||||
//case 0000007: // MFPT 000007
|
||||
// //LOG_INSTRUCTION(instruction, 0, "MFPT");
|
||||
// this.regsCur[0] = 1;
|
||||
// this.regsGen[0] = 1;
|
||||
// break; // Exists on pdp 11/44 & KB11-EM
|
||||
default: // We don't know this instruction
|
||||
//LOG_INSTRUCTION(instruction, 11, "-unknown-");
|
||||
|
|
|
|||
|
|
@ -229,7 +229,8 @@ if (DEBUGGER) {
|
|||
ROLB: 72, ROR: 73, RORB: 74, RTI: 75, RTS: 76, SBC: 77, SBCB: 78, SCC: 79,
|
||||
SEC: 80, SECN: 81, SECV: 82, SECVN: 83, SECVZ: 84, SECZ: 85, SECZN: 86, SEN: 87,
|
||||
SEV: 88, SEVN: 89, SEVZ: 90, SEVZN: 91, SEZ: 92, SEZN: 93, SUB: 94, SWAB: 95,
|
||||
SXT: 96, TST: 97, TSTB: 98, WAIT: 99
|
||||
SXT: 96, TST: 97, TSTB: 98, WAIT: 99, MUL: 100, DIV: 101, ASH: 102, ASHC: 103,
|
||||
XOR: 104, SOB: 105, EMT: 106, TRAP: 107, SPL: 108, IOT: 109, RTT: 110, MFPT: 111
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -248,11 +249,12 @@ if (DEBUGGER) {
|
|||
"ROLB", "ROR", "RORB", "RTI", "RTS", "SBC", "SBCB", "SCC",
|
||||
"SEC", "SECN", "SECV", "SECVN", "SECVZ", "SECZ", "SECZN", "SEN",
|
||||
"SEV", "SEVN", "SEVZ", "SEVZN", "SEZ", "SEZN", "SUB", "SWAB",
|
||||
"SXT", "TST", "TSTB", "WAIT"
|
||||
"SXT", "TST", "TSTB", "WAIT", "MUL", "DIV", "ASH", "ASHC",
|
||||
"XOR", "SOB", "EMT", "TRAP", "SPL", "IOT", "RTT", "MFPT"
|
||||
];
|
||||
|
||||
/*
|
||||
* Register numbers 0-7 are reserved for cpu.regsCur, 8-15 are reserved for cpu.regsAlt, and 16-19 for cpu.regsStack.
|
||||
* Register numbers 0-7 are reserved for cpu.regsGen, 8-15 are reserved for cpu.regsAlt, and 16-19 for cpu.regsStack.
|
||||
*/
|
||||
DebuggerPDP11.REG_SP = 6; // aka R6
|
||||
DebuggerPDP11.REG_PC = 7; // aka R7
|
||||
|
|
@ -268,7 +270,7 @@ if (DEBUGGER) {
|
|||
DebuggerPDP11.MODE_INDEXD = 0x7; // INDEX DEFERRED (register + next word is address of address of operand)
|
||||
|
||||
/*
|
||||
* Operand descriptor masks
|
||||
* Operand descriptor masks; anything that's not covered by TYPE_SRC or TYPE_DST must be a TYPE_OTHER value.
|
||||
*/
|
||||
DebuggerPDP11.TYPE_DSTREG = 0x0007;
|
||||
DebuggerPDP11.TYPE_DSTMOD = 0x0038;
|
||||
|
|
@ -277,36 +279,51 @@ if (DEBUGGER) {
|
|||
DebuggerPDP11.TYPE_SRCMOD = 0x0E00;
|
||||
DebuggerPDP11.TYPE_SRC = (DebuggerPDP11.TYPE_SRCMOD | DebuggerPDP11.TYPE_SRCREG);
|
||||
DebuggerPDP11.TYPE_BRANCH = 0x1000;
|
||||
DebuggerPDP11.TYPE_DSTOFF = 0x2000;
|
||||
DebuggerPDP11.TYPE_DSTNUM3 = 0x3000; // DST 3-bit number (ie, just the DSTREG field)
|
||||
DebuggerPDP11.TYPE_DSTNUM6 = 0x6000; // DST 6-bit number (ie, both the DSTREG and DSTMOD fields)
|
||||
DebuggerPDP11.TYPE_OTHER = 0xF000;
|
||||
|
||||
/*
|
||||
* The opMasks table contains opcode masks, and each mask refers to table of possible values,
|
||||
* and each value refers to an array that contains:
|
||||
* The opMasks table contains opcode masks, and each mask refers to table of possible values, and each
|
||||
* value refers to an array that contains:
|
||||
*
|
||||
* [0]: {number} of the opcode name (see OP.*)
|
||||
* [1]: {number} containing the first operand descriptor bit(s), if any
|
||||
* [2]: {number} containing the second operand descriptor bit(s), if any
|
||||
*
|
||||
* These sub-elements are all optional. If [0] is not present, the opcode is undefined; if [1] is not
|
||||
* present (or contains zero), the opcode has no (or only implied) operands; if [2] is not present, the
|
||||
* opcode has only a single operand. And so on.
|
||||
* Note that, by convention, opcodes that require two operands list the SRC operand first and DST operand
|
||||
* second (ie, the OPPOSITE of the Intel convention).
|
||||
*
|
||||
* Also note that, for some of the newer PDP-11 opcodes (eg, MUL, DIV, ASH, ASCH), the location of the
|
||||
* opcode's SRC and DST bits are reversed. This is why, for example, you'll see the MUL instruction defined
|
||||
* below as having TYPE_DST for the first operand and TYPE_SRCREG for the second operand. This does NOT mean
|
||||
* that the opcode's destination operand is being listed first, but rather that the bits describing the source
|
||||
* operand are in the opcode's TYPE_DST field.
|
||||
*/
|
||||
DebuggerPDP11.opMasks = {
|
||||
0xF000: {
|
||||
0x1000: [DebuggerPDP11.OPS.MOV, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0x2000: [DebuggerPDP11.OPS.CMP, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0x3000: [DebuggerPDP11.OPS.BIT, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0x4000: [DebuggerPDP11.OPS.BIC, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0x5000: [DebuggerPDP11.OPS.BIS, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0x6000: [DebuggerPDP11.OPS.ADD, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0x9000: [DebuggerPDP11.OPS.MOVB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0xA000: [DebuggerPDP11.OPS.CMPB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0xB000: [DebuggerPDP11.OPS.BITB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0xC000: [DebuggerPDP11.OPS.BICB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0xD000: [DebuggerPDP11.OPS.BISB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST],
|
||||
0xE000: [DebuggerPDP11.OPS.SUB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST]
|
||||
0x1000: [DebuggerPDP11.OPS.MOV, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 01SSDD
|
||||
0x2000: [DebuggerPDP11.OPS.CMP, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 02SSDD
|
||||
0x3000: [DebuggerPDP11.OPS.BIT, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 03SSDD
|
||||
0x4000: [DebuggerPDP11.OPS.BIC, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 04SSDD
|
||||
0x5000: [DebuggerPDP11.OPS.BIS, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 05SSDD
|
||||
0x6000: [DebuggerPDP11.OPS.ADD, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 06SSDD
|
||||
0x9000: [DebuggerPDP11.OPS.MOVB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 11SSDD
|
||||
0xA000: [DebuggerPDP11.OPS.CMPB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 12SSDD
|
||||
0xB000: [DebuggerPDP11.OPS.BITB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 13SSDD
|
||||
0xC000: [DebuggerPDP11.OPS.BICB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 14SSDD
|
||||
0xD000: [DebuggerPDP11.OPS.BISB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST], // 15SSDD
|
||||
0xE000: [DebuggerPDP11.OPS.SUB, DebuggerPDP11.TYPE_SRC, DebuggerPDP11.TYPE_DST] // 16SSDD
|
||||
},
|
||||
0xFE00: {
|
||||
0x0800: [DebuggerPDP11.OPS.JSR, DebuggerPDP11.TYPE_SRCREG, DebuggerPDP11.TYPE_DST]
|
||||
0x0800: [DebuggerPDP11.OPS.JSR, DebuggerPDP11.TYPE_SRCREG, DebuggerPDP11.TYPE_DST], // 004RDD
|
||||
0x7000: [DebuggerPDP11.OPS.MUL, DebuggerPDP11.TYPE_DST, DebuggerPDP11.TYPE_SRCREG], // 070RSS
|
||||
0x7200: [DebuggerPDP11.OPS.DIV, DebuggerPDP11.TYPE_DST, DebuggerPDP11.TYPE_SRCREG], // 071RSS
|
||||
0x7400: [DebuggerPDP11.OPS.ASH, DebuggerPDP11.TYPE_DST, DebuggerPDP11.TYPE_SRCREG], // 072RSS
|
||||
0x7600: [DebuggerPDP11.OPS.ASHC, DebuggerPDP11.TYPE_DST, DebuggerPDP11.TYPE_SRCREG], // 073RSS
|
||||
0x7800: [DebuggerPDP11.OPS.XOR, DebuggerPDP11.TYPE_SRCREG, DebuggerPDP11.TYPE_DST], // 074RSS
|
||||
0x7E00: [DebuggerPDP11.OPS.SOB, DebuggerPDP11.TYPE_SRCREG, DebuggerPDP11.TYPE_DSTOFF] // 077Rnn
|
||||
},
|
||||
0xFF00: {
|
||||
0x0100: [DebuggerPDP11.OPS.BR, DebuggerPDP11.TYPE_BRANCH],
|
||||
|
|
@ -323,53 +340,59 @@ if (DEBUGGER) {
|
|||
0x8400: [DebuggerPDP11.OPS.BVC, DebuggerPDP11.TYPE_BRANCH],
|
||||
0x8500: [DebuggerPDP11.OPS.BVS, DebuggerPDP11.TYPE_BRANCH],
|
||||
0x8600: [DebuggerPDP11.OPS.BCC, DebuggerPDP11.TYPE_BRANCH],
|
||||
0x8700: [DebuggerPDP11.OPS.BCS, DebuggerPDP11.TYPE_BRANCH]
|
||||
0x8700: [DebuggerPDP11.OPS.BCS, DebuggerPDP11.TYPE_BRANCH],
|
||||
0x8800: [DebuggerPDP11.OPS.EMT], // 104000..104377
|
||||
0x8900: [DebuggerPDP11.OPS.TRAP] // 104400..104777
|
||||
},
|
||||
0xFFC0: {
|
||||
0x0010: [DebuggerPDP11.OPS.JMP, DebuggerPDP11.TYPE_DST],
|
||||
0x00C0: [DebuggerPDP11.OPS.SWAB, DebuggerPDP11.TYPE_DST],
|
||||
0x0480: [DebuggerPDP11.OPS.INC, DebuggerPDP11.TYPE_DST],
|
||||
0x0A00: [DebuggerPDP11.OPS.CLR, DebuggerPDP11.TYPE_DST],
|
||||
0x0A40: [DebuggerPDP11.OPS.COM, DebuggerPDP11.TYPE_DST],
|
||||
0x0AC0: [DebuggerPDP11.OPS.DEC, DebuggerPDP11.TYPE_DST],
|
||||
0x0B00: [DebuggerPDP11.OPS.NEG, DebuggerPDP11.TYPE_DST],
|
||||
0x0B40: [DebuggerPDP11.OPS.ADC, DebuggerPDP11.TYPE_DST],
|
||||
0x0B80: [DebuggerPDP11.OPS.SBC, DebuggerPDP11.TYPE_DST],
|
||||
0x0BC0: [DebuggerPDP11.OPS.TST, DebuggerPDP11.TYPE_DST],
|
||||
0x0C00: [DebuggerPDP11.OPS.ROR, DebuggerPDP11.TYPE_DST],
|
||||
0x0C40: [DebuggerPDP11.OPS.ROL, DebuggerPDP11.TYPE_DST],
|
||||
0x0C80: [DebuggerPDP11.OPS.ASR, DebuggerPDP11.TYPE_DST],
|
||||
0x0CC0: [DebuggerPDP11.OPS.ASL, DebuggerPDP11.TYPE_DST],
|
||||
0x0D00: [DebuggerPDP11.OPS.MARK, DebuggerPDP11.TYPE_DST],
|
||||
0x0D40: [DebuggerPDP11.OPS.MFPI, DebuggerPDP11.TYPE_DST],
|
||||
0x0D80: [DebuggerPDP11.OPS.MTPI, DebuggerPDP11.TYPE_DST],
|
||||
0x0DC0: [DebuggerPDP11.OPS.SXT, DebuggerPDP11.TYPE_DST],
|
||||
0x8480: [DebuggerPDP11.OPS.INCB, DebuggerPDP11.TYPE_DST],
|
||||
0x8A00: [DebuggerPDP11.OPS.CLRB, DebuggerPDP11.TYPE_DST],
|
||||
0x8A40: [DebuggerPDP11.OPS.COMB, DebuggerPDP11.TYPE_DST],
|
||||
0x8AC0: [DebuggerPDP11.OPS.DECB, DebuggerPDP11.TYPE_DST],
|
||||
0x8B00: [DebuggerPDP11.OPS.NEGB, DebuggerPDP11.TYPE_DST],
|
||||
0x8B40: [DebuggerPDP11.OPS.ADCB, DebuggerPDP11.TYPE_DST],
|
||||
0x8B80: [DebuggerPDP11.OPS.SBCB, DebuggerPDP11.TYPE_DST],
|
||||
0x8BC0: [DebuggerPDP11.OPS.TSTB, DebuggerPDP11.TYPE_DST],
|
||||
0x8C00: [DebuggerPDP11.OPS.RORB, DebuggerPDP11.TYPE_DST],
|
||||
0x8C40: [DebuggerPDP11.OPS.ROLB, DebuggerPDP11.TYPE_DST],
|
||||
0x8C80: [DebuggerPDP11.OPS.ASRB, DebuggerPDP11.TYPE_DST],
|
||||
0x8CC0: [DebuggerPDP11.OPS.ASLB, DebuggerPDP11.TYPE_DST],
|
||||
0x8D00: [DebuggerPDP11.OPS.MTPS, DebuggerPDP11.TYPE_DST], // only on LSI-11
|
||||
0x8D40: [DebuggerPDP11.OPS.MFPD, DebuggerPDP11.TYPE_DST], // same as MFPI if no separate instruction/data spaces
|
||||
0x8D80: [DebuggerPDP11.OPS.MTPD, DebuggerPDP11.TYPE_DST], // same as MTPI if no separate instruction/data spaces
|
||||
0x8DC0: [DebuggerPDP11.OPS.MFPS, DebuggerPDP11.TYPE_DST] // only on LSI-11
|
||||
0x0040: [DebuggerPDP11.OPS.JMP, DebuggerPDP11.TYPE_DST], // 0001DD
|
||||
0x00C0: [DebuggerPDP11.OPS.SWAB, DebuggerPDP11.TYPE_DST], // 0003DD
|
||||
0x0A00: [DebuggerPDP11.OPS.CLR, DebuggerPDP11.TYPE_DST], // 0050DD
|
||||
0x0A40: [DebuggerPDP11.OPS.COM, DebuggerPDP11.TYPE_DST], // 0051DD
|
||||
0x0A80: [DebuggerPDP11.OPS.INC, DebuggerPDP11.TYPE_DST], // 0052DD
|
||||
0x0AC0: [DebuggerPDP11.OPS.DEC, DebuggerPDP11.TYPE_DST], // 0053DD
|
||||
0x0B00: [DebuggerPDP11.OPS.NEG, DebuggerPDP11.TYPE_DST], // 0054DD
|
||||
0x0B40: [DebuggerPDP11.OPS.ADC, DebuggerPDP11.TYPE_DST], // 0055DD
|
||||
0x0B80: [DebuggerPDP11.OPS.SBC, DebuggerPDP11.TYPE_DST], // 0056DD
|
||||
0x0BC0: [DebuggerPDP11.OPS.TST, DebuggerPDP11.TYPE_DST], // 0057DD
|
||||
0x0C00: [DebuggerPDP11.OPS.ROR, DebuggerPDP11.TYPE_DST], // 0060DD
|
||||
0x0C40: [DebuggerPDP11.OPS.ROL, DebuggerPDP11.TYPE_DST], // 0061DD
|
||||
0x0C80: [DebuggerPDP11.OPS.ASR, DebuggerPDP11.TYPE_DST], // 0062DD
|
||||
0x0CC0: [DebuggerPDP11.OPS.ASL, DebuggerPDP11.TYPE_DST], // 0063DD
|
||||
0x0D00: [DebuggerPDP11.OPS.MARK, DebuggerPDP11.TYPE_DSTNUM6], // 0064nn
|
||||
0x0D40: [DebuggerPDP11.OPS.MFPI, DebuggerPDP11.TYPE_DST], // 0065SS
|
||||
0x0D80: [DebuggerPDP11.OPS.MTPI, DebuggerPDP11.TYPE_DST], // 0066DD
|
||||
0x0DC0: [DebuggerPDP11.OPS.SXT, DebuggerPDP11.TYPE_DST], // 0067DD
|
||||
0x8A00: [DebuggerPDP11.OPS.CLRB, DebuggerPDP11.TYPE_DST], // 1050DD
|
||||
0x8A40: [DebuggerPDP11.OPS.COMB, DebuggerPDP11.TYPE_DST], // 1051DD
|
||||
0x8A80: [DebuggerPDP11.OPS.INCB, DebuggerPDP11.TYPE_DST], // 1052DD
|
||||
0x8AC0: [DebuggerPDP11.OPS.DECB, DebuggerPDP11.TYPE_DST], // 1053DD
|
||||
0x8B00: [DebuggerPDP11.OPS.NEGB, DebuggerPDP11.TYPE_DST], // 1054DD
|
||||
0x8B40: [DebuggerPDP11.OPS.ADCB, DebuggerPDP11.TYPE_DST], // 1055DD
|
||||
0x8B80: [DebuggerPDP11.OPS.SBCB, DebuggerPDP11.TYPE_DST], // 1056DD
|
||||
0x8BC0: [DebuggerPDP11.OPS.TSTB, DebuggerPDP11.TYPE_DST], // 1057DD
|
||||
0x8C00: [DebuggerPDP11.OPS.RORB, DebuggerPDP11.TYPE_DST], // 1060DD
|
||||
0x8C40: [DebuggerPDP11.OPS.ROLB, DebuggerPDP11.TYPE_DST], // 1061DD
|
||||
0x8C80: [DebuggerPDP11.OPS.ASRB, DebuggerPDP11.TYPE_DST], // 1062DD
|
||||
0x8CC0: [DebuggerPDP11.OPS.ASLB, DebuggerPDP11.TYPE_DST], // 1063DD
|
||||
0x8D00: [DebuggerPDP11.OPS.MTPS, DebuggerPDP11.TYPE_DST], // 1064SS (only on LSI-11)
|
||||
0x8D40: [DebuggerPDP11.OPS.MFPD, DebuggerPDP11.TYPE_DST], // 1065DD (same as MFPI if no separate instruction/data spaces)
|
||||
0x8D80: [DebuggerPDP11.OPS.MTPD, DebuggerPDP11.TYPE_DST], // 1066DD (same as MTPI if no separate instruction/data spaces)
|
||||
0x8DC0: [DebuggerPDP11.OPS.MFPS, DebuggerPDP11.TYPE_DST] // 1067SS (only on LSI-11)
|
||||
},
|
||||
0xFFF8: {
|
||||
0x0080: [DebuggerPDP11.OPS.RTS, DebuggerPDP11.TYPE_SRCREG]
|
||||
0x0080: [DebuggerPDP11.OPS.RTS, DebuggerPDP11.TYPE_DSTREG], // 00020R
|
||||
0x0098: [DebuggerPDP11.OPS.SPL, DebuggerPDP11.TYPE_DSTNUM3] // 00023N
|
||||
},
|
||||
0xFFFF: {
|
||||
0x0000: [DebuggerPDP11.OPS.HALT],
|
||||
0x0001: [DebuggerPDP11.OPS.WAIT],
|
||||
0x0002: [DebuggerPDP11.OPS.RTI],
|
||||
0x0004: [DebuggerPDP11.OPS.BPT],
|
||||
0x0005: [DebuggerPDP11.OPS.RESET],
|
||||
0x0000: [DebuggerPDP11.OPS.HALT], // 000000
|
||||
0x0001: [DebuggerPDP11.OPS.WAIT], // 000001
|
||||
0x0002: [DebuggerPDP11.OPS.RTI], // 000002
|
||||
0x0003: [DebuggerPDP11.OPS.BPT], // 000003
|
||||
0x0004: [DebuggerPDP11.OPS.IOT], // 000004
|
||||
0x0005: [DebuggerPDP11.OPS.RESET], // 000005
|
||||
0x0006: [DebuggerPDP11.OPS.RTT], // 000006
|
||||
0x0007: [DebuggerPDP11.OPS.MFPT], // 000007
|
||||
0x00A0: [DebuggerPDP11.OPS.NOP],
|
||||
0x00A1: [DebuggerPDP11.OPS.CLC],
|
||||
0x00A2: [DebuggerPDP11.OPS.CLV],
|
||||
|
|
@ -385,7 +408,7 @@ if (DEBUGGER) {
|
|||
0x00AC: [DebuggerPDP11.OPS.CLZN],
|
||||
0x00AD: [DebuggerPDP11.OPS.CLCZN],
|
||||
0x00AE: [DebuggerPDP11.OPS.CLVZN],
|
||||
0x00AF: [DebuggerPDP11.OPS.CCC], // aka CLCVZN
|
||||
0x00AF: [DebuggerPDP11.OPS.CCC], // aka CLCVZN
|
||||
0x00B0: [DebuggerPDP11.OPS.NOP],
|
||||
0x00B1: [DebuggerPDP11.OPS.SEC],
|
||||
0x00B2: [DebuggerPDP11.OPS.SEV],
|
||||
|
|
@ -401,7 +424,7 @@ if (DEBUGGER) {
|
|||
0x00BC: [DebuggerPDP11.OPS.SEZN],
|
||||
0x00BD: [DebuggerPDP11.OPS.SECZN],
|
||||
0x00BE: [DebuggerPDP11.OPS.SEVZN],
|
||||
0x00BF: [DebuggerPDP11.OPS.SCC] // aka SECVZN
|
||||
0x00BF: [DebuggerPDP11.OPS.SCC] // aka SECVZN
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1942,16 +1965,30 @@ if (DEBUGGER) {
|
|||
*/
|
||||
DebuggerPDP11.prototype.getOperand = function(opCode, type, dbgAddr)
|
||||
{
|
||||
var sOperand = "";
|
||||
var sOperand = "", disp, addr;
|
||||
/*
|
||||
* Take care of TYPE_BRANCH opcodes first; then all we'll have to worry about
|
||||
* Take care of TYPE_OTHER opcodes first; then all we'll have to worry about
|
||||
* next are TYPE_SRC or TYPE_DST opcodes.
|
||||
*/
|
||||
if (type & DebuggerPDP11.TYPE_BRANCH) {
|
||||
var disp = ((opCode & 0xff) << 24) >> 24;
|
||||
var addr = (dbgAddr.addr + disp) & 0xffff;
|
||||
var typeOther = type & DebuggerPDP11.TYPE_OTHER;
|
||||
if (typeOther == DebuggerPDP11.TYPE_BRANCH) {
|
||||
disp = ((opCode & 0xff) << 24) >> 24;
|
||||
addr = (dbgAddr.addr + disp) & 0xffff;
|
||||
sOperand = str.toHexWord(addr);
|
||||
}
|
||||
else if (typeOther == DebuggerPDP11.TYPE_DSTOFF) {
|
||||
disp = (opCode & 0x3f) << 1;
|
||||
addr = (dbgAddr.addr - disp) & 0xffff;
|
||||
sOperand = str.toHexWord(addr);
|
||||
}
|
||||
else if (typeOther == DebuggerPDP11.TYPE_DSTNUM3) {
|
||||
disp = (opCode & 0x7);
|
||||
sOperand = str.toHexByte(disp);
|
||||
}
|
||||
else if (typeOther == DebuggerPDP11.TYPE_DSTNUM6) {
|
||||
disp = (opCode & 0x3f);
|
||||
sOperand = str.toHexByte(disp);
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Isolate all TYPE_SRC or TYPE_DST bits from opcode in the mode variable.
|
||||
|
|
@ -2056,11 +2093,14 @@ if (DEBUGGER) {
|
|||
var b;
|
||||
switch (sFlag) {
|
||||
case 'N':
|
||||
b = this.cpu.getSF();
|
||||
b = this.cpu.getNF();
|
||||
break;
|
||||
case 'Z':
|
||||
b = this.cpu.getZF();
|
||||
break;
|
||||
case 'V':
|
||||
b = this.cpu.getVF();
|
||||
break;
|
||||
case 'C':
|
||||
b = this.cpu.getCF();
|
||||
break;
|
||||
|
|
@ -2085,13 +2125,13 @@ if (DEBUGGER) {
|
|||
|
||||
if (iReg < 8) {
|
||||
sReg = (iReg < 6? ("R" + iReg) : (iReg == 6? "SP" : "PC"));
|
||||
sReg += '=' + str.toHex(cpu.regsCur[iReg], 4);
|
||||
sReg += '=' + str.toHex(cpu.regsGen[iReg], 4);
|
||||
}
|
||||
else if (iReg < 13) {
|
||||
sReg = "A" + (iReg - 8) + '=' + str.toHex(cpu.regsAlt[iReg - 8], 4);
|
||||
}
|
||||
else if (iReg >= 16 && iReg < 20) {
|
||||
sReg = "S" + (iReg - 16) + '=' + str.toHex(cpu.regsStack[iReg - 16], 4);
|
||||
sReg = "S" + (iReg - 16) + '=' + str.toHex(cpu.regsAltStack[iReg - 16], 4);
|
||||
}
|
||||
else if (iReg == DebuggerPDP11.REG_PSW) {
|
||||
sReg = "PS=" + str.toHex(cpu.getPSW(), 4);
|
||||
|
|
@ -3070,14 +3110,17 @@ if (DEBUGGER) {
|
|||
cpu.setPC(w);
|
||||
this.dbgAddrNextCode = this.newAddr(cpu.getPC());
|
||||
break;
|
||||
case "CF":
|
||||
if (w) cpu.setCF(); else cpu.clearCF();
|
||||
case "NF":
|
||||
if (w) cpu.setNF(); else cpu.clearNF();
|
||||
break;
|
||||
case "ZF":
|
||||
if (w) cpu.setZF(); else cpu.clearZF();
|
||||
break;
|
||||
case "SF":
|
||||
if (w) cpu.setSF(); else cpu.clearSF();
|
||||
case "VF":
|
||||
if (w) cpu.setVF(); else cpu.clearVF();
|
||||
break;
|
||||
case "CF":
|
||||
if (w) cpu.setCF(); else cpu.clearCF();
|
||||
break;
|
||||
default:
|
||||
this.println("unknown register: " + sReg);
|
||||
|
|
@ -3215,7 +3258,7 @@ if (DEBUGGER) {
|
|||
if (n > 2) {
|
||||
dbgAddr.addr = addr;
|
||||
var s = this.getInstruction(dbgAddr);
|
||||
if (s.indexOf("CALL") >= 0) {
|
||||
if (s.indexOf("JSR") >= 0) {
|
||||
/*
|
||||
* Verify that the length of this CALL (or INT), when added to the address of the CALL (or INT),
|
||||
* matches the original return address. We do this by getting the string index of the opcode bytes,
|
||||
|
|
|
|||
|
|
@ -122,21 +122,38 @@ var PDP11 = {
|
|||
* automatic inlining will no longer occur.
|
||||
*/
|
||||
ADDR_INVALID: -1,
|
||||
|
||||
/*
|
||||
* Processor Modes
|
||||
*/
|
||||
MODE: {
|
||||
KERNEL: 0x0,
|
||||
SUPER: 0x1,
|
||||
UNUSED: 0x2,
|
||||
USER: 0x3,
|
||||
MASK: 0x3
|
||||
},
|
||||
/*
|
||||
* Processor Status flag definitions (stored in regPSW)
|
||||
*/
|
||||
PSW: {
|
||||
CF: 0x0001, // bit 0: Carry Flag
|
||||
OF: 0x0002, // bit 1: Overflow Flag
|
||||
CF_SHIFT: 0,
|
||||
VF: 0x0002, // bit 1: Overflow Flag (aka OF on Intel processors)
|
||||
VF_SHIFT: 1,
|
||||
ZF: 0x0004, // bit 2: Zero Flag
|
||||
SF: 0x0008, // bit 3: Sign Flag
|
||||
ZF_SHIFT: 2,
|
||||
NF: 0x0008, // bit 3: Negative Flag (aka SF -- Sign Flag -- on Intel processors)
|
||||
NF_SHIFT: 3,
|
||||
TF: 0x0010, // bit 4: Trap Flag
|
||||
TF_SHIFT: 4,
|
||||
PRI: 0x00E0, // bits 5-7: Priority
|
||||
PRI_SHIFT: 5,
|
||||
UNUSED: 0x0700, // bits 8-10: unused
|
||||
REGSET: 0x0800, // bit 11: Register Set
|
||||
PMODE: 0x3000, // bits 12-13: Previous Mode
|
||||
CMODE: 0xC000 // bits 14-15: Current Mode
|
||||
PMODE: 0x3000, // bits 12-13: Previous Mode (see PDP11.MODE)
|
||||
PMODE_SHIFT:12,
|
||||
CMODE: 0xC000, // bits 14-15: Current Mode (see PDP11.MODE)
|
||||
CMODE_SHIFT:14
|
||||
},
|
||||
/*
|
||||
* Interrupt-related flags (stored in intFlags)
|
||||
|
|
@ -150,7 +167,7 @@ var PDP11 = {
|
|||
* Opcode definitions
|
||||
*/
|
||||
OPCODE: {
|
||||
// to be continued....
|
||||
// TODO
|
||||
},
|
||||
|
||||
IOBASE_VIRT: 0x00E000, /*000160000*/
|
||||
|
|
@ -168,18 +185,18 @@ var PDP11 = {
|
|||
};
|
||||
|
||||
/*
|
||||
* PSW "arithmetic" flags are NOT stored in the PSW register; they are maintained across separate result registers,
|
||||
* hence the RESULT designation.
|
||||
* PSW arithmetic flags are NOT stored directly into the PSW register; they are maintained across separate
|
||||
* flag registers.
|
||||
*/
|
||||
PDP11.PSW.RESULT = (PDP11.PSW.CF | PDP11.PSW.ZF | PDP11.PSW.SF);
|
||||
PDP11.PSW.FLAGS = (PDP11.PSW.NF | PDP11.PSW.ZF | PDP11.PSW.VF | PDP11.PSW.CF);
|
||||
|
||||
if (NODE) {
|
||||
global.APPCLASS = APPCLASS;
|
||||
global.APPNAME = APPNAME;
|
||||
global.DEBUGGER = DEBUGGER;
|
||||
global.BYTEARRAYS = BYTEARRAYS;
|
||||
global.TYPEDARRAYS = TYPEDARRAYS;
|
||||
global.PDP11 = PDP11;
|
||||
global.APPCLASS = APPCLASS;
|
||||
global.APPNAME = APPNAME;
|
||||
global.DEBUGGER = DEBUGGER;
|
||||
global.BYTEARRAYS = BYTEARRAYS;
|
||||
global.TYPEDARRAYS = TYPEDARRAYS;
|
||||
global.PDP11 = PDP11;
|
||||
|
||||
module.exports = PDP11;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,173 +1,173 @@
|
|||
(function(){var m;
|
||||
function ea(a){var b=16,d;if(a){b||(b=10);var c=a.charAt(0),e=0<a.indexOf(",");e&&(a=a.replace(/,/g,""));"#"==c?(b=8,c=null):"$"==c&&(b=16,c=null);null==c?a=a.substr(1):("0"==c&&(c=a.charAt(1),"b"==c&&e&&(b=2,c=null),"o"==c?(b=8,c=null):"x"==c&&(b=16,c=null)),null==c?a=a.substr(2):(c=a.charAt(a.length-1).toLowerCase(),"y"==c?(b=2,c=null):"."==c?(b=10,c=null):"h"==c&&(b=16,c=null),null==c&&(a=a.substr(0,a.length-1))));var f,c=a;((e=b)&&10!=e?16==e?null!==c.match(/^[0-9a-f]+$/i):8==e?null!==c.match(/^[0-7]+$/):2==
|
||||
e&&null!==c.match(/^[01]+$/):null!==c.match(/^[0-9]+$/))&&!isNaN(f=parseInt(a,b))&&(d=f|0)}return d}function p(a,b,d){var c="";b?8<b&&(b=8):b=a&-65536?8:4;if(null==a||isNaN(a))for(;0<b--;)c="?"+c;else for(;0<b--;){var e=a&15,e=e+(0<=e&&9>=e?48:55),c=String.fromCharCode(e)+c;a>>=4}return(d?"0x":"")+c}function r(a){return p(a,4,!0)}function fa(a){var b=a,d=a.lastIndexOf("/");0<=d&&(b=a.substr(d+1));d=b.indexOf("&");0<d&&(b=b.substr(0,d));return b}
|
||||
function ga(a){var b="",d=a.lastIndexOf(".");0<=d&&(b=a.substr(d+1).toLowerCase());return b}function ja(){var a=ka();return-1!==a.indexOf("pcjs.org",a.length-8)}var la={"&":"&","<":"<",">":">",'"':""","'":"'"};function ma(a){return a.replace(/[&<>"']/g,function(a){return la[a]})}function na(a,b){return(a+" ").slice(0,b)}function oa(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}
|
||||
function sa(a,b,d){var c=0,e=a.length,f=0;for(void 0===d&&(d=function(a,b){return a>b?1:a<b?-1:0});c<e;){var h=c+e>>1,g;g=d(b,a[h]);0<g?c=h+1:(e=h,f=!g)}return f?c:~c}var ta=Date.now||function(){return+new Date};function ua(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}
|
||||
function va(a,b,d,c){var e=0,f=null,h=null;if("object"==typeof resources&&(f=resources[a]))return c&&c(a,f,e),[f,e];if(d&&"function"==typeof resources)return resources(a,function(b,d){c&&c(a,b,d)}),h;var g=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");d&&(g.onreadystatechange=function(){4===g.readyState&&(f=g.responseText,200==g.status||!g.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=g.status||-1),c&&c(a,f,e))});if(b&&"object"==
|
||||
typeof b){var k="",l;for(l in b)b.hasOwnProperty(l)&&(k&&(k+="&"),k+=l+"="+encodeURIComponent(b[l]));k=k.replace(/%20/g,"+");g.open("POST",a,!!d);g.setRequestHeader("Content-type","application/x-www-form-urlencoded");g.send(k)}else g.open("GET",a,!!d),"bytes"==b&&g.overrideMimeType("text/plain; charset=x-user-defined"),g.send();d||(f=g.responseText,200!=g.status&&(e=g.status||-1),c&&c(a,f,e),h=[f,e]);return h}function ka(){return"http://"+(window?window.location.host:"www.pcjs.org")}
|
||||
function t(a){window&&window.alert(a)}function wa(a){var b=!1;window&&(b=window.confirm(a));return b}var xa=null;function ya(){if(null==xa){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}xa=a}return xa}function Fa(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(d){}return b}
|
||||
function fa(a){var b=16,d;if(a){b||(b=10);var c=a.charAt(0),e=0<a.indexOf(",");e&&(a=a.replace(/,/g,""));"#"==c?(b=8,c=null):"$"==c&&(b=16,c=null);null==c?a=a.substr(1):("0"==c&&(c=a.charAt(1),"b"==c&&e&&(b=2,c=null),"o"==c?(b=8,c=null):"x"==c&&(b=16,c=null)),null==c?a=a.substr(2):(c=a.charAt(a.length-1).toLowerCase(),"y"==c?(b=2,c=null):"."==c?(b=10,c=null):"h"==c&&(b=16,c=null),null==c&&(a=a.substr(0,a.length-1))));var f,c=a;((e=b)&&10!=e?16==e?null!==c.match(/^[0-9a-f]+$/i):8==e?null!==c.match(/^[0-7]+$/):2==
|
||||
e&&null!==c.match(/^[01]+$/):null!==c.match(/^[0-9]+$/))&&!isNaN(f=parseInt(a,b))&&(d=f|0)}return d}function p(a,b,d){var c="";b?8<b&&(b=8):b=a&-65536?8:4;if(null==a||isNaN(a))for(;0<b--;)c="?"+c;else for(;0<b--;){var e=a&15,e=e+(0<=e&&9>=e?48:55),c=String.fromCharCode(e)+c;a>>=4}return(d?"0x":"")+c}function r(a){return p(a,4,!0)}function ga(a){var b=a,d=a.lastIndexOf("/");0<=d&&(b=a.substr(d+1));d=b.indexOf("&");0<d&&(b=b.substr(0,d));return b}
|
||||
function ha(a){var b="",d=a.lastIndexOf(".");0<=d&&(b=a.substr(d+1).toLowerCase());return b}function ka(){var a=la();return-1!==a.indexOf("pcjs.org",a.length-8)}var ma={"&":"&","<":"<",">":">",'"':""","'":"'"};function na(a){return a.replace(/[&<>"']/g,function(a){return ma[a]})}function oa(a,b){return(a+" ").slice(0,b)}function pa(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}
|
||||
function ta(a,b,d){var c=0,e=a.length,f=0;for(void 0===d&&(d=function(a,b){return a>b?1:a<b?-1:0});c<e;){var h=c+e>>1,g;g=d(b,a[h]);0<g?c=h+1:(e=h,f=!g)}return f?c:~c}var ua=Date.now||function(){return+new Date};function va(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}
|
||||
function wa(a,b,d,c){var e=0,f=null,h=null;if("object"==typeof resources&&(f=resources[a]))return c&&c(a,f,e),[f,e];if(d&&"function"==typeof resources)return resources(a,function(b,d){c&&c(a,b,d)}),h;var g=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");d&&(g.onreadystatechange=function(){4===g.readyState&&(f=g.responseText,200==g.status||!g.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=g.status||-1),c&&c(a,f,e))});if(b&&"object"==
|
||||
typeof b){var k="",l;for(l in b)b.hasOwnProperty(l)&&(k&&(k+="&"),k+=l+"="+encodeURIComponent(b[l]));k=k.replace(/%20/g,"+");g.open("POST",a,!!d);g.setRequestHeader("Content-type","application/x-www-form-urlencoded");g.send(k)}else g.open("GET",a,!!d),"bytes"==b&&g.overrideMimeType("text/plain; charset=x-user-defined"),g.send();d||(f=g.responseText,200!=g.status&&(e=g.status||-1),c&&c(a,f,e),h=[f,e]);return h}function la(){return"http://"+(window?window.location.host:"www.pcjs.org")}
|
||||
function u(a){window&&window.alert(a)}function xa(a){var b=!1;window&&(b=window.confirm(a));return b}var ya=null;function za(){if(null==ya){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}ya=a}return ya}function Fa(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(d){}return b}
|
||||
function Ga(a,b){try{return window.localStorage.setItem(a,b),!0}catch(d){}return!1}function Ha(a){if(window){var b=window?window.navigator.userAgent:"";return"iOS"==a&&b.match(/(iPod|iPhone|iPad)/)&&b.match(/AppleWebKit/)||"MSIE"==a&&b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)?!0:!1}return!1}function Ia(a,b,d){function c(){--a;0<=a&&(b()||(a=0));0<a?setTimeout(c,0):d()}c()}
|
||||
function Ja(a,b){function d(){b(100===c)&&(e=setTimeout(d,c),c=100)}var c=0,e=null,f=!1;a.onmousedown=function(){f||e||(c=500,d())};a.ontouchstart=function(){e||(c=500,d())};a.onmouseup=a.onmouseout=function(){e&&(clearTimeout(e),e=null)};a.ontouchend=a.ontouchcancel=function(){e&&(clearTimeout(e),e=null);f=!0}}var Ka={init:[],show:[],exit:[]},La=!1,Ma=!1,Na=!0;function Oa(a,b){if(window){var d=window[a];window[a]="function"!==typeof d?b:function(){d&&d();b()}}}function Pa(a){Ka.init.push(a)}
|
||||
function Qa(a){if(Na)try{for(var b=0;b<a.length;b++)a[b]()}catch(d){t(""+("An unexpected exception occurred:\n\n"+d.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function Ra(a){!Na&&a?(Na=!0,La&&Sa("init"),Ma&&Sa("show")):Na=a}function Sa(a){Ka[a]&&Qa(Ka[a])}Oa("onload",function(){La=!0;Qa(Ka.init)});Oa("onpageshow",function(){Ma=!0;Qa(Ka.show)});Oa(Ha("Opera")||Ha("iOS")?"onunload":"onbeforeunload",function(){Qa(Ka.exit)});
|
||||
function v(a,b,d,c){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.mb=b.comment;this.Gb=b;b=this.id.indexOf(".");0>b?this.Va=this.id:(this.nb=this.id.substr(0,b),this.Va=this.id.substr(b+1));this[a]=d;this.w={ready:!1,Da:!1,Wa:!1,W:!1,error:!1};this.Ua=null;this.w.error=!1;this.J={};this.D=null;this.X=c||0;x.push(this)}var Ta=void 0,Ua={};
|
||||
function Qa(a){if(Na)try{for(var b=0;b<a.length;b++)a[b]()}catch(d){u(""+("An unexpected exception occurred:\n\n"+d.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function Ra(a){!Na&&a?(Na=!0,La&&Sa("init"),Ma&&Sa("show")):Na=a}function Sa(a){Ka[a]&&Qa(Ka[a])}Oa("onload",function(){La=!0;Qa(Ka.init)});Oa("onpageshow",function(){Ma=!0;Qa(Ka.show)});Oa(Ha("Opera")||Ha("iOS")?"onunload":"onbeforeunload",function(){Qa(Ka.exit)});
|
||||
function x(a,b,d,c){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.kb=b.comment;this.Eb=b;b=this.id.indexOf(".");0>b?this.La=this.id:(this.lb=this.id.substr(0,b),this.La=this.id.substr(b+1));this[a]=d;this.w={ready:!1,Fa:!1,Za:!1,Z:!1,error:!1};this.Xa=null;this.w.error=!1;this.L={};this.I=null;this.$=c||0;z.push(this)}var Ta=void 0,Ua={};
|
||||
if(window){Ta||(Ta=window.location.search.substr(1));for(var Va,Wa=/\+/g,Xa=/([^&=]+)=?([^&]*)/g;Va=Xa.exec(Ta);)Ua[decodeURIComponent(Va[1].replace(Wa," "))]=decodeURIComponent(Va[2].replace(Wa," "))}function Ya(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var d=typeof a;if("object"!==d&&"function"!==d)throw new TypeError;}b.prototype=a;return new b}
|
||||
function y(a,b){b||(b=v);a.prototype=Ya(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}if(window){window.PCjs||(window.PCjs={});var Za=window.PCjs.Machines||(window.PCjs.Machines={}),x=window.PCjs.Components||(window.PCjs.Components=[])}else Za={},x=[];function $a(a,b,d){Za[a]&&b&&(Za[a][b]=d)}function ab(a){var b,d=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<x.length;b++){var c=x[b];a&&c.id.indexOf(a)||d.push(c)}return d}
|
||||
function kb(a,b){var d;if(void 0!==a){var c;b&&(b=0<(c=b.indexOf("."))?b.substr(0,c+1):"");for(c=0;c<x.length;c++)if(d)d==x[c]&&(d=null);else if(!(a!=x[c].type||b&&x[c].id.indexOf(b)))return x[c]}return null}function B(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(d){t(d.message+" ("+a+")")}return b}
|
||||
function lb(a,b){for(var d=D(b.parentNode,"pdp11-control"),c=0;c<d.length;c++)for(var e=d[c].childNodes,f=0;f<e.length;f++){var h=e[f];if(1===h.nodeType){var g=h.getAttribute("class");if(g)for(var k=g.split(" "),l=0;l<k.length;l++)switch(g=k[l],g){case "pdp11-binding":(g=B(h))&&g.binding&&a.fa(g.type,g.binding,h,g.value),l=k.length}}}}
|
||||
function D(a,b,d){d&&(b+="-"+d+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var c;d=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(c=a.length;b<c;b++)e.test(a[b].className)&&d.push(a[b]);return d}
|
||||
v.prototype={constructor:v,parent:null,toString:function(){return this.name?this.name:this.id||this.type},fa:function(a,b,d){switch(b){case "clear":return this.J[b]||(this.J[b]=d,d.onclick=function(a){return function(){a.J.print&&(a.J.print.value="")}}(this)),!0;case "print":return this.J[b]||(this.wa=this.J[b]=d,d.value="",this.j=function(a){return function(b,d){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==d?d+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(d),
|
||||
this.da=function(a){this.j(a,this.Va)}),!0;default:return!1}},log:function(){},j:function(){},status:function(a){this.j(this.Va+": "+a)},da:function(a,b,d){d=d||this.type;b||t((d?d+": ":"")+a)},sa:function(){return this.w.W=!0},ra:function(a,b){b&&(this.w.W=!1);return!0}};function mb(a,b){if(a.D){a===a.D?b|=0:b=b||a.X;var d=a.D.X&b;return!!b&&d===b||!!(d&a.D.Ab)}return!1}
|
||||
function nb(a,b){if(a.w.Wa)return a.w.Da&&(a.w.Da=!1),a.w.Wa=!1;if(a.w.error)return a.j(a.toString()+" error"),!1;a.w.Da=b;return a.w.Da}function ob(a,b){a.w.Da&&(b?a.w.Wa=!0:void 0===b&&a.j(a.toString()+" busy"));return a.w.Da}function E(a){if(!a.w.error&&(a.w.ready=!0,a.w.ready)){var b=a.Ua;a.Ua=null;b&&b()}}function pb(a,b){b&&(a.w.ready?b():a.Ua=b);return a.w.ready}function qb(a,b){a.w.error=!0;a.da(b)}
|
||||
var rb="undefined"!==typeof ArrayBuffer,F={cpu:1,bus:64,mem:128,keyboard:65536,key:131072,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:268435456,warn:536870912,buffer:1073741824,halt:-2147483648};function sb(a){v.call(this,"Panel",a,sb)}y(sb);m=sb.prototype;m.fa=function(a,b,d,c){return this.C&&this.C.fa(a,b,d,c)||this.b&&this.b.fa(a,b,d,c)||this.D&&this.D.fa(a,b,d,c)?!0:this.parent.fa.call(this,a,b,d,c)};m.xa=function(a,b,d,c){this.C=a;this.G=b;this.b=d;this.D=c};
|
||||
m.sa=function(a,b){b||tb();return!0};m.ra=function(){return!0};m.ha=function(){};function tb(){for(var a=!1,b=D(document,"pdp11","panel"),d=0;d<b.length;d++){var c=b[d],e=B(c),f;a:{f=e.id;if(void 0!==f)for(var h=void 0,h=0;h<x.length;h++)if(x[h].id===f){f=x[h];break a}f=null}f||(a=!0,f=new sb(e));lb(f,c);a&&E(f)}}Pa(tb);
|
||||
function ub(a,b,d){v.call(this,"Bus",a,ub);this.b=b;this.D=d;this.u=a.busWidth||16;this.C=Math.pow(2,this.u);this.i=this.C-1|0;this.$=16>=this.u?10:20>=this.u?12:24>=this.u?14:15;this.ja=1<<this.$;this.B=this.ja>>2;this.g=this.ja-1;this.G=this.C/this.ja|0;this.F=this.G-1;a=new G;vb(a,this.D);this.N=Array(this.G);for(b=0;b<this.G;b++)this.N[b]=a;E(this)}y(ub);ub.prototype.reset=function(){};ub.prototype.sa=function(a,b){b||this.reset();return!0};
|
||||
function wb(a,b,d,c){for(var e=b,f=d,h=e>>>a.$;0<f&&h<a.N.length;){var g=a.N[h],k=h*a.ja,l=a.ja-(e-k);l>f&&(l=f);if(g&&g.size){if(g.type==c){if(e+f<=g.A)return g.Sa+=g.A-e,g.A=e,!0;if(e>=g.A+g.Sa){l=g.size-(e-k);l>f&&(l=f);g.Sa=e-g.A+l;e=k+a.ja;f-=l;h++;continue}}return xb(1,e,f)}e=new G(e,l,a.ja,c);vb(e,a.D,g);a.N[h++]=e;e=k+a.ja;f-=l}return 0>=f?(a.status(Math.floor(d/1024)+"Kb "+yb[c]+" at "+r(b)),!0):xb(2,b,d)}
|
||||
function zb(a,b){var d=b&a.g,c=(b&a.i)>>>a.$;return d!=a.g?a.N[c].vb(d,b):a.N[c++].Qa(d,b)|a.N[c&a.F].Qa(0,b+1)<<8}function xb(a,b,d){t("Memory block error ("+a+": "+p(b)+","+p(d)+")");return!1}var Ab;if(rb){var Mb=new ArrayBuffer(2);(new DataView(Mb)).setUint16(0,256,!0);Ab=256===(new Uint16Array(Mb))[0]}else Ab=!1;var Nb=Ab;
|
||||
function G(a,b,d,c){this.id=Ob+=2;this.b=null;this.A=a;this.Sa=b;this.size=d||0;this.type=c||Pb;this.B=c==Qb;vb(this);this.ta=this.Cb=!1;if(d)if(rb)this.J=new ArrayBuffer(d),this.C=new DataView(this.J,0,d),this.g=new Uint8Array(this.J,0,d),this.K=new Uint16Array(this.J,0,d>>1),this.b=new Int32Array(this.J,0,d>>2),Rb(this,Nb?Sb:Tb);else{this.b=Array(d>>2);for(a=0;a<this.b.length;a++)this.b[a]=0;Rb(this,Ub)}else Rb(this)}var Pb=0,Qb=2,yb=["NONE","RAM","ROM","VID","H/W"],Ob=0;
|
||||
G.prototype={constructor:G,parent:null,save:function(){var a,b;if(rb)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.C.getInt32(b<<2,!0);else a=this.b;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(rb)for(b=0;b<a.length;b++)this.C.setInt32(b<<2,a[b],!0);else this.b=a;return this.ta=!0}return!1},va:function(a,b){b?0===this.u++&&Vb(this,Wb,!1):0===this.i++&&Xb(this,Wb,!1)},L:function(){this.D&&mb(this.D,129)&&this.D.message("attempt to read invalid block %"+p(this.A),!0);
|
||||
return 255},G:function(a,b){this.D&&mb(this.D,129)&&this.D.message("attempt to write "+r(b)+" to invalid block %"+p(this.A),!0)},U:function(a,b){return this.F(a++,b++)|this.F(a,b)<<8},na:function(a,b,d){this.I(a++,b&255,d++);this.I(a,b>>8,d)},R:function(a){return this.b[a>>2]>>>((a&3)<<3)&255},Z:function(a){var b=a>>2;a=(a&3)<<3;var d=this.b[b]>>a;return 24>a?d&65535:d&255|(this.b[b+1]&255)<<8},ga:function(a,b){var d=a>>2,c=(a&3)<<3;this.b[d]=this.b[d]&~(255<<c)|b<<c;this.ta=!0},pa:function(a,b){var d=
|
||||
a>>2,c=(a&3)<<3;24>c?this.b[d]=this.b[d]&~(65535<<c)|b<<c:(this.b[d]=this.b[d]&16777215|b<<24,d++,this.b[d]=this.b[d]&-256|b>>8);this.ta=!0},O:function(a,b){if(this.D&&null!=this.A){var d=this.D;Yb(d,this.A+a,1,d.M)&&d.aa(!0)}return this.Qa(a,b)},T:function(a,b){if(this.D&&null!=this.A){var d=this.D;Yb(d,this.A+a,2,d.M)&&d.aa(!0)}return this.vb(a,b)},ca:function(a,b,d){if(this.D&&null!=this.A){var c=this.D;Yb(c,this.A+a,1,c.B)&&c.aa(!0)}this.B?this.G(a,b,d):this.Ia(a,b,d)},la:function(a,b,d){if(this.D&&
|
||||
null!=this.A){var c=this.D;Yb(c,this.A+a,2,c.B)&&c.aa(!0)}this.B?this.G(a,b,d):this.xb(a,b,d)},M:function(a){return this.g[a]},P:function(a){return this.g[a]},S:function(a){return this.C.getUint16(a,!0)},V:function(a){return a&1?this.g[a]|this.g[a+1]<<8:this.K[a>>1]},ba:function(a,b){this.g[a]=b;this.ta=!0},ea:function(a,b){this.g[a]=b;this.ta=!0},ia:function(a,b){this.C.setUint16(a,b,!0);this.ta=!0},oa:function(a,b){a&1?(this.g[a]=b,this.g[a+1]=b>>8):this.K[a>>1]=b;this.ta=!0}};
|
||||
function vb(a,b,d){a.D=b;a.i=a.u=0;d&&((a.i=d.i)&&Xb(a,Wb,!1),(a.u=d.u)&&Vb(a,Wb,!1))}function Zb(a,b){b?0===--a.u&&(a.I=a.B?a.G:a.Ia):0===--a.i&&(a.F=a.Qa)}function Vb(a,b,d){d&&a.u||(a.I=!a.B&&b[2]||a.G);if(d||void 0===d)a.Ia=b[2]||a.G,a.xb=b[3]||a.na}function Xb(a,b,d){d&&a.i||(a.F=b[0]||a.L);if(d||void 0===d)a.Qa=b[0]||a.L,a.vb=b[1]||a.U}function Rb(a,b){b||(b=$b);Xb(a,b,void 0);Vb(a,b,void 0)}
|
||||
var $b=[],Ub=[G.prototype.R,G.prototype.Z,G.prototype.ga,G.prototype.pa],Wb=[G.prototype.O,G.prototype.T,G.prototype.ca,G.prototype.la];if(rb)var Tb=[G.prototype.M,G.prototype.S,G.prototype.ba,G.prototype.ia],Sb=[G.prototype.P,G.prototype.V,G.prototype.ea,G.prototype.oa];
|
||||
function ac(a,b){v.call(this,"CPU",a,ac,1);var d=a.multiplier||1;this.Za=a.cycles||b;this.za=d;this.Ka=Math.round(this.Za/1E4)/100;this.ya=this.Ka*this.za;this.w.Y=!1;this.w.cb=!1;this.w.Ja=a.autoStart;this.w.ib=!1;this.w.Ea=!1;this.Na=this.ba=0;this.Oa=a.csStart;this.Fa=a.csInterval;this.Ga=a.csStop;this.la=[];this.Fb=this.Ba.bind(this);E(this)}y(ac);var bc=["power","reset"];m=ac.prototype;
|
||||
m.xa=function(a,b,d,c){this.C=a;this.G=b;this.D=c;for(b=0;b<bc.length;b++)(d=this.J[bc[b]])&&this.C.fa(null,bc[b],d);this.ga=null;a=cc(a,"autoStart");null!=a&&(this.w.Ja="true"==a?!0:"false"==a?!1:!!a);E(this)};m.reset=function(){};m.save=function(){return null};m.restore=function(){return!1};
|
||||
m.sa=function(a,b){if(!b){if(a&&this.restore){dc(this);if(!this.restore(a))return!1;ec(this)}else this.reset();if(this.D){var d=this.D;d.j("Type ? for help with PDP11 Debugger commands");d.ha();if(d.la){var c=d.la;d.la=null;fc(d,c)}}else this.j("No debugger detected")}H(this);return!0};m.ra=function(a){return a?this.save():!0};m.Ja=function(){return this.w.Ja||!this.D&&void 0===this.J.run?(this.Ba(!0),!0):!1};m.kb=function(){return 0};
|
||||
function ec(a){void 0===a.Oa&&(a.Oa=0);void 0===a.Fa&&(a.Fa=-1);void 0===a.Ga&&(a.Ga=-1);a.w.Ea=0<=a.Oa&&0<a.Fa;a.w.Ea&&(a.Na=0,a.ba=a.Oa-a.U)}function gc(a,b){if(a.w.Ea){var d=!1;a.Na=a.Na+a.kb()|0;a.ba-=b;0>=a.ba&&(a.ba+=a.Fa,d=!0);0<=a.Ga&&a.Ga<=hc(a)&&(a.Fa=a.Ga=-1,ec(a),a.aa(),d=!0);d&&a.j(hc(a)+" cycles: checksum="+p(a.Na))}}
|
||||
function ic(a,b,d,c){a.J[b]&&(void 0===d&&(qb(a,"Value for "+b+" is invalid"),a.aa()),d=!a.w.Y||a.w.ib?p(d,c):"--------".substr(0,c),a.J[b].textContent!=d&&(a.J[b].textContent=d))}
|
||||
m.fa=function(a,b,d){var c=this;a=!1;switch(b){case "power":case "reset":this.J[b]=d;a=!0;break;case "run":this.J[b]=d;d.onclick=function(){var a;if(a=c.C)if(a=c.C,a.w.W)a=!0;else{var b=null,d,g=ab(a.id);for(d=0;d<g.length&&(b=g[d],b===a||b.w.ready);d++);if(d==g.length)for(d=0;d<g.length&&(b=g[d],b===a||b.w.W);d++);d==g.length&&(b=a);t("The "+b.type+" component ("+b.id+") is not "+(b.w.ready?"powered yet":"ready yet"+(b.Ua?" (waiting for notification)":""))+".");a=!1}a&&(c.w.Y?c.aa():c.Ba())};a=!0;
|
||||
break;case "speed":this.J[b]=d;a=!0;break;case "setSpeed":this.J[b]=d,d.onclick=function(){jc(c,c.za<<1,!0)},d.textContent=this.ya.toFixed(2)+"Mhz",a=!0}return a};function kc(a,b,d){a.U+=b;d&&(a.T=a.P=0)}function lc(a,b){var d=1;b&&1<a.za&&a.R&&(d=a.R/a.Ka);a.sb=Math.round(1E3/30);a.pa=Math.floor(a.Za/30*d);b||(a.ca=a.pa);a.$a=0}function hc(a){return a.U+a.O+a.T-a.P}function dc(a){a.R=0;a.tb=0;a.U=a.O=a.T=a.P=0;ec(a);jc(a,1)}
|
||||
function jc(a,b,d){var c=!1;if(void 0!==b){.8>a.R/a.ya?b=1:c=!0;a.za=b;b=a.Ka*a.za;if(a.ya!=b){a.ya=b;b=a.ya.toFixed(2)+"Mhz";var e=a.J.setSpeed;e&&(e.textContent=b);a.j("target speed: "+b)}d&&a.C&&a.C.Ra()}kc(a,a.O);a.O=0;a.M=ta();a.S=0;lc(a);return c}function yc(a){a.T-=a.P;a.P=0}
|
||||
m.Ba=function(a){if(nb(this,!0)){if(!this.w.Y){jc(this);this.C&&this.C.start(this.M,hc(this));this.w.Y=!0;this.w.cb=!0;this.ga&&this.ga.start();var b=this.J.run;b&&(b.textContent="Halt");this.C&&(this.C.ha(!0),a&&this.C.Ra(!0))}this.$a>=this.Za&&lc(this,!0);this.ia=0;this.oa=ta();this.S&&(a=this.oa-this.S,a>this.sb&&(this.M+=a,this.M>this.oa&&(this.M=this.oa)));try{do{for(var d=this.w.Ea?1:this.pa,c=this.la.length-1;0<=c;c--){var e=this.la[c];0>e[0]||d>e[0]&&(d=e[0])}this.Ha(d);var f=this.T-this.P;
|
||||
a=f;for(var h=this.la.length-1;0<=h;h--){var g=this.la[h];0>g[0]||(g[0]-=a,0>=g[0]&&(g[0]=-1,g[1]()))}this.ia+=f;this.O+=f;kc(this,0,!0);gc(this,f);this.ca-=f;if(0>=this.ca){this.ca+=this.pa;15<=++this.tb&&(this.C&&this.C.ha(),this.tb=0);break}}while(this.w.Y)}catch(k){this.aa();H(this);this.C&&this.C.stop(ta(),hc(this));nb(this,!1);qb(this,k.stack||k.message);return}d=setTimeout;c=this.Fb;this.S=ta();e=this.sb;this.ia&&(e=Math.round(e*this.ia/this.pa));e=e-(this.S-this.oa);if(f=this.S-this.M)this.R=
|
||||
Math.round(this.O/(10*f))/100,864E5<=f&&(this.U=0,jc(this));if(0>e||this.R<this.ya)-1E3>e&&(this.M-=e),e=0;this.$a+=this.ia;this.S+=e;d(c,e)}else H(this),this.C&&this.C.stop(ta(),hc(this))};m.Ha=function(){return 0};m.aa=function(a){ob(this,!0);yc(this);kc(this,this.O);this.O=0;if(this.w.Y){this.w.Y=!1;this.ga&&this.ga.stop();var b=this.J.run;b&&(b.textContent="Run")}this.w.complete=a};function H(a,b){a.C&&a.C.ha(b)}
|
||||
function zc(a){this.rb=+a.model||1170;ac.call(this,a,1E6);this.lb=0;this.u=65536;this.g=this.b=32768;this.i=65535;this.H=15;this.f=[0,0,0,0,0,0,0,0];this.bb=[0,0,0,0,0,0];this.Aa=[0,0,0,0];this.memory=[];this.I=[];this.ab=this.ub=0;this.V=2;this.Z=255;this.F=0;this.ea=-1;this.qb=this.La=this.pb=this.B=this.Ca=this.L=this.K=0;this.na=[7,7,7,7];this.Ma=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[65535,65535,65535,
|
||||
65535,65535,65535,65535,65535,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];this.Hb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.w.complete=this.w.Bb=!1}y(zc,ac);m=zc.prototype;m.reset=function(){this.w.Y&&this.aa();Ac(this);dc(this);this.w.error=!1;this.parent.reset.call(this)};
|
||||
function Ac(a){a.Z=255;a.I=[];a.ub=0;a.K=a.L=a.Ca=a.pb=0;a.na[0]=a.na[1]=a.na[3]=7;a.La=0}m.kb=function(){return 0};m.save=function(){var a=new I(this);J(a,0,[]);J(a,1,[this.ob,this.U,this.za]);for(var b=this.G,d=0,c=[],e=0;e<b.G;e++){var f=b.N[e];if(f.ta||f.Cb){c[d++]=e;var h=d++;a:if(f=f.save()){for(var g=0,k=0,l=[];g<f.length;){for(var n=f[g],q=g+1;q<f.length&&f[q]===n;)q++;l[k++]=q-g;l[k++]=n;g=q}if(l.length<f.length){f=l;break a}}c[h]=f}}J(a,2,c);return a.data()};
|
||||
m.restore=function(a){var b=a[1];this.ob=b[0];this.U=b[1];jc(this,b[3]);a:{b=this.G;a=a[2];var d;for(d=0;d<a.length-1;d+=2){var c=a[d],e=a[d+1];if(e&&e.length<b.B){for(var f=0,h=Array(b.B),g=0;g<e.length-1;)for(var k=e[g++],l=e[g++];k--;)h[f++]=l;e=h}f=b.N[c];if(!f||!f.restore(e)){t("Unable to restore memory block "+c);b=!1;break a}}b=!0}return b};
|
||||
m.fa=function(a,b,d){var c=!1;switch(b){case "PC":case "PSW":case "SF":case "ZF":case "CF":this.J[b]=d;this.lb++;c=!0;break;default:c=this.parent.fa.call(this,a,b,d)}return c};m.ha=function(a){this.lb&&(a||!this.w.Y||this.w.ib)&&(a=this.H&-14|0|(this.ka&255?0:4)|(this.ka&256?1:0),ic(this,"PSW",a,4),ic(this,"SF",a&8?1:0,1),ic(this,"ZF",a&4?1:0,1),ic(this,"CF",a&1?1:0,1));if(a=this.J.speed)a.textContent=this.w.Y&&this.R?this.R.toFixed(2)+"Mhz":"Stopped"};
|
||||
function Bc(a,b){var d,c;a.b=b<<12;a.i=~b&4;a.g=b<<14;a.u=b<<16;if((b^a.H)&2048)for(d=0;6>d;d++)c=a.f[d],a.f[d]=a.bb[d],a.bb[d]=c;(a.B=b>>14&3)!==(a.H>>14&3)&&(a.Aa[c]=a.f[6],a.f[6]=a.Aa[a.B]);a.V=2;a.H=b}
|
||||
function L(a,b){var d,c,e=0;0>a.ea?(a.H=a.H&63728|a.b>>12&8|a.g>>14&2|a.u>>16&1,a.i&65535||(a.H|=4),a.ea=a.H):a.B||(b=4,e=1);a.K&57344||(a.L=63222);a.B=0;0<=(d=M(a,b|65536))&&0<=(c=M(a,b+2&65535|65536))&&(Bc(a,c&53247|a.ea>>2&12288),e&&(a.f[6]=4),0<=Cc(a,a.ea)&&0<=Cc(a,a.f[7])&&(a.f[7]=d));a.F=0;return a.ea=-1}
|
||||
function Dc(a,b,d){var c,e,f,h=0;if(d&a.pb){c=b>>13&a.na[a.B];e=a.Ma[a.B][c];f=(a.Ma[a.B][c+16]<<6)+(b&8191)&4194303;if(a.Ca&16){if(3932160<=f&&4186112>f){f=f&262143;var g=f>>13&31;31>g?a.Ca&32&&(f=a.Hb[g]+(f&8190)&4194302,3932160<=f&&4186112>f&&console.log("panic(898)")):f|=4186112}}else f&=262143,253952<=f&&(f|=4186112);if(3932160>f&&(3915776<=f||f&1&&!(d&1)))return L(a,4);switch(e&7){case 1:h=4096;case 2:e|=128;d&4&&(h=8192);break;case 4:h=4096;case 5:d&4&&(h=4096);case 6:e|=d&4?192:128;break;
|
||||
default:h=32768}32512!==(e&32520)&&(e&8?e&32512&&(b&8128)<(e>>2&8128)&&(h|=16384):(b&8128)>(e>>2&8128)&&(h|=16384));a.Ma[a.B][c]=e;if(4194170!==f||a.B)a.La=a.B,a.qb=c;if(h){if(h&57344)return 0<=a.ea&&(h|=128),a.K&57344||(a.K=a.K|h|a.La<<5|a.qb<<1),L(a,168);a.K&61440||!(4191360>f||4194239<f)||(a.K|=4096,a.K&512&&(a.F|=2))}}else if(f=b&65535,57344<=f)f|=4186112;else if(f&1&&!(d&1))return L(a,4);return f}function N(a,b){return 4194304<=b?a.f[b-4194304]:3932160<=b?-1:0<=b?a.memory[b>>1]:b}
|
||||
function Q(a,b,d){d&=65535;return 4194304<=b?a.f[b-4194304]=d:3932160<=b?-1:0<=b?a.memory[b>>1]=d:b}function R(a,b){var d;return 4194304<=b?a.f[b-4194304]&255:3932160<=b?-1:0<=b?(d=a.memory[b>>1],b&1&&(d=d>>8),d&255):b}function S(a,b,d){d&=255;return 4194304<=b?a.f[b-4194304]=a.f[b-4194304]&65280|d:3932160<=b?-1:0<=b?b&1?a.memory[b>>1]=d<<8|a.memory[b>>1]&255:a.memory[b>>1]=a.memory[b>>1]&65280|d:b}function M(a,b){return N(a,Dc(a,b,2))}
|
||||
function Ec(a){var b=M(a,a.f[6]|65536);0<=b&&(a.f[6]=a.f[6]+2&65535);return b}function Cc(a,b){var d,c;a.f[6]=c=a.f[6]-2&65535;a.K&57344||(a.L=a.L<<8|246);if(!a.B&&c<=a.Z&&4<c){if(c<=a.Z-32)return a.f[6]=4,L(a,4);a.F|=4}return 0<=(d=Dc(a,c|65536,4))?Q(a,d,b):d}
|
||||
function Fc(a,b,d){var c,e,f=b&7;switch(b>>3&7){case 0:return L(a,4);case 1:if(6===f&&!a.B&&d&4&&(a.f[6]<=a.Z||65534<=a.f[6])){if(a.f[6]<=a.Z-32||65534<=a.f[6])return a.f[6]=4,L(a,4);a.F|=4}return 7===f?a.f[f]:a.f[f]|65536;case 2:e=2;c=a.f[f];7!==f&&(c|=65536,6>f&&d&1&&(e=1));break;case 3:e=2;c=a.f[f];7!==f&&(c|=65536);if(0>(c=M(a,c)))return c;c|=65536;break;case 4:e=-2;6>f&&d&1&&(e=-1);c=a.f[f]+e&65535;7!==f&&(c|=65536);break;case 5:e=-2;c=a.f[f]-2&65535;7!==f&&(c|=65536);if(0>(c=M(a,c)))return c;
|
||||
c|=65536;break;case 6:if(0>(c=M(a,a.f[7])))return c;a.f[7]=a.f[7]+2&65535;c=c+a.f[f]&65535;return c|65536;case 7:if(0>(c=M(a,a.f[7])))return c;a.f[7]=a.f[7]+2&65535;c=c+a.f[f]&65535;return 0>(c=M(a,c|65536))?c:c|65536}a.f[f]=a.f[f]+e&65535;a.K&57344||(a.L=a.L<<8|e<<3&248|f);if(6===f&&!a.B&&d&4&&0>=e&&(a.f[6]<=a.Z||65534<=a.f[6])){if(a.f[6]<=a.Z-32)return a.f[6]=4,L(a,4);a.F|=4}return c}function T(a,b,d){var c;return b&56?(0<=(c=Fc(a,b,d))&&(c=Dc(a,c,d)),c):4194304+(b&7)}
|
||||
function U(a,b){var d;b&56?0<=(d=T(a,b,2))&&(d=N(a,d)):d=a.f[b&7];return d}function Gc(a,b){var d;b&56?0<=(d=T(a,b,3))&&(d=R(a,d)):d=a.f[b&7]&255;return d}function V(a,b){return((b&128?b|65280:b&255)<<1)+a&65535}
|
||||
m.Ha=function(a){this.w.complete=!0;var b=this.w.Bb=this.D&&Hc(this.D),d=a?this.w.cb?0:1:-1;this.w.cb=!1;this.T=this.P=a;this.ob&256?(yc(this),a=!1):a=!0;if(a){do{if(b){if(Ic(this.D,this.f[7],d)){this.aa();break}d=1}var c,e,f,h,g;if(this.V)if(1===this.V)this.V=2;else{this.V=0;g=-1;c=this.ub&224;if(0<(a=this.I.length))for(;0<a--;){if(0<this.I[a].Ya){this.I[a].Ya--;this.V=2;break}if(this.I[a].gb){if(!this.I[a].gb()){this.I.splice(a,1);g--;continue}this.I[a].gb=null}this.I[a].Eb>c&&(c=this.I[a].Eb,g=
|
||||
a)}c>(this.H&224)&&(0>g?L(this,160):(L(this,this.I[g].Jb),this.I.splice(g,1)))}this.K&57344||(this.L=0);this.F=this.H&16;if(0<=(a=M(this,this.f[7])))switch(this.f[7]=this.f[7]+2&65535,a&61440){case 4096:0<=(c=U(this,a>>6))&&(a&56?0<=(f=T(this,a,4))&&0<=Q(this,f,c)&&(this.b=this.i=c,this.g=0):(this.b=this.i=this.f[a&7]=c,this.g=0));break;case 8192:0<=(c=U(this,a>>6))&&0<=(e=U(this,a))&&(this.b=this.i=this.u=a=c-e,this.g=(c^e)&(c^a));break;case 12288:0<=(c=U(this,a>>6))&&0<=(e=U(this,a))&&(this.b=this.i=
|
||||
c&e,this.g=0);break;case 16384:0<=(c=U(this,a>>6))&&(a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=e&~c,0<=Q(this,f,a)&&(this.b=this.i=a,this.g=0)):(this.b=this.i=a=this.f[a&7]&=~c,this.g=0));break;case 20480:0<=(c=U(this,a>>6))&&(a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=e|c,0<=Q(this,f,a)&&(this.b=this.i=a,this.g=0)):(this.b=this.i=a=this.f[a&7]|=c,this.g=0));break;case 24576:0<=(c=U(this,a>>6))&&(a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=c+e,0<=Q(this,f,a)&&(this.b=this.i=this.u=a,this.g=(c^a)&(e^a))):(g=a&7,
|
||||
e=this.f[g],this.f[g]=(a=c+e)&65535,this.b=this.i=this.u=a,this.g=(c^a)&(e^a)));break;case 36864:0<=(c=Gc(this,a>>6))&&(a&56?0<=(f=T(this,a,5))&&0<=S(this,f,c)&&(this.b=this.i=c<<8,this.g=0):(c&128&&(c|=65280),this.b=this.i=this.f[a&7]=c,this.g=0));break;case 40960:0<=(c=Gc(this,a>>6))&&0<=(e=Gc(this,a))&&(a=c-e,this.b=this.i=this.u=a<<8,this.g=((c^e)&(c^a))<<8);break;case 45056:0<=(c=Gc(this,a>>6))&&0<=(e=Gc(this,a))&&(this.b=this.i=(c&e)<<8,this.g=0);break;case 49152:0<=(c=Gc(this,a>>6))&&0<=(e=
|
||||
R(this,f=T(this,a,7)))&&(a=e&~c,0<=S(this,f,a)&&(this.b=this.i=a<<8,this.g=0));break;case 53248:0<=(c=Gc(this,a>>6))&&0<=(e=R(this,f=T(this,a,7)))&&(a=e|c,0<=S(this,f,a)&&(this.b=this.i=a<<8,this.g=0));break;case 57344:0<=(c=U(this,a>>6))&&(a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=e-c,0<=Q(this,f,a)&&(this.b=this.i=this.u=a,this.g=(c^e)&(e^a))):(g=a&7,e=this.f[g],this.f[g]=(a=e-c)&65535,this.b=this.i=this.u=a,this.g=(c^e)&(e^a)));break;default:switch(a&65024){case 2048:0<=(h=Fc(this,a,0))&&(g=a>>6&7,
|
||||
0<=Cc(this,this.f[g])&&(this.f[g]=this.f[7],this.f[7]=h&65535));break;case 28672:0<=(c=U(this,a))&&(g=a>>6&7,c&32768&&(c|=-65536),e=this.f[g],e&32768&&(e|=-65536),a=~~(c*e),this.f[g]=a>>16&65535,this.f[g|1]=a&65535,this.b=a>>16,this.i=this.b|a,this.u=this.g=0,-32768>a||32767<a)&&(this.u=65536);break;case 29184:0<=(c=U(this,a))&&(c?(g=a>>6&7,e=this.f[g]<<16|this.f[g|1],this.u=this.g=0,c&32768&&(c|=-65536),a=~~(e/c),-32768<=a&&32767>=a?(this.f[g]=a&65535,this.f[g|1]=e-a*c&65535,this.i=a>>16|a,this.b=
|
||||
a>>16):(this.g=32768,this.i=a>>15|a,this.b=e>>16,-1===c&&65534===this.f[g]&&(this.f[g]=this.f[g|1]=1))):(this.i=this.b=0,this.g=32768,this.u=65536));break;case 29696:0<=(c=U(this,a))&&(g=a>>6&7,a=this.f[g],a&32768&&(a|=4294901760),this.u=this.g=0,c&=63,c&32?(c=64-c,16<c&&(c=16),this.u=a<<17-c,a=a>>c):c&&(16<c?(this.g=a,a=0):(this.u=a=a<<c,(e=a>>15&65535)&&65535!==e&&(this.g=32768))),this.f[g]=a&65535,this.b=this.i=a);break;case 30208:if(0<=(c=U(this,a))){g=a>>6&7;e=this.f[g]<<16|this.f[g|1];this.u=
|
||||
this.g=0;c&=63;if(c&32)c=64-c,32<c&&(c=32),a=e>>c-1,this.u=a<<16,a>>=1,e&2147483648&&(a|=4294967295<<32-c);else if(c){if(a=e<<c-1,this.u=a>>15,a<<=1,32<c&&(c=32),e>>=32-c)e|=4294967295<<c&4294967295,4294967295!==e&&(this.g=32768)}else a=e;this.f[g]=a>>16&65535;this.f[g|1]=a&65535;this.b=a>>16;this.i=a>>16|a}break;case 30720:a&56?0<=(e=N(this,f=T(this,a,6)))&&(e^=this.f[a>>6&7],0<=Q(this,f,e)&&(this.b=this.i=e,this.g=0)):(this.b=this.i=e=this.f[a&7]^=this.f[a>>6&7],this.g=0);break;case 32256:g=a>>
|
||||
6&7;if(this.f[g]=this.f[g]-1&65535)this.f[7]=this.f[7]-((a&63)<<1)&65535;break;default:switch(a&65280){case 256:this.f[7]=V(this.f[7],a);break;case 512:this.i&65535&&(this.f[7]=V(this.f[7],a));break;case 768:this.i&65535||(this.f[7]=V(this.f[7],a));break;case 1024:(this.b&32768)===(this.g&32768)&&(this.f[7]=V(this.f[7],a));break;case 1280:(this.b&32768)!==(this.g&32768)&&(this.f[7]=V(this.f[7],a));break;case 1536:this.i&65535&&(this.b&32768)===(this.g&32768)&&(this.f[7]=V(this.f[7],a));break;case 1792:this.i&
|
||||
65535&&(this.b&32768)===(this.g&32768)||(this.f[7]=V(this.f[7],a));break;case 32768:this.b&32768||(this.f[7]=V(this.f[7],a));break;case 33280:!(this.u&65536)&&this.i&65535&&(this.f[7]=V(this.f[7],a));break;case 33024:this.b&32768&&(this.f[7]=V(this.f[7],a));break;case 33536:if(this.u&65536||!(this.i&65535))this.f[7]=V(this.f[7],a);break;case 33792:this.g&32768||(this.f[7]=V(this.f[7],a));break;case 34048:this.g&32768&&(this.f[7]=V(this.f[7],a));break;case 34304:this.u&65536||(this.f[7]=V(this.f[7],
|
||||
a));break;case 34560:this.u&65536&&(this.f[7]=V(this.f[7],a));break;case 34816:L(this,24);break;case 35072:L(this,28);break;default:switch(a&65472){case 64:0<=(h=Fc(this,a,0))&&(this.f[7]=h&65535);break;case 192:a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=e<<8|e>>8,0<=Q(this,f,a)&&(this.b=this.i=e&65280,this.g=this.u=0)):(g=a&7,e=this.f[g],this.f[g]=(e<<8|e>>8)&65535,this.b=this.i=e&65280,this.g=this.u=0);break;case 2560:a&56?0<=(f=T(this,a,4))&&0<=Q(this,f,0)&&(this.b=this.u=this.g=this.i=0):this.b=this.u=
|
||||
this.g=this.i=this.f[a&7]=0;break;case 2624:0<=(e=N(this,f=T(this,a,6)))&&(a=~e,0<=Q(this,f,a)&&(this.b=this.i=a,this.u=65536,this.g=0));break;case 2688:a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=e+1,0<=Q(this,f,a)&&(this.b=this.i=a,this.g=a&(a^e))):(g=a&7,e=this.f[g],a=e+1,this.f[g]=a&65535,this.b=this.i=a,this.g=a&(a^e));break;case 2752:a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=e-1,0<=Q(this,f,a)&&(this.b=this.i=a,this.g=(a^e)&e)):(g=a&7,e=this.f[g],a=e-1,this.f[g]=a&65535,this.b=this.i=a,this.g=(a^e)&e);
|
||||
break;case 2816:0<=(e=N(this,f=T(this,a,6)))&&(a=-e,0<=Q(this,f,a)&&(this.u=this.b=this.i=a,this.g=a&e));break;case 2880:0<=(e=N(this,f=T(this,a,6)))&&(a=e+(this.u>>16&1),0<=Q(this,f,a)&&(this.u=this.b=this.i=a,this.g=a&(a^e)));break;case 2944:0<=(e=N(this,f=T(this,a,6)))&&(a=e-(this.u>>16&1),0<=Q(this,f,a)&&(this.u=this.b=this.i=a,this.g=(a^e)&e));break;case 3008:0<=(e=U(this,a))&&(this.b=this.i=e,this.u=this.g=0);break;case 3072:a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=(this.u&65536|e)>>1,0<=Q(this,
|
||||
f,a)&&(this.u=e<<16,this.b=this.i=a,this.g=a^this.u>>1)):(g=a&7,e=this.f[g],a=(this.u&65536|e)>>1,this.f[g]=a&65535,this.u=e<<16,this.b=this.i=a,this.g=a^this.u>>1);break;case 3136:a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=e<<1|this.u>>16&1,0<=Q(this,f,a)&&(this.u=this.b=this.i=a,this.g=a^e)):(g=a&7,e=this.f[g],a=e<<1|this.u>>16&1,this.f[g]=a&65535,this.u=this.b=this.i=a,this.g=a^e);break;case 3200:a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=e&32768|e>>1,0<=Q(this,f,a)&&(this.u=e<<16,this.b=this.i=a,this.g=
|
||||
this.b^this.u>>1)):(g=a&7,e=this.f[g],a=e&32768|e>>1,this.f[g]=a&65535,this.u=e<<16,this.b=this.i=a,this.g=this.b^this.u>>1);break;case 3264:a&56?0<=(e=N(this,f=T(this,a,6)))&&(a=e<<1,0<=Q(this,f,a)&&(this.u=this.b=this.i=a,this.g=a^e)):(g=a&7,e=this.f[g],a=e<<1,this.f[g]=a&65535,this.u=this.b=this.i=a,this.g=a^e);break;case 3328:h=this.f[7]+((a&63)<<1)&65535;0<=(c=M(this,h|65536))&&(this.f[7]=this.f[5],this.f[5]=c,this.f[6]=h+2&65535);break;case 3392:a&56?0<=(h=Fc(this,a,0))&&(61440!==(this.H&61440)&&
|
||||
(h&=65535),this.B=this.H>>12&3,0<=(c=M(this,h))&&(this.B=this.H>>14&3,0<=Cc(this,c)&&(this.b=this.i=c,this.g=0))):(g=a&7,c=6!==g||(this.H>>2&12288)===(this.H&12288)?this.f[g]:this.Aa[this.H>>12&3],0<=Cc(this,c)&&(this.b=this.i=c,this.g=0));break;case 3456:0<=(e=Ec(this))&&((this.K&57344||(this.L=22),a&56)?0<=(h=Fc(this,a,0))&&(h&=65535,this.B=this.H>>12&3,0<=(f=Dc(this,h,4))&&(this.B=this.H>>14&3,0<=Q(this,f,e)&&(this.b=this.i=e,this.g=0))):(g=a&7,6!==g||(this.H>>2&12288)===(this.H&12288)?this.f[g]=
|
||||
e:this.Aa[this.H>>12&3]=e,this.b=this.i=e,this.g=0));break;case 3520:0<=(f=T(this,a,4))&&(a=-(this.b>>15&1),0<=Q(this,f,a)&&(this.i=a,this.g=0));break;case 35328:a&56?0<=(f=T(this,a,5))&&0<=S(this,f,0)&&(this.b=this.u=this.g=this.i=0):(this.f[a&7]&=65280,this.b=this.u=this.g=this.i=0);break;case 35392:0<=(e=R(this,f=T(this,a,7)))&&(a=~e,0<=S(this,f,a)&&(this.b=this.i=a<<8,this.u=65536,this.g=0));break;case 35456:0<=(e=R(this,f=T(this,a,7)))&&(a=e+1,0<=S(this,f,a)&&(this.b=this.i=a<<8,this.g=(a&(a^
|
||||
e))<<8));break;case 35520:0<=(e=R(this,f=T(this,a,7)))&&(a=e-1,0<=S(this,f,a)&&(this.b=this.i=a<<8,this.g=((a^e)&e)<<8));break;case 35584:0<=(e=R(this,f=T(this,a,7)))&&(a=-e,0<=S(this,f,a)&&(this.u=this.b=this.i=a<<8,this.g=(a&e)<<8));break;case 35648:0<=(e=R(this,f=T(this,a,7)))&&(a=e+(this.u>>16&1),0<=S(this,f,a)&&(this.b=this.i=this.u=a<<8,this.g=(a&(a^e))<<8));break;case 35712:0<=(e=R(this,f=T(this,a,7)))&&(a=e-(this.u>>16&1),0<=S(this,f,a)&&(this.b=this.i=this.u=a<<8,this.g=((a^e)&e)<<8));break;
|
||||
case 35776:0<=(e=Gc(this,a))&&(this.b=this.i=e<<8,this.u=this.g=0);break;case 35840:0<=(e=R(this,f=T(this,a,7)))&&(a=((this.u&65536)>>8|e)>>1,0<=S(this,f,a)&&(this.u=e<<16,this.b=this.i=a<<8,this.g=this.b^this.u>>1));break;case 35904:0<=(e=R(this,f=T(this,a,7)))&&(a=e<<1|this.u>>16&1,0<=S(this,f,a)&&(this.u=this.b=this.i=a<<8,this.g=(a^e)<<8));break;case 35968:0<=(e=R(this,f=T(this,a,7)))&&(a=e&128|e>>1,0<=S(this,f,a)&&(this.u=e<<16,this.b=this.i=a<<8,this.g=this.b^this.u>>1));break;case 36032:0<=
|
||||
(e=R(this,f=T(this,a,7)))&&(a=e<<1,0<=S(this,f,a)&&(this.u=this.b=this.i=a<<8,this.g=(a^e)<<8));break;case 36160:a&56?0<=(h=Fc(this,a,0))&&(this.B=this.H>>12&3,0<=(c=M(this,h|65536))&&(this.B=this.H>>14&3,0<=Cc(this,c)&&(this.b=this.i=c,this.g=0))):(g=a&7,c=6!==g||(this.H>>2&12288)===(this.H&12288)?this.f[g]:this.Aa[this.H>>12&3],0<=Cc(this,c)&&(this.b=this.i=c,this.g=0));break;case 36224:0<=(e=Ec(this))&&((this.K&57344||(this.L=22),a&56)?0<=(h=Fc(this,a,0))&&(this.B=this.H>>12&3,0<=(f=Dc(this,h|
|
||||
65536,4))&&(this.B=this.H>>14&3,0<=Q(this,f,e)&&(this.b=this.i=e,this.g=0))):(g=a&7,6!==g||(this.H>>2&12288)===(this.H&12288)?this.f[g]=e:this.Aa[this.H>>12&3]=e,this.b=this.i=e,this.g=0));break;default:switch(a&65528){case 128:0<=(c=Ec(this))&&(g=a&7,this.f[7]=this.f[g],this.f[g]=c);break;case 152:this.H&49152||(this.H=this.H&63519|(a&7)<<5,this.V=1);break;case 160:case 168:a&1&&(this.u=0);a&2&&(this.g=0);a&4&&(this.i=1);a&8&&(this.b=0);break;case 176:case 184:a&1&&(this.u=65536);a&2&&(this.g=32768);
|
||||
a&4&&(this.i=0);a&8&&(this.b=32768);break;default:switch(a){case 0:49152&this.H?L(this,4):(this.ab=3,yc(this),console.log("HALT at "+this.f[7].toString(8)));break;case 1:g=0;if(0<(a=this.I.length))for(;0<a--;)g+=this.I[a].Ya,this.I[a].Ya=0;0===g&&0===this.ab&&(this.ab=2,yc(this));break;case 3:L(this,12);break;case 4:L(this,16);break;case 5:this.H&49152||Ac(this);break;case 2:case 6:f=this.f[6];0<=(h=M(this,f|65536))&&(f=f+2&65535,0<=(c=M(this,f|65536))&&(this.f[6]=f+2&65535,c&=63743,this.H&49152&&
|
||||
(c=c&63519|this.H&63712),this.f[7]=h,Bc(this,c),this.F&=-17,2===a&&(this.F|=this.H&16)));break;default:L(this,8)}}}}}}this.F&&(this.F&2?L(this,168):this.F&4?L(this,4):this.F&16&&L(this,12),this.F=0)}while(0<this.P)}return this.w.complete?this.T-this.P:void 0===this.w.complete?0:-1};Pa(function(){for(var a=D(document,"pdp11","cpu"),b=0;b<a.length;b++){var d=a[b],c=B(d),c=new zc(c);lb(c,d)}});
|
||||
function Jc(a){v.call(this,"ROM",a,Jc);this.g=null;this.B=a.addr;this.i=a.size;this.F=a.writable;this.u=a.alias;this.C=a.file;this.I=fa(this.C);if(this.C){a=this.C;var b=ga(this.I);"json"!=b&&"hex"!=b&&(a=ka()+"/api/v1/dump?file="+this.C+"&format=bytes&decimal=true");var d=this;va(a,null,!0,function(a,b,f){Kc(d,a,b,f)})}}y(Jc);Jc.prototype.xa=function(a,b,d,c){this.G=b;this.b=d;this.D=c;Lc(this)};
|
||||
Jc.prototype.sa=function(){if(this.qa){if(this.D){var a=this.D,b=this.id,d=this.B,c=this.i,e=this.qa,f=[],h;for(h in e){var g=e[h];"number"==typeof g&&(e[h]=g={o:g});var k=g.o,l=g.a;if(void 0!==k){var n=f,k=[k>>>0,h],q=sa(n,k,a.hb);0>q&&n.splice(-(q+1),0,k)}l&&(g.a=l.replace(/''/g,'"'))}a.F.push({Ib:b,A:d,Db:c,qa:e,fb:f})}delete this.qa}return!0};Jc.prototype.ra=function(){return!0};
|
||||
function Kc(a,b,d,c){if(c)a.da("Unable to load system ROM (error "+c+": "+b+")");else{$a(a.nb,b,d);if("["==d.charAt(0)||"{"==d.charAt(0))try{var e=eval("("+d+")"),f=e.bytes,h=e.data;if(f)a.g=f;else if(h)for(a.g=Array(4*h.length),c=d=0;d<h.length;d++)a.g[c++]=h[d]&255,a.g[c++]=h[d]>>8&255,a.g[c++]=h[d]>>16&255,a.g[c++]=h[d]>>24&255;else a.g=e;a.qa=e.symbols;if(!a.g.length){t("Empty ROM: "+b);return}if(1==a.g.length){t(a.g[0]);return}}catch(g){a.da("ROM data error: "+g.message);return}else for(b=d.replace(/\n/gm,
|
||||
" ").replace(/ +$/,"").split(" "),a.g=Array(b.length),e=0;e<b.length;e++)a.g[e]=ea(b[e]);Lc(a)}}
|
||||
function Lc(a){if(!pb(a))if(!a.C)E(a);else if(a.g&&a.G){a.i||(a.i=a.g.length);if(a.g.length!=a.i)qb(a,"ROM size ("+p(a.g.length,8,!0)+") does not match specified size ("+p(a.i,8,!0)+")");else{var b;b=a.B;if(wb(a.G,b,a.i,a.F?1:Qb)){var d;for(d=0;d<a.g.length;d++){var c=a.G,e=b+d;c.N[(e&c.i)>>>c.$].Ia(e&c.g,a.g[d]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.u?b.push(a.u):null!=a.u&&a.u.length&&(b=a.u);for(d=0;d<b.length;d++){for(var f=a,c=b[d],e=f.G,h=f.i,g=[],k=f.B>>>e.$;0<h&&k<e.N.length;)g.push(e.N[k++]),
|
||||
h-=e.ja;e=f.G;f=f.i;h=0;for(c>>>=e.$;0<f&&c<e.N.length;){k=g[h++];if(!k)break;e.N[c++]=k;f-=e.ja}}delete a.g}}E(a)}}Pa(function(){for(var a=D(document,"pdp11","rom"),b=0;b<a.length;b++){var d=a[b],c=B(d),c=new Jc(c);lb(c,d)}});function Mc(a){v.call(this,"RAM",a,Mc);this.u=a.addr;this.i=a.size;this.g=!1}y(Mc);m=Mc.prototype;m.xa=function(a,b,d,c){this.G=b;this.b=d;this.D=c;E(this)};m.sa=function(a,b){b||this.reset();return!0};m.ra=function(a){return a?this.save():!0};
|
||||
m.reset=function(){!this.g&&this.i&&wb(this.G,this.u,this.i,1)&&(this.g=!0);this.g||t("No RAM allocated")};m.save=function(){return null};m.restore=function(){return!0};Pa(function(){for(var a=D(document,"pdp11","ram"),b=0;b<a.length;b++){var d=a[b],c=B(d),c=new Mc(c);lb(c,d)}});function Nc(a){v.call(this,"Keyboard",a,Nc,65536);E(this)}y(Nc);Nc.prototype.fa=function(){return!1};Nc.prototype.xa=function(a,b,d,c){this.C=a;this.b=d;this.D=c;this.ga=null};
|
||||
Pa(function(){for(var a=D(document,"pdp11","keyboard"),b=0;b<a.length;b++){var d=a[b],c=B(d),c=new Nc(c);lb(c,d)}});function Oc(a){v.call(this,"Debugger",a,Oc);this.O=this.ga=this.I=0;this.R=!1;this.u=-1;this.i=[];this.T={}}y(Oc);var Pc={"||":0,"&&":1,"|":2,"^":3,"&":4,"!=":5,"==":5,">=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};
|
||||
function Qc(a,b,d,c){if(d)if(b){0>a.u&&a.i.length&&(a.u=0);if(0>a.u||b!=a.i[a.u])a.i.splice(0,0,b),a.u=0;a.u--}else a.R?b="end":b=a.i[a.u+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");d=0;var e=null;c=c||";";for(var f=0;f<=b.length;f++){var h=b.charAt(f);if('"'==h||"'"==h)e?h==e&&(e=null):e=h;else if(h==c&&!e||!h)a.push(oa(b.substring(d,f))),d=f+1}}return a}
|
||||
function Rc(a,b,d){for(d=d||-1;d--&&b.length;){var c=b.pop();if(2>a.length)return!1;var e=a.pop(),f=a.pop();switch(c){case "*":c=f*e;break;case "/":if(!e)return!1;c=f/e;break;case "%":if(!e)return!1;c=f%e;break;case "+":c=f+e;break;case "-":c=f-e;break;case "<<":c=f<<e;break;case ">>":c=f>>e;break;case ">>>":c=f>>>e;break;case "<":c=f<e?1:0;break;case "<=":c=f<=e?1:0;break;case ">":c=f>e?1:0;break;case ">=":c=f>=e?1:0;break;case "==":c=f==e?1:0;break;case "!=":c=f!=e?1:0;break;case "&":c=f&e;break;
|
||||
function A(a,b){b||(b=x);a.prototype=Ya(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}if(window){window.PCjs||(window.PCjs={});var Za=window.PCjs.Machines||(window.PCjs.Machines={}),z=window.PCjs.Components||(window.PCjs.Components=[])}else Za={},z=[];function $a(a,b,d){Za[a]&&b&&(Za[a][b]=d)}function ab(a){var b,d=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<z.length;b++){var c=z[b];a&&c.id.indexOf(a)||d.push(c)}return d}
|
||||
function bb(a,b){var d;if(void 0!==a){var c;b&&(b=0<(c=b.indexOf("."))?b.substr(0,c+1):"");for(c=0;c<z.length;c++)if(d)d==z[c]&&(d=null);else if(!(a!=z[c].type||b&&z[c].id.indexOf(b)))return z[c]}return null}function C(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(d){u(d.message+" ("+a+")")}return b}
|
||||
function lb(a,b){for(var d=E(b.parentNode,"pdp11-control"),c=0;c<d.length;c++)for(var e=d[c].childNodes,f=0;f<e.length;f++){var h=e[f];if(1===h.nodeType){var g=h.getAttribute("class");if(g)for(var k=g.split(" "),l=0;l<k.length;l++)switch(g=k[l],g){case "pdp11-binding":(g=C(h))&&g.binding&&a.ha(g.type,g.binding,h,g.value),l=k.length}}}}
|
||||
function E(a,b,d){d&&(b+="-"+d+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var c;d=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(c=a.length;b<c;b++)e.test(a[b].className)&&d.push(a[b]);return d}
|
||||
x.prototype={constructor:x,parent:null,toString:function(){return this.name?this.name:this.id||this.type},ha:function(a,b,d){switch(b){case "clear":return this.L[b]||(this.L[b]=d,d.onclick=function(a){return function(){a.L.print&&(a.L.print.value="")}}(this)),!0;case "print":return this.L[b]||(this.xa=this.L[b]=d,d.value="",this.g=function(a){return function(b,d){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==d?d+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(d),
|
||||
this.ea=function(a){this.g(a,this.La)}),!0;default:return!1}},log:function(){},g:function(){},status:function(a){this.g(this.La+": "+a)},ea:function(a,b,d){d=d||this.type;b||u((d?d+": ":"")+a)},ra:function(){return this.w.Z=!0},qa:function(a,b){b&&(this.w.Z=!1);return!0}};function mb(a,b){if(a.I){a===a.I?b|=0:b=b||a.$;var d=a.I.$&b;return!!b&&d===b||!!(d&a.I.zb)}return!1}
|
||||
function nb(a,b){if(a.w.Za)return a.w.Fa&&(a.w.Fa=!1),a.w.Za=!1;if(a.w.error)return a.g(a.toString()+" error"),!1;a.w.Fa=b;return a.w.Fa}function ob(a,b){a.w.Fa&&(b?a.w.Za=!0:void 0===b&&a.g(a.toString()+" busy"));return a.w.Fa}function F(a){if(!a.w.error&&(a.w.ready=!0,a.w.ready)){var b=a.Xa;a.Xa=null;b&&b()}}function pb(a,b){b&&(a.w.ready?b():a.Xa=b);return a.w.ready}function qb(a,b){a.w.error=!0;a.ea(b)}
|
||||
var rb="undefined"!==typeof ArrayBuffer,G={cpu:1,bus:64,mem:128,keyboard:65536,key:131072,disk:2097152,serial:8388608,speaker:33554432,computer:67108864,log:268435456,warn:536870912,buffer:1073741824,halt:-2147483648};function sb(a){x.call(this,"Panel",a,sb)}A(sb);m=sb.prototype;m.ha=function(a,b,d,c){return this.A&&this.A.ha(a,b,d,c)||this.f&&this.f.ha(a,b,d,c)||this.I&&this.I.ha(a,b,d,c)?!0:this.parent.ha.call(this,a,b,d,c)};m.ya=function(a,b,d,c){this.A=a;this.H=b;this.f=d;this.I=c};
|
||||
m.ra=function(a,b){b||tb();return!0};m.qa=function(){return!0};m.ia=function(){};function tb(){for(var a=!1,b=E(document,"pdp11","panel"),d=0;d<b.length;d++){var c=b[d],e=C(c),f;a:{f=e.id;if(void 0!==f)for(var h=void 0,h=0;h<z.length;h++)if(z[h].id===f){f=z[h];break a}f=null}f||(a=!0,f=new sb(e));lb(f,c);a&&F(f)}}Pa(tb);
|
||||
function ub(a,b,d){x.call(this,"Bus",a,ub);this.f=b;this.I=d;this.B=a.busWidth||16;this.G=Math.pow(2,this.B);this.A=this.G-1|0;this.ba=16>=this.B?10:20>=this.B?12:24>=this.B?14:15;this.la=1<<this.ba;this.J=this.la>>2;this.H=this.la-1;this.F=this.G/this.la|0;this.K=this.F-1;a=new H;vb(a,this.I);this.P=Array(this.F);for(b=0;b<this.F;b++)this.P[b]=a;F(this)}A(ub);ub.prototype.reset=function(){};ub.prototype.ra=function(a,b){b||this.reset();return!0};
|
||||
function wb(a,b,d,c){for(var e=b,f=d,h=e>>>a.ba;0<f&&h<a.P.length;){var g=a.P[h],k=h*a.la,l=a.la-(e-k);l>f&&(l=f);if(g&&g.size){if(g.type==c){if(e+f<=g.D)return g.Va+=g.D-e,g.D=e,!0;if(e>=g.D+g.Va){l=g.size-(e-k);l>f&&(l=f);g.Va=e-g.D+l;e=k+a.la;f-=l;h++;continue}}return xb(1,e,f)}e=new H(e,l,a.la,c);vb(e,a.I,g);a.P[h++]=e;e=k+a.la;f-=l}return 0>=f?(a.status(Math.floor(d/1024)+"Kb "+yb[c]+" at "+r(b)),!0):xb(2,b,d)}
|
||||
function zb(a,b){var d=b&a.H,c=(b&a.A)>>>a.ba;return d!=a.H?a.P[c].ub(d,b):a.P[c++].Ta(d,b)|a.P[c&a.K].Ta(0,b+1)<<8}function xb(a,b,d){u("Memory block error ("+a+": "+p(b)+","+p(d)+")");return!1}var Ab;if(rb){var Mb=new ArrayBuffer(2);(new DataView(Mb)).setUint16(0,256,!0);Ab=256===(new Uint16Array(Mb))[0]}else Ab=!1;var Nb=Ab;
|
||||
function H(a,b,d,c){this.id=Ob+=2;this.f=null;this.D=a;this.Va=b;this.size=d||0;this.type=c||Pb;this.J=c==Qb;vb(this);this.ua=this.Bb=!1;if(d)if(rb)this.F=new ArrayBuffer(d),this.G=new DataView(this.F,0,d),this.H=new Uint8Array(this.F,0,d),this.N=new Uint16Array(this.F,0,d>>1),this.f=new Int32Array(this.F,0,d>>2),Rb(this,Nb?Sb:Tb);else{this.f=Array(d>>2);for(a=0;a<this.f.length;a++)this.f[a]=0;Rb(this,Ub)}else Rb(this)}var Pb=0,Qb=2,yb=["NONE","RAM","ROM","VID","H/W"],Ob=0;
|
||||
H.prototype={constructor:H,parent:null,save:function(){var a,b;if(rb)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.G.getInt32(b<<2,!0);else a=this.f;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(rb)for(b=0;b<a.length;b++)this.G.setInt32(b<<2,a[b],!0);else this.f=a;return this.ua=!0}return!1},wa:function(a,b){b?0===this.A++&&Vb(this,Wb,!1):0===this.L++&&Xb(this,Wb,!1)},O:function(){this.I&&mb(this.I,129)&&this.I.message("attempt to read invalid block %"+p(this.D),!0);
|
||||
return 255},B:function(a,b){this.I&&mb(this.I,129)&&this.I.message("attempt to write "+r(b)+" to invalid block %"+p(this.D),!0)},X:function(a,b){return this.K(a++,b++)|this.K(a,b)<<8},sa:function(a,b,d){this.M(a++,b&255,d++);this.M(a,b>>8,d)},U:function(a){return this.f[a>>2]>>>((a&3)<<3)&255},da:function(a){var b=a>>2;a=(a&3)<<3;var d=this.f[b]>>a;return 24>a?d&65535:d&255|(this.f[b+1]&255)<<8},ka:function(a,b){var d=a>>2,c=(a&3)<<3;this.f[d]=this.f[d]&~(255<<c)|b<<c;this.ua=!0},ta:function(a,b){var d=
|
||||
a>>2,c=(a&3)<<3;24>c?this.f[d]=this.f[d]&~(65535<<c)|b<<c:(this.f[d]=this.f[d]&16777215|b<<24,d++,this.f[d]=this.f[d]&-256|b>>8);this.ua=!0},S:function(a,b){if(this.I&&null!=this.D){var d=this.I;Yb(d,this.D+a,1,d.R)&&d.ca(!0)}return this.Ta(a,b)},W:function(a,b){if(this.I&&null!=this.D){var d=this.I;Yb(d,this.D+a,2,d.R)&&d.ca(!0)}return this.ub(a,b)},ga:function(a,b,d){if(this.I&&null!=this.D){var c=this.I;Yb(c,this.D+a,1,c.J)&&c.ca(!0)}this.J?this.B(a,b,d):this.Ka(a,b,d)},na:function(a,b,d){if(this.I&&
|
||||
null!=this.D){var c=this.I;Yb(c,this.D+a,2,c.J)&&c.ca(!0)}this.J?this.B(a,b,d):this.wb(a,b,d)},R:function(a){return this.H[a]},T:function(a){return this.H[a]},V:function(a){return this.G.getUint16(a,!0)},Y:function(a){return a&1?this.H[a]|this.H[a+1]<<8:this.N[a>>1]},fa:function(a,b){this.H[a]=b;this.ua=!0},ja:function(a,b){this.H[a]=b;this.ua=!0},ma:function(a,b){this.G.setUint16(a,b,!0);this.ua=!0},La:function(a,b){a&1?(this.H[a]=b,this.H[a+1]=b>>8):this.N[a>>1]=b;this.ua=!0}};
|
||||
function vb(a,b,d){a.I=b;a.L=a.A=0;d&&((a.L=d.L)&&Xb(a,Wb,!1),(a.A=d.A)&&Vb(a,Wb,!1))}function Zb(a,b){b?0===--a.A&&(a.M=a.J?a.B:a.Ka):0===--a.L&&(a.K=a.Ta)}function Vb(a,b,d){d&&a.A||(a.M=!a.J&&b[2]||a.B);if(d||void 0===d)a.Ka=b[2]||a.B,a.wb=b[3]||a.sa}function Xb(a,b,d){d&&a.L||(a.K=b[0]||a.O);if(d||void 0===d)a.Ta=b[0]||a.O,a.ub=b[1]||a.X}function Rb(a,b){b||(b=$b);Xb(a,b,void 0);Vb(a,b,void 0)}
|
||||
var $b=[],Ub=[H.prototype.U,H.prototype.da,H.prototype.ka,H.prototype.ta],Wb=[H.prototype.S,H.prototype.W,H.prototype.ga,H.prototype.na];if(rb)var Tb=[H.prototype.R,H.prototype.V,H.prototype.fa,H.prototype.ma],Sb=[H.prototype.T,H.prototype.Y,H.prototype.ja,H.prototype.La];
|
||||
function ac(a,b){x.call(this,"CPU",a,ac,1);var d=a.multiplier||1;this.Na=a.cycles||b;this.Aa=d;this.ta=Math.round(this.Na/1E4)/100;this.za=this.ta*this.Aa;this.w.aa=!1;this.w.bb=!1;this.w.Ma=a.autoStart;this.w.hb=!1;this.w.Ga=!1;this.Qa=this.X=0;this.Ra=a.csStart;this.Ha=a.csInterval;this.Ia=a.csStop;this.ja=[];this.Db=this.Ca.bind(this);F(this)}A(ac);var bc=["power","reset"];m=ac.prototype;
|
||||
m.ya=function(a,b,d,c){this.A=a;this.H=b;this.I=c;for(b=0;b<bc.length;b++)(d=this.L[bc[b]])&&this.A.ha(null,bc[b],d);this.fa=null;a=cc(a,"autoStart");null!=a&&(this.w.Ma="true"==a?!0:"false"==a?!1:!!a);F(this)};m.reset=function(){};m.save=function(){return null};m.restore=function(){return!1};
|
||||
m.ra=function(a,b){if(!b){if(a&&this.restore){dc(this);if(!this.restore(a))return!1;ec(this)}else this.reset();if(this.I){var d=this.I;d.g("Type ? for help with PDP11 Debugger commands");d.ia();if(d.na){var c=d.na;d.na=null;fc(d,c)}}else this.g("No debugger detected")}I(this);return!0};m.qa=function(a){return a?this.save():!0};m.Ma=function(){return this.w.Ma||!this.I&&void 0===this.L.run?(this.Ca(!0),!0):!1};m.mb=function(){return 0};
|
||||
function ec(a){void 0===a.Ra&&(a.Ra=0);void 0===a.Ha&&(a.Ha=-1);void 0===a.Ia&&(a.Ia=-1);a.w.Ga=0<=a.Ra&&0<a.Ha;a.w.Ga&&(a.Qa=0,a.X=a.Ra-a.U)}function gc(a,b){if(a.w.Ga){var d=!1;a.Qa=a.Qa+a.mb()|0;a.X-=b;0>=a.X&&(a.X+=a.Ha,d=!0);0<=a.Ia&&a.Ia<=hc(a)&&(a.Ha=a.Ia=-1,ec(a),a.ca(),d=!0);d&&a.g(hc(a)+" cycles: checksum="+p(a.Qa))}}
|
||||
function ic(a,b,d,c){a.L[b]&&(void 0===d&&(qb(a,"Value for "+b+" is invalid"),a.ca()),d=!a.w.aa||a.w.hb?p(d,c):"--------".substr(0,c),a.L[b].textContent!=d&&(a.L[b].textContent=d))}
|
||||
m.ha=function(a,b,d){var c=this;a=!1;switch(b){case "power":case "reset":this.L[b]=d;a=!0;break;case "run":this.L[b]=d;d.onclick=function(){var a;if(a=c.A)if(a=c.A,a.w.Z)a=!0;else{var b=null,d,g=ab(a.id);for(d=0;d<g.length&&(b=g[d],b===a||b.w.ready);d++);if(d==g.length)for(d=0;d<g.length&&(b=g[d],b===a||b.w.Z);d++);d==g.length&&(b=a);u("The "+b.type+" component ("+b.id+") is not "+(b.w.ready?"powered yet":"ready yet"+(b.Xa?" (waiting for notification)":""))+".");a=!1}a&&(c.w.aa?c.ca():c.Ca())};a=
|
||||
!0;break;case "speed":this.L[b]=d;a=!0;break;case "setSpeed":this.L[b]=d,d.onclick=function(){jc(c,c.Aa<<1,!0)},d.textContent=this.za.toFixed(2)+"Mhz",a=!0}return a};function kc(a,b,d){a.U+=b;d&&(a.T=a.O=0)}function lc(a,b){var d=1;b&&1<a.Aa&&a.R&&(d=a.R/a.ta);a.qb=Math.round(1E3/30);a.na=Math.floor(a.Na/30*d);b||(a.Y=a.na);a.Oa=0}function hc(a){return a.U+a.N+a.T-a.O}function dc(a){a.R=0;a.rb=0;a.U=a.N=a.T=a.O=0;ec(a);jc(a,1)}
|
||||
function jc(a,b,d){var c=!1;if(void 0!==b){.8>a.R/a.za?b=1:c=!0;a.Aa=b;b=a.ta*a.Aa;if(a.za!=b){a.za=b;b=a.za.toFixed(2)+"Mhz";var e=a.L.setSpeed;e&&(e.textContent=b);a.g("target speed: "+b)}d&&a.A&&a.A.Ua()}kc(a,a.N);a.N=0;a.M=ua();a.S=0;lc(a);return c}function yc(a){a.T-=a.O;a.O=0}
|
||||
m.Ca=function(a){if(nb(this,!0)){if(!this.w.aa){jc(this);this.A&&this.A.start(this.M,hc(this));this.w.aa=!0;this.w.bb=!0;this.fa&&this.fa.start();var b=this.L.run;b&&(b.textContent="Halt");this.A&&(this.A.ia(!0),a&&this.A.Ua(!0))}this.Oa>=this.Na&&lc(this,!0);this.ga=0;this.ma=ua();this.S&&(a=this.ma-this.S,a>this.qb&&(this.M+=a,this.M>this.ma&&(this.M=this.ma)));try{do{for(var d=this.w.Ga?1:this.na,c=this.ja.length-1;0<=c;c--){var e=this.ja[c];0>e[0]||d>e[0]&&(d=e[0])}this.Ja(d);var f=this.T-this.O;
|
||||
a=f;for(var h=this.ja.length-1;0<=h;h--){var g=this.ja[h];0>g[0]||(g[0]-=a,0>=g[0]&&(g[0]=-1,g[1]()))}this.ga+=f;this.N+=f;kc(this,0,!0);gc(this,f);this.Y-=f;if(0>=this.Y){this.Y+=this.na;15<=++this.rb&&(this.A&&this.A.ia(),this.rb=0);break}}while(this.w.aa)}catch(k){this.ca();I(this);this.A&&this.A.stop(ua(),hc(this));nb(this,!1);qb(this,k.stack||k.message);return}d=setTimeout;c=this.Db;this.S=ua();e=this.qb;this.ga&&(e=Math.round(e*this.ga/this.na));e=e-(this.S-this.ma);if(f=this.S-this.M)this.R=
|
||||
Math.round(this.N/(10*f))/100,864E5<=f&&(this.U=0,jc(this));if(0>e||this.R<this.za)-1E3>e&&(this.M-=e),e=0;this.Oa+=this.ga;this.S+=e;d(c,e)}else I(this),this.A&&this.A.stop(ua(),hc(this))};m.Ja=function(){return 0};m.ca=function(a){ob(this,!0);yc(this);kc(this,this.N);this.N=0;if(this.w.aa){this.w.aa=!1;this.fa&&this.fa.stop();var b=this.L.run;b&&(b.textContent="Run")}this.w.complete=a};function I(a,b){a.A&&a.A.ia(b)}
|
||||
function zc(a){this.tb=+a.model||1170;ac.call(this,a,1E6);this.jb=0;this.C=65536;this.j=this.i=32768;this.u=65535;this.f=15;this.b=[0,0,0,0,0,0,0,0];this.Ya=[0,0,0,0,0,0];this.Ba=[0,0,0,0];this.memory=[];this.G=[];this.Pa=this.sb=0;this.V=2;this.W=255;this.F=0;this.da=-1;this.pb=this.Da=this.ob=this.B=this.sa=this.K=this.J=0;this.ka=[7,7,7,7];this.Ea=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[65535,65535,65535,
|
||||
65535,65535,65535,65535,65535,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];this.Fb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.w.complete=this.w.Ab=!1}A(zc,ac);m=zc.prototype;m.reset=function(){this.w.aa&&this.ca();Ac(this);dc(this);this.w.error=!1;this.parent.reset.call(this)};
|
||||
function Ac(a){a.W=255;a.G=[];a.sb=0;a.J=a.K=a.sa=a.ob=0;a.ka[0]=a.ka[1]=a.ka[3]=7;a.Da=0}m.mb=function(){return 0};m.save=function(){var a=new J(this);K(a,0,[]);K(a,1,[this.nb,this.U,this.Aa]);for(var b=this.H,d=0,c=[],e=0;e<b.F;e++){var f=b.P[e];if(f.ua||f.Bb){c[d++]=e;var h=d++;a:if(f=f.save()){for(var g=0,k=0,l=[];g<f.length;){for(var n=f[g],q=g+1;q<f.length&&f[q]===n;)q++;l[k++]=q-g;l[k++]=n;g=q}if(l.length<f.length){f=l;break a}}c[h]=f}}K(a,2,c);return a.data()};
|
||||
m.restore=function(a){var b=a[1];this.nb=b[0];this.U=b[1];jc(this,b[3]);a:{b=this.H;a=a[2];var d;for(d=0;d<a.length-1;d+=2){var c=a[d],e=a[d+1];if(e&&e.length<b.J){for(var f=0,h=Array(b.J),g=0;g<e.length-1;)for(var k=e[g++],l=e[g++];k--;)h[f++]=l;e=h}f=b.P[c];if(!f||!f.restore(e)){u("Unable to restore memory block "+c);b=!1;break a}}b=!0}return b};
|
||||
m.ha=function(a,b,d){var c=!1;switch(b){case "PC":case "PSW":case "NF":case "ZF":case "VF":case "CF":this.L[b]=d;this.jb++;c=!0;break;default:c=this.parent.ha.call(this,a,b,d)}return c};function Bc(a){return a.f&-16|a.i>>12&8|(a.u&65535?0:4)|(a.j&32768?2:0)|(a.C&65536?1:0)}
|
||||
m.ia=function(a){this.jb&&(a||!this.w.aa||this.w.hb)&&(a=Bc(this),ic(this,"PSW",a,4),ic(this,"NF",a&8?1:0,1),ic(this,"ZF",a&4?1:0,1),ic(this,"VF",a&2?1:0,1),ic(this,"CF",a&1?1:0,1));if(a=this.L.speed)a.textContent=this.w.aa&&this.R?this.R.toFixed(2)+"Mhz":"Stopped"};function Cc(a,b){a.i=b<<12;a.u=~b&4;a.j=b<<14;a.C=b<<16;if((b^a.f)&2048)for(var d=a.Ya.length;0<=--d;){var c=a.b[d];a.b[d]=a.Ya[d];a.Ya[d]=c}a.B=b>>14&3;d=a.f>>14&3;a.B!=d&&(a.Ba[d]=a.b[6],a.b[6]=a.Ba[a.B]);a.V=2;a.f=b}
|
||||
function M(a,b){var d,c,e=0;0>a.da?a.da=a.f=a.f&63728|a.i>>12&8|(a.u&65535?0:4)|(a.j&32768?2:0)|(a.C&65536?1:0):a.B||(b=4,e=1);a.J&57344||(a.K=63222);a.B=0;0<=(d=N(a,b|65536))&&0<=(c=N(a,b+2&65535|65536))&&(Cc(a,c&53247|a.da>>2&12288),e&&(a.b[6]=4),0<=Dc(a,a.da)&&0<=Dc(a,a.b[7])&&(a.b[7]=d));a.F=0;return a.da=-1}
|
||||
function Ec(a,b,d){var c,e,f,h=0;if(d&a.ob){c=b>>13&a.ka[a.B];e=a.Ea[a.B][c];f=(a.Ea[a.B][c+16]<<6)+(b&8191)&4194303;if(a.sa&16){if(3932160<=f&&4186112>f){f=f&262143;var g=f>>13&31;31>g?a.sa&32&&(f=a.Fb[g]+(f&8190)&4194302,3932160<=f&&4186112>f&&console.log("panic(898)")):f|=4186112}}else f&=262143,253952<=f&&(f|=4186112);if(3932160>f&&(3915776<=f||f&1&&!(d&1)))return M(a,4);switch(e&7){case 1:h=4096;case 2:e|=128;d&4&&(h=8192);break;case 4:h=4096;case 5:d&4&&(h=4096);case 6:e|=d&4?192:128;break;
|
||||
default:h=32768}32512!==(e&32520)&&(e&8?e&32512&&(b&8128)<(e>>2&8128)&&(h|=16384):(b&8128)>(e>>2&8128)&&(h|=16384));a.Ea[a.B][c]=e;if(4194170!==f||a.B)a.Da=a.B,a.pb=c;if(h){if(h&57344)return 0<=a.da&&(h|=128),a.J&57344||(a.J=a.J|h|a.Da<<5|a.pb<<1),M(a,168);a.J&61440||!(4191360>f||4194239<f)||(a.J|=4096,a.J&512&&(a.F|=2))}}else if(f=b&65535,57344<=f)f|=4186112;else if(f&1&&!(d&1))return M(a,4);return f}function O(a,b){return 4194304<=b?a.b[b-4194304]:3932160<=b?-1:0<=b?a.memory[b>>1]:b}
|
||||
function P(a,b,d){d&=65535;return 4194304<=b?a.b[b-4194304]=d:3932160<=b?-1:0<=b?a.memory[b>>1]=d:b}function S(a,b){var d;return 4194304<=b?a.b[b-4194304]&255:3932160<=b?-1:0<=b?(d=a.memory[b>>1],b&1&&(d=d>>8),d&255):b}function T(a,b,d){d&=255;return 4194304<=b?a.b[b-4194304]=a.b[b-4194304]&65280|d:3932160<=b?-1:0<=b?b&1?a.memory[b>>1]=d<<8|a.memory[b>>1]&255:a.memory[b>>1]=a.memory[b>>1]&65280|d:b}function N(a,b){return O(a,Ec(a,b,2))}
|
||||
function Fc(a){var b=N(a,a.b[6]|65536);0<=b&&(a.b[6]=a.b[6]+2&65535);return b}function Dc(a,b){var d,c;a.b[6]=c=a.b[6]-2&65535;a.J&57344||(a.K=a.K<<8|246);if(!a.B&&c<=a.W&&4<c){if(c<=a.W-32)return a.b[6]=4,M(a,4);a.F|=4}return 0<=(d=Ec(a,c|65536,4))?P(a,d,b):d}
|
||||
function Gc(a,b,d){var c,e,f=b&7;switch(b>>3&7){case 0:return M(a,4);case 1:if(6===f&&!a.B&&d&4&&(a.b[6]<=a.W||65534<=a.b[6])){if(a.b[6]<=a.W-32||65534<=a.b[6])return a.b[6]=4,M(a,4);a.F|=4}return 7===f?a.b[f]:a.b[f]|65536;case 2:e=2;c=a.b[f];7!==f&&(c|=65536,6>f&&d&1&&(e=1));break;case 3:e=2;c=a.b[f];7!==f&&(c|=65536);if(0>(c=N(a,c)))return c;c|=65536;break;case 4:e=-2;6>f&&d&1&&(e=-1);c=a.b[f]+e&65535;7!==f&&(c|=65536);break;case 5:e=-2;c=a.b[f]-2&65535;7!==f&&(c|=65536);if(0>(c=N(a,c)))return c;
|
||||
c|=65536;break;case 6:if(0>(c=N(a,a.b[7])))return c;a.b[7]=a.b[7]+2&65535;c=c+a.b[f]&65535;return c|65536;case 7:if(0>(c=N(a,a.b[7])))return c;a.b[7]=a.b[7]+2&65535;c=c+a.b[f]&65535;return 0>(c=N(a,c|65536))?c:c|65536}a.b[f]=a.b[f]+e&65535;a.J&57344||(a.K=a.K<<8|e<<3&248|f);if(6===f&&!a.B&&d&4&&0>=e&&(a.b[6]<=a.W||65534<=a.b[6])){if(a.b[6]<=a.W-32)return a.b[6]=4,M(a,4);a.F|=4}return c}function U(a,b,d){var c;return b&56?(0<=(c=Gc(a,b,d))&&(c=Ec(a,c,d)),c):4194304+(b&7)}
|
||||
function V(a,b){var d;b&56?0<=(d=U(a,b,2))&&(d=O(a,d)):d=a.b[b&7];return d}function Hc(a,b){var d;b&56?0<=(d=U(a,b,3))&&(d=S(a,d)):d=a.b[b&7]&255;return d}function W(a,b){return((b&128?b|65280:b&255)<<1)+a&65535}
|
||||
m.Ja=function(a){this.w.complete=!0;var b=this.w.Ab=this.I&&Ic(this.I),d=a?this.w.bb?0:1:-1;this.w.bb=!1;this.T=this.O=a;this.nb&256?(yc(this),a=!1):a=!0;if(a){do{if(b){if(Jc(this.I,this.b[7],d)){this.ca();break}d=1}var c,e,f,h,g;if(this.V)if(1===this.V)this.V=2;else{this.V=0;g=-1;c=this.sb&224;if(0<(a=this.G.length))for(;0<a--;){if(0<this.G[a].ab){this.G[a].ab--;this.V=2;break}if(this.G[a].fb){if(!this.G[a].fb()){this.G.splice(a,1);g--;continue}this.G[a].fb=null}this.G[a].Gb>c&&(c=this.G[a].Gb,g=
|
||||
a)}c>(this.f&224)&&(0>g?M(this,160):(M(this,this.G[g].Ib),this.G.splice(g,1)))}this.J&57344||(this.K=0);this.F=this.f&16;if(0<=(a=N(this,this.b[7])))switch(this.b[7]=this.b[7]+2&65535,a&61440){case 4096:0<=(c=V(this,a>>6))&&(a&56?0<=(f=U(this,a,4))&&0<=P(this,f,c)&&(this.i=this.u=c,this.j=0):(this.i=this.u=this.b[a&7]=c,this.j=0));break;case 8192:0<=(c=V(this,a>>6))&&0<=(e=V(this,a))&&(this.i=this.u=this.C=a=c-e,this.j=(c^e)&(c^a));break;case 12288:0<=(c=V(this,a>>6))&&0<=(e=V(this,a))&&(this.i=this.u=
|
||||
c&e,this.j=0);break;case 16384:0<=(c=V(this,a>>6))&&(a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=e&~c,0<=P(this,f,a)&&(this.i=this.u=a,this.j=0)):(this.i=this.u=a=this.b[a&7]&=~c,this.j=0));break;case 20480:0<=(c=V(this,a>>6))&&(a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=e|c,0<=P(this,f,a)&&(this.i=this.u=a,this.j=0)):(this.i=this.u=a=this.b[a&7]|=c,this.j=0));break;case 24576:0<=(c=V(this,a>>6))&&(a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=c+e,0<=P(this,f,a)&&(this.i=this.u=this.C=a,this.j=(c^a)&(e^a))):(g=a&7,
|
||||
e=this.b[g],this.b[g]=(a=c+e)&65535,this.i=this.u=this.C=a,this.j=(c^a)&(e^a)));break;case 36864:0<=(c=Hc(this,a>>6))&&(a&56?0<=(f=U(this,a,5))&&0<=T(this,f,c)&&(this.i=this.u=c<<8,this.j=0):(c&128&&(c|=65280),this.i=this.u=this.b[a&7]=c,this.j=0));break;case 40960:0<=(c=Hc(this,a>>6))&&0<=(e=Hc(this,a))&&(a=c-e,this.i=this.u=this.C=a<<8,this.j=((c^e)&(c^a))<<8);break;case 45056:0<=(c=Hc(this,a>>6))&&0<=(e=Hc(this,a))&&(this.i=this.u=(c&e)<<8,this.j=0);break;case 49152:0<=(c=Hc(this,a>>6))&&0<=(e=
|
||||
S(this,f=U(this,a,7)))&&(a=e&~c,0<=T(this,f,a)&&(this.i=this.u=a<<8,this.j=0));break;case 53248:0<=(c=Hc(this,a>>6))&&0<=(e=S(this,f=U(this,a,7)))&&(a=e|c,0<=T(this,f,a)&&(this.i=this.u=a<<8,this.j=0));break;case 57344:0<=(c=V(this,a>>6))&&(a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=e-c,0<=P(this,f,a)&&(this.i=this.u=this.C=a,this.j=(c^e)&(e^a))):(g=a&7,e=this.b[g],this.b[g]=(a=e-c)&65535,this.i=this.u=this.C=a,this.j=(c^e)&(e^a)));break;default:switch(a&65024){case 2048:0<=(h=Gc(this,a,0))&&(g=a>>6&7,
|
||||
0<=Dc(this,this.b[g])&&(this.b[g]=this.b[7],this.b[7]=h&65535));break;case 28672:0<=(c=V(this,a))&&(g=a>>6&7,c&32768&&(c|=-65536),e=this.b[g],e&32768&&(e|=-65536),a=~~(c*e),this.b[g]=a>>16&65535,this.b[g|1]=a&65535,this.i=a>>16,this.u=this.i|a,this.C=this.j=0,-32768>a||32767<a)&&(this.C=65536);break;case 29184:0<=(c=V(this,a))&&(c?(g=a>>6&7,e=this.b[g]<<16|this.b[g|1],this.C=this.j=0,c&32768&&(c|=-65536),a=~~(e/c),-32768<=a&&32767>=a?(this.b[g]=a&65535,this.b[g|1]=e-a*c&65535,this.u=a>>16|a,this.i=
|
||||
a>>16):(this.j=32768,this.u=a>>15|a,this.i=e>>16,-1===c&&65534===this.b[g]&&(this.b[g]=this.b[g|1]=1))):(this.u=this.i=0,this.j=32768,this.C=65536));break;case 29696:0<=(c=V(this,a))&&(g=a>>6&7,a=this.b[g],a&32768&&(a|=4294901760),this.C=this.j=0,c&=63,c&32?(c=64-c,16<c&&(c=16),this.C=a<<17-c,a=a>>c):c&&(16<c?(this.j=a,a=0):(this.C=a=a<<c,(e=a>>15&65535)&&65535!==e&&(this.j=32768))),this.b[g]=a&65535,this.i=this.u=a);break;case 30208:if(0<=(c=V(this,a))){g=a>>6&7;e=this.b[g]<<16|this.b[g|1];this.C=
|
||||
this.j=0;c&=63;if(c&32)c=64-c,32<c&&(c=32),a=e>>c-1,this.C=a<<16,a>>=1,e&2147483648&&(a|=4294967295<<32-c);else if(c){if(a=e<<c-1,this.C=a>>15,a<<=1,32<c&&(c=32),e>>=32-c)e|=4294967295<<c&4294967295,4294967295!==e&&(this.j=32768)}else a=e;this.b[g]=a>>16&65535;this.b[g|1]=a&65535;this.i=a>>16;this.u=a>>16|a}break;case 30720:a&56?0<=(e=O(this,f=U(this,a,6)))&&(e^=this.b[a>>6&7],0<=P(this,f,e)&&(this.i=this.u=e,this.j=0)):(this.i=this.u=e=this.b[a&7]^=this.b[a>>6&7],this.j=0);break;case 32256:g=a>>
|
||||
6&7;if(this.b[g]=this.b[g]-1&65535)this.b[7]=this.b[7]-((a&63)<<1)&65535;break;default:switch(a&65280){case 256:this.b[7]=W(this.b[7],a);break;case 512:this.u&65535&&(this.b[7]=W(this.b[7],a));break;case 768:this.u&65535||(this.b[7]=W(this.b[7],a));break;case 1024:(this.i&32768)===(this.j&32768)&&(this.b[7]=W(this.b[7],a));break;case 1280:(this.i&32768)!==(this.j&32768)&&(this.b[7]=W(this.b[7],a));break;case 1536:this.u&65535&&(this.i&32768)===(this.j&32768)&&(this.b[7]=W(this.b[7],a));break;case 1792:this.u&
|
||||
65535&&(this.i&32768)===(this.j&32768)||(this.b[7]=W(this.b[7],a));break;case 32768:this.i&32768||(this.b[7]=W(this.b[7],a));break;case 33280:!(this.C&65536)&&this.u&65535&&(this.b[7]=W(this.b[7],a));break;case 33024:this.i&32768&&(this.b[7]=W(this.b[7],a));break;case 33536:if(this.C&65536||!(this.u&65535))this.b[7]=W(this.b[7],a);break;case 33792:this.j&32768||(this.b[7]=W(this.b[7],a));break;case 34048:this.j&32768&&(this.b[7]=W(this.b[7],a));break;case 34304:this.C&65536||(this.b[7]=W(this.b[7],
|
||||
a));break;case 34560:this.C&65536&&(this.b[7]=W(this.b[7],a));break;case 34816:M(this,24);break;case 35072:M(this,28);break;default:switch(a&65472){case 64:0<=(h=Gc(this,a,0))&&(this.b[7]=h&65535);break;case 192:a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=e<<8|e>>8,0<=P(this,f,a)&&(this.i=this.u=e&65280,this.j=this.C=0)):(g=a&7,e=this.b[g],this.b[g]=(e<<8|e>>8)&65535,this.i=this.u=e&65280,this.j=this.C=0);break;case 2560:a&56?0<=(f=U(this,a,4))&&0<=P(this,f,0)&&(this.i=this.C=this.j=this.u=0):this.i=this.C=
|
||||
this.j=this.u=this.b[a&7]=0;break;case 2624:0<=(e=O(this,f=U(this,a,6)))&&(a=~e,0<=P(this,f,a)&&(this.i=this.u=a,this.C=65536,this.j=0));break;case 2688:a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=e+1,0<=P(this,f,a)&&(this.i=this.u=a,this.j=a&(a^e))):(g=a&7,e=this.b[g],a=e+1,this.b[g]=a&65535,this.i=this.u=a,this.j=a&(a^e));break;case 2752:a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=e-1,0<=P(this,f,a)&&(this.i=this.u=a,this.j=(a^e)&e)):(g=a&7,e=this.b[g],a=e-1,this.b[g]=a&65535,this.i=this.u=a,this.j=(a^e)&e);
|
||||
break;case 2816:0<=(e=O(this,f=U(this,a,6)))&&(a=-e,0<=P(this,f,a)&&(this.C=this.i=this.u=a,this.j=a&e));break;case 2880:0<=(e=O(this,f=U(this,a,6)))&&(a=e+(this.C>>16&1),0<=P(this,f,a)&&(this.C=this.i=this.u=a,this.j=a&(a^e)));break;case 2944:0<=(e=O(this,f=U(this,a,6)))&&(a=e-(this.C>>16&1),0<=P(this,f,a)&&(this.C=this.i=this.u=a,this.j=(a^e)&e));break;case 3008:0<=(e=V(this,a))&&(this.i=this.u=e,this.C=this.j=0);break;case 3072:a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=(this.C&65536|e)>>1,0<=P(this,
|
||||
f,a)&&(this.C=e<<16,this.i=this.u=a,this.j=a^this.C>>1)):(g=a&7,e=this.b[g],a=(this.C&65536|e)>>1,this.b[g]=a&65535,this.C=e<<16,this.i=this.u=a,this.j=a^this.C>>1);break;case 3136:a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=e<<1|this.C>>16&1,0<=P(this,f,a)&&(this.C=this.i=this.u=a,this.j=a^e)):(g=a&7,e=this.b[g],a=e<<1|this.C>>16&1,this.b[g]=a&65535,this.C=this.i=this.u=a,this.j=a^e);break;case 3200:a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=e&32768|e>>1,0<=P(this,f,a)&&(this.C=e<<16,this.i=this.u=a,this.j=
|
||||
this.i^this.C>>1)):(g=a&7,e=this.b[g],a=e&32768|e>>1,this.b[g]=a&65535,this.C=e<<16,this.i=this.u=a,this.j=this.i^this.C>>1);break;case 3264:a&56?0<=(e=O(this,f=U(this,a,6)))&&(a=e<<1,0<=P(this,f,a)&&(this.C=this.i=this.u=a,this.j=a^e)):(g=a&7,e=this.b[g],a=e<<1,this.b[g]=a&65535,this.C=this.i=this.u=a,this.j=a^e);break;case 3328:h=this.b[7]+((a&63)<<1)&65535;0<=(c=N(this,h|65536))&&(this.b[7]=this.b[5],this.b[5]=c,this.b[6]=h+2&65535);break;case 3392:a&56?0<=(h=Gc(this,a,0))&&(61440!==(this.f&61440)&&
|
||||
(h&=65535),this.B=this.f>>12&3,0<=(c=N(this,h))&&(this.B=this.f>>14&3,0<=Dc(this,c)&&(this.i=this.u=c,this.j=0))):(g=a&7,c=6!==g||(this.f>>2&12288)===(this.f&12288)?this.b[g]:this.Ba[this.f>>12&3],0<=Dc(this,c)&&(this.i=this.u=c,this.j=0));break;case 3456:0<=(e=Fc(this))&&((this.J&57344||(this.K=22),a&56)?0<=(h=Gc(this,a,0))&&(h&=65535,this.B=this.f>>12&3,0<=(f=Ec(this,h,4))&&(this.B=this.f>>14&3,0<=P(this,f,e)&&(this.i=this.u=e,this.j=0))):(g=a&7,6!==g||(this.f>>2&12288)===(this.f&12288)?this.b[g]=
|
||||
e:this.Ba[this.f>>12&3]=e,this.i=this.u=e,this.j=0));break;case 3520:0<=(f=U(this,a,4))&&(a=-(this.i>>15&1),0<=P(this,f,a)&&(this.u=a,this.j=0));break;case 35328:a&56?0<=(f=U(this,a,5))&&0<=T(this,f,0)&&(this.i=this.C=this.j=this.u=0):(this.b[a&7]&=65280,this.i=this.C=this.j=this.u=0);break;case 35392:0<=(e=S(this,f=U(this,a,7)))&&(a=~e,0<=T(this,f,a)&&(this.i=this.u=a<<8,this.C=65536,this.j=0));break;case 35456:0<=(e=S(this,f=U(this,a,7)))&&(a=e+1,0<=T(this,f,a)&&(this.i=this.u=a<<8,this.j=(a&(a^
|
||||
e))<<8));break;case 35520:0<=(e=S(this,f=U(this,a,7)))&&(a=e-1,0<=T(this,f,a)&&(this.i=this.u=a<<8,this.j=((a^e)&e)<<8));break;case 35584:0<=(e=S(this,f=U(this,a,7)))&&(a=-e,0<=T(this,f,a)&&(this.C=this.i=this.u=a<<8,this.j=(a&e)<<8));break;case 35648:0<=(e=S(this,f=U(this,a,7)))&&(a=e+(this.C>>16&1),0<=T(this,f,a)&&(this.i=this.u=this.C=a<<8,this.j=(a&(a^e))<<8));break;case 35712:0<=(e=S(this,f=U(this,a,7)))&&(a=e-(this.C>>16&1),0<=T(this,f,a)&&(this.i=this.u=this.C=a<<8,this.j=((a^e)&e)<<8));break;
|
||||
case 35776:0<=(e=Hc(this,a))&&(this.i=this.u=e<<8,this.C=this.j=0);break;case 35840:0<=(e=S(this,f=U(this,a,7)))&&(a=((this.C&65536)>>8|e)>>1,0<=T(this,f,a)&&(this.C=e<<16,this.i=this.u=a<<8,this.j=this.i^this.C>>1));break;case 35904:0<=(e=S(this,f=U(this,a,7)))&&(a=e<<1|this.C>>16&1,0<=T(this,f,a)&&(this.C=this.i=this.u=a<<8,this.j=(a^e)<<8));break;case 35968:0<=(e=S(this,f=U(this,a,7)))&&(a=e&128|e>>1,0<=T(this,f,a)&&(this.C=e<<16,this.i=this.u=a<<8,this.j=this.i^this.C>>1));break;case 36032:0<=
|
||||
(e=S(this,f=U(this,a,7)))&&(a=e<<1,0<=T(this,f,a)&&(this.C=this.i=this.u=a<<8,this.j=(a^e)<<8));break;case 36160:a&56?0<=(h=Gc(this,a,0))&&(this.B=this.f>>12&3,0<=(c=N(this,h|65536))&&(this.B=this.f>>14&3,0<=Dc(this,c)&&(this.i=this.u=c,this.j=0))):(g=a&7,c=6!==g||(this.f>>2&12288)===(this.f&12288)?this.b[g]:this.Ba[this.f>>12&3],0<=Dc(this,c)&&(this.i=this.u=c,this.j=0));break;case 36224:0<=(e=Fc(this))&&((this.J&57344||(this.K=22),a&56)?0<=(h=Gc(this,a,0))&&(this.B=this.f>>12&3,0<=(f=Ec(this,h|
|
||||
65536,4))&&(this.B=this.f>>14&3,0<=P(this,f,e)&&(this.i=this.u=e,this.j=0))):(g=a&7,6!==g||(this.f>>2&12288)===(this.f&12288)?this.b[g]=e:this.Ba[this.f>>12&3]=e,this.i=this.u=e,this.j=0));break;default:switch(a&65528){case 128:0<=(c=Fc(this))&&(g=a&7,this.b[7]=this.b[g],this.b[g]=c);break;case 152:this.f&49152||(this.f=this.f&63519|(a&7)<<5,this.V=1);break;case 160:case 168:a&1&&(this.C=0);a&2&&(this.j=0);a&4&&(this.u=1);a&8&&(this.i=0);break;case 176:case 184:a&1&&(this.C=65536);a&2&&(this.j=32768);
|
||||
a&4&&(this.u=0);a&8&&(this.i=32768);break;default:switch(a){case 0:49152&this.f?M(this,4):(this.Pa=3,yc(this),console.log("HALT at "+this.b[7].toString(8)));break;case 1:g=0;if(0<(a=this.G.length))for(;0<a--;)g+=this.G[a].ab,this.G[a].ab=0;0===g&&0===this.Pa&&(this.Pa=2,yc(this));break;case 3:M(this,12);break;case 4:M(this,16);break;case 5:this.f&49152||Ac(this);break;case 2:case 6:f=this.b[6];0<=(h=N(this,f|65536))&&(f=f+2&65535,0<=(c=N(this,f|65536))&&(this.b[6]=f+2&65535,c&=63743,this.f&49152&&
|
||||
(c=c&63519|this.f&63712),this.b[7]=h,Cc(this,c),this.F&=-17,2===a&&(this.F|=this.f&16)));break;default:M(this,8)}}}}}}this.F&&(this.F&2?M(this,168):this.F&4?M(this,4):this.F&16&&M(this,12),this.F=0)}while(0<this.O)}return this.w.complete?this.T-this.O:void 0===this.w.complete?0:-1};Pa(function(){for(var a=E(document,"pdp11","cpu"),b=0;b<a.length;b++){var d=a[b],c=C(d),c=new zc(c);lb(c,d)}});
|
||||
function Kc(a){x.call(this,"ROM",a,Kc);this.A=null;this.J=a.addr;this.B=a.size;this.K=a.writable;this.F=a.alias;this.G=a.file;this.M=ga(this.G);if(this.G){a=this.G;var b=ha(this.M);"json"!=b&&"hex"!=b&&(a=la()+"/api/v1/dump?file="+this.G+"&format=bytes&decimal=true");var d=this;wa(a,null,!0,function(a,b,f){Lc(d,a,b,f)})}}A(Kc);Kc.prototype.ya=function(a,b,d,c){this.H=b;this.f=d;this.I=c;Mc(this)};
|
||||
Kc.prototype.ra=function(){if(this.pa){if(this.I){var a=this.I,b=this.id,d=this.J,c=this.B,e=this.pa,f=[],h;for(h in e){var g=e[h];"number"==typeof g&&(e[h]=g={o:g});var k=g.o,l=g.a;if(void 0!==k){var n=f,k=[k>>>0,h],q=ta(n,k,a.gb);0>q&&n.splice(-(q+1),0,k)}l&&(g.a=l.replace(/''/g,'"'))}a.K.push({Hb:b,D:d,Cb:c,pa:e,eb:f})}delete this.pa}return!0};Kc.prototype.qa=function(){return!0};
|
||||
function Lc(a,b,d,c){if(c)a.ea("Unable to load system ROM (error "+c+": "+b+")");else{$a(a.lb,b,d);if("["==d.charAt(0)||"{"==d.charAt(0))try{var e=eval("("+d+")"),f=e.bytes,h=e.data;if(f)a.A=f;else if(h)for(a.A=Array(4*h.length),c=d=0;d<h.length;d++)a.A[c++]=h[d]&255,a.A[c++]=h[d]>>8&255,a.A[c++]=h[d]>>16&255,a.A[c++]=h[d]>>24&255;else a.A=e;a.pa=e.symbols;if(!a.A.length){u("Empty ROM: "+b);return}if(1==a.A.length){u(a.A[0]);return}}catch(g){a.ea("ROM data error: "+g.message);return}else for(b=d.replace(/\n/gm,
|
||||
" ").replace(/ +$/,"").split(" "),a.A=Array(b.length),e=0;e<b.length;e++)a.A[e]=fa(b[e]);Mc(a)}}
|
||||
function Mc(a){if(!pb(a))if(!a.G)F(a);else if(a.A&&a.H){a.B||(a.B=a.A.length);if(a.A.length!=a.B)qb(a,"ROM size ("+p(a.A.length,8,!0)+") does not match specified size ("+p(a.B,8,!0)+")");else{var b;b=a.J;if(wb(a.H,b,a.B,a.K?1:Qb)){var d;for(d=0;d<a.A.length;d++){var c=a.H,e=b+d;c.P[(e&c.A)>>>c.ba].Ka(e&c.H,a.A[d]&255,e)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.F?b.push(a.F):null!=a.F&&a.F.length&&(b=a.F);for(d=0;d<b.length;d++){for(var f=a,c=b[d],e=f.H,h=f.B,g=[],k=f.J>>>e.ba;0<h&&k<e.P.length;)g.push(e.P[k++]),
|
||||
h-=e.la;e=f.H;f=f.B;h=0;for(c>>>=e.ba;0<f&&c<e.P.length;){k=g[h++];if(!k)break;e.P[c++]=k;f-=e.la}}delete a.A}}F(a)}}Pa(function(){for(var a=E(document,"pdp11","rom"),b=0;b<a.length;b++){var d=a[b],c=C(d),c=new Kc(c);lb(c,d)}});function Nc(a){x.call(this,"RAM",a,Nc);this.F=a.addr;this.B=a.size;this.A=!1}A(Nc);m=Nc.prototype;m.ya=function(a,b,d,c){this.H=b;this.f=d;this.I=c;F(this)};m.ra=function(a,b){b||this.reset();return!0};m.qa=function(a){return a?this.save():!0};
|
||||
m.reset=function(){!this.A&&this.B&&wb(this.H,this.F,this.B,1)&&(this.A=!0);this.A||u("No RAM allocated")};m.save=function(){return null};m.restore=function(){return!0};Pa(function(){for(var a=E(document,"pdp11","ram"),b=0;b<a.length;b++){var d=a[b],c=C(d),c=new Nc(c);lb(c,d)}});function Oc(a){x.call(this,"Keyboard",a,Oc,65536);F(this)}A(Oc);Oc.prototype.ha=function(){return!1};Oc.prototype.ya=function(a,b,d,c){this.A=a;this.f=d;this.I=c;this.fa=null};
|
||||
Pa(function(){for(var a=E(document,"pdp11","keyboard"),b=0;b<a.length;b++){var d=a[b],c=C(d),c=new Oc(c);lb(c,d)}});function Pc(a){x.call(this,"Debugger",a,Pc);this.S=this.ka=this.M=0;this.U=!1;this.G=-1;this.F=[];this.W={}}A(Pc);var Qc={"||":0,"&&":1,"|":2,"^":3,"&":4,"!=":5,"==":5,">=":6,">":6,"<=":6,"<":6,">>>":7,">>":7,"<<":7,"-":8,"+":8,"%":9,"/":9,"*":9};
|
||||
function Rc(a,b,d,c){if(d)if(b){0>a.G&&a.F.length&&(a.G=0);if(0>a.G||b!=a.F[a.G])a.F.splice(0,0,b),a.G=0;a.G--}else a.U?b="end":b=a.F[a.G+1];a=[];if(b){b=b.toLowerCase().replace(/""/g,"'");d=0;var e=null;c=c||";";for(var f=0;f<=b.length;f++){var h=b.charAt(f);if('"'==h||"'"==h)e?h==e&&(e=null):e=h;else if(h==c&&!e||!h)a.push(pa(b.substring(d,f))),d=f+1}}return a}
|
||||
function Sc(a,b,d){for(d=d||-1;d--&&b.length;){var c=b.pop();if(2>a.length)return!1;var e=a.pop(),f=a.pop();switch(c){case "*":c=f*e;break;case "/":if(!e)return!1;c=f/e;break;case "%":if(!e)return!1;c=f%e;break;case "+":c=f+e;break;case "-":c=f-e;break;case "<<":c=f<<e;break;case ">>":c=f>>e;break;case ">>>":c=f>>>e;break;case "<":c=f<e?1:0;break;case "<=":c=f<=e?1:0;break;case ">":c=f>e?1:0;break;case ">=":c=f>=e?1:0;break;case "==":c=f==e?1:0;break;case "!=":c=f!=e?1:0;break;case "&":c=f&e;break;
|
||||
case "^":c=f^e;break;case "|":c=f|e;break;case "&&":c=f&&e?1:0;break;case "||":c=f||e?1:0;break;default:return!1}a.push(c|0)}return!0}
|
||||
function Sc(a,b,d){var c;if(b){b=Tc(a,b);for(var e=0,f=!1,h=b,g=[],k=[],l=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e<l.length;){var n=l[e++],q=n.length,n=oa(n);if(!n){f=!0;break}n=Uc(a,n,null,!1===d);if(void 0===n){f=!0;d=!1;break}g.push(n);if(e==l.length)break;var n=l[e++],u=n.length;k.length&&Pc[n]<Pc[k[k.length-1]]&&Rc(g,k,1);k.push(n);b=b.substr(q+u)}Rc(g,k)&&1==g.length||(f=!0);f?d&&a.j("error parsing '"+h+"' at character "+(h.length-b.length)):(c=g.pop(),d&&Vc(a,null,
|
||||
c))}return c}function Tc(a,b){for(var d;(d=b.match(/\{(.*?)}/))&&!(0<=d[1].indexOf("{"));){var c=Sc(a,d[1]);b=b.replace("{"+d[1]+"}",null!=c?p(c):"undefined")}for(;(d=b.match(/\[(.*?)]/))&&!(0<=d[1].indexOf("["));)b=b.replace("["+d[1]+"]","unimplemented");for(d=b;c=d.match(/\$([a-z]+)/i);){var e=null;switch(c[1].toLowerCase()){case "ops":e=a.O-a.ga}if(null==e)break;d=d.replace(c[0],e.toString())}return d}
|
||||
function Uc(a,b,d,c){var e;null!=b?(e=a.T[b],null==e&&(e=ea(b)),null!=e||c||a.j("invalid "+(d?d:"value")+": "+b)):c||a.j("missing "+(d||"value"));return e}
|
||||
function Vc(a,b,d){var c,e=!1;if(void 0!==d){var e=!0,f=d,h=0;c="";if(!h||4<h)h=4;for(var g=0;g<h;g++){c&&(c=","+c);var k=f&255,l=8,n="";l?32<l&&(l=32):l=32;if(null==k||isNaN(k))for(;0<l--;)n="?"+n;else for(;0<l--;)n=(k&1?"1":"0")+n,k>>=1;c=n+c;f>>=8}f=d;h=0;g="";h?11<h&&(h=11):h=f&-65536?11:6;if(null==f||isNaN(f))for(;0<h--;)g="?"+g;else for(;0<h--;)g=String.fromCharCode((f&7)+48)+g,f>>=3;c=p(d,0,!0)+" "+d+". "+("0o"+g)+" "+("0b"+c)}a.j((null!=b?b+": ":"")+c);return e}
|
||||
function Wc(a,b){if(b)return Vc(a,b,a.T[b]);var d=0;for(b in a.T)Vc(a,b,a.T[b]),d++;return 0<d}function Xc(a){Oc.call(this,a);this.L=W();this.na=W();this.P=W();this.F=[];this.g=this.M=this.B=[];Yc(this);this.ba=0;Zc(this);this.ia=[];$c(this,a.messages);this.la=a.commands;var b=this;window?void 0===window.pdp11&&(window.pdp11=function(a){return fc(b,a)}):void 0===global.pdp11&&(global.pdp11=function(a){return fc(b,a)})}y(Xc,Oc);
|
||||
var ad={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory","g [#]":"go [to #]",h:"halt","if":"eval expression","int [#]":"request interrupt",k:"stack trace",ln:"list nearest symbol(s)",m:"messages",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine",s:"set options","t [#]":"trace","u [#]":"unassemble",v:"print version","var":"assign variable"},bd="NONE ADC ADCB ADD ASL ASLB ASR ASRB BCC BCS BEQ BGE BGT BHI BIC BICB BIS BISB BIT BITB BLE BLOS BLT BMI BNE BPL BPT BR BVC BVS CCC CLC CLCN CLCV CLCVN CLCVZ CLCZ CLCZN CLN CLR CLRB CLV CLVN CLVZ CLVZN CLZ CLZN CMP CMPB COM COMB DEC DECB INC INCB HALT JMP JSR MARK MFPD MFPI MFPS MOV MOVB MTPD MTPI MTPS NEG NEGB NOP RESET ROL ROLB ROR RORB RTI RTS SBC SBCB SCC SEC SECN SECV SECVN SECVZ SECZ SECZN SEN SEV SEVN SEVZ SEVZN SEZ SEZN SUB SWAB SXT TST TSTB WAIT".split(" "),
|
||||
cd={61440:{4096:[62,4032,63],8192:[47,4032,63],12288:[18,4032,63],16384:[14,4032,63],20480:[16,4032,63],24576:[3,4032,63],36864:[63,4032,63],40960:[48,4032,63],45056:[19,4032,63],49152:[15,4032,63],53248:[17,4032,63],57344:[94,4032,63]},65024:{2048:[57,448,63]},65280:{256:[27,4096],512:[24,4096],768:[10,4096],1024:[11,4096],1280:[22,4096],1536:[12,4096],1792:[20,4096],32768:[25,4096],33024:[23,4096],33280:[13,4096],33536:[21,4096],33792:[28,4096],34048:[29,4096],34304:[8,4096],34560:[9,4096]},65472:{16:[56,
|
||||
63],192:[95,63],1152:[53,63],2560:[38,63],2624:[49,63],2752:[51,63],2816:[67,63],2880:[1,63],2944:[77,63],3008:[97,63],3072:[73,63],3136:[71,63],3200:[6,63],3264:[4,63],3328:[58,63],3392:[60,63],3456:[65,63],3520:[96,63],33920:[54,63],35328:[40,63],35392:[50,63],35520:[52,63],35584:[68,63],35648:[2,63],35712:[78,63],35776:[98,63],35840:[74,63],35904:[72,63],35968:[7,63],36032:[5,63],36096:[66,63],36160:[59,63],36224:[64,63],36288:[61,63]},65528:{128:[76,448]},65535:{0:[55],1:[99],2:[75],4:[26],5:[70],
|
||||
160:[69],161:[31],162:[41],163:[32],164:[45],165:[35],166:[43],167:[34],168:[37],169:[32],170:[42],171:[33],172:[46],173:[36],174:[44],175:[30],176:[69],177:[80],178:[88],179:[82],180:[92],181:[85],182:[90],183:[84],184:[87],185:[81],186:[89],187:[83],188:[93],189:[86],190:[91],191:[79]}};m=Xc.prototype;
|
||||
m.xa=function(a,b,d,c){this.G=b;this.b=d;this.C=a;(a=cc(a,"messages"))&&$c(this,a);this.Ca=cd;dd(this,function(a){a:{var b=c.G.N,d=a[0],g=a=0,k=b.length;if(d){a=X(Y(c,d));if(-1===a){c.j("invalid address: "+d);break a}g=a>>>c.G.$;k=1}c.j("blockid physical blockaddr used size type");c.j("-------- --------- ---------- ------ ------ ----");for(var d=-1,l=0;k--;){var n=b[g];n.type==d?l++||c.j("..."):(d=n.type,l=yb[d],n&&c.j(p(n.id)+" %"+p(g<<c.G.$)+" %%"+p(n.A)+" "+r(n.Sa)+" "+r(n.size)+
|
||||
" "+l),d!=Pb&&(d=-1),l=0);a+=c.G.ja;g++}}});E(this)};
|
||||
m.fa=function(a,b,d){var c=this;switch(b){case "debugInput":return this.Z=this.J[b]=d,d.onkeydown=function(a){var b;if(13==a.keyCode)b=d.value,d.value="",fc(c,b,!0);else if(27==a.keyCode)d.value=b="";else if(38==a.keyCode?(b=null,c.u<c.i.length-1&&(b=c.i[++c.u])):40==a.keyCode&&(0<c.u?b=c.i[--c.u]:(b="",c.u=-1)),null!=b){var h=b.length;d.value=b;d.setSelectionRange(h,h)}null!=b&&a.preventDefault&&a.preventDefault()},!0;case "debugEnter":return this.J[b]=d,Ja(d,function(){if(c.Z){var a=c.Z.value;c.Z.value=
|
||||
"";fc(c,a,!0);return!0}return!1}),!0;case "step":return this.J[b]=d,Ja(d,function(a){var b=!1;ob(c,!0)||(nb(c,!0),b=c.Ha(a?1:0),nb(c,!1));return b}),!0}return!1};m.Ra=function(){this.Z&&this.Z.focus()};function X(a){a=a&&a.A;null==a&&(a=-1);return a}m.Ta=function(a,b){var d=255,c=X(a);-1!==c&&(d=this.G,d=d.N[(c&d.i)>>>d.$].Qa(c&d.g,c),b&&ed(a,b));return d};m.ua=function(a,b){var d=65535,c=X(a);-1!==c&&(d=zb(this.G,c),b&&ed(a,b));return d};
|
||||
m.eb=function(a,b,d){var c=X(a);if(-1!==c){var e=this.G;e.N[(c&e.i)>>>e.$].Ia(c&e.g,b&255,c);d&&ed(a,d);H(this.b,!0)}};m.yb=function(a,b,d){var c=X(a);if(-1!==c){var e=this.G,f=c&e.g,h=(c&e.i)>>>e.$;f!=e.g?e.N[h].xb(f,b&65535,c):(e.N[h++].Ia(f,b&255,c),e.N[h&e.F].Ia(0,b>>8&255,c+1));d&&ed(a,d);H(this.b,!0)}};function W(a){return{A:a,ma:!1}}function fd(a){return[a.A,a.ma]}function gd(a){return{A:a[0],ma:a[1]}}
|
||||
function Y(a,b,d){var c;d=(d?a.L:a.na).A;if(void 0!==b){c=b=Tc(a,b);var e;if(c.match(/^[a-z_][a-z0-9_]*$/i))for(c=c.toUpperCase(),d=0;d<a.F.length;d++){var f=a.F[d].qa[c];if(void 0!==f){c=f.o;void 0!==c&&(e=W(c));break}}if(c=e)return c;d=Sc(a,b,void 0)}null!=d&&(c=W(d));return c}function hd(a,b,d){d&&(d=d.match(/(['"])(.*?)\1/))&&(b.zb=Qc(a,b.wb=d[2]))}function ed(a,b){null!=a.A&&(a.A+=b||1)}
|
||||
function $c(a,b){a.D=a;a.X=a.Ab=536870912;a.ca=null;a.ea=[];var d=Qc(a,b.replace("keys","key").replace("kbd","keyboard"),!1,"|");if(d.length)for(var c in F){var e;a:if(e=void 0,Array.prototype.indexOf)e=d.indexOf(c,e);else{e=e||0;0>e&&(e+=d.length);0>e&&(e=0);for(var f=d.length;e<f;e++)if(e in d&&d[e]===c)break a;e=-1}0<=e&&(a.X|=F[c],a.j(c+" messages enabled"))}}function dd(a,b){for(var d in F)if(64==F[d]){a.ia[d]=b;break}}
|
||||
m.message=function(a,b){b&&(a+=" at "+p(W(this.b.f[7]).A,4));if(this.X&1073741824)this.ea.push(a);else if(!this.ca||a!=this.ca)if(this.ca=a,this.X&-2147483648&&(this.aa(),a+=" (cpu halted)"),this.j(a),this.b){var d=this.b;yc(d);d.ca=0;H(d)}};
|
||||
function Zc(a){var b;if(Hc(a)){if(!a.K||!a.K.length){a.K=Array(1E3);for(b=0;b<a.K.length;b++)a.K[b]=W();a.V=0;a.j("instruction history buffer allocated")}if(!a.U||!a.U.length)for(a.U=Array(256),b=0;b<a.U.length;b++)a.U[b]=[b,0]}else a.K&&a.K.length&&a.j("instruction history buffer freed"),a.V=0,a.K=[],a.U=[]}m.Ba=function(a){if(!id(this))return!1;this.b.Ba(a);return!0};
|
||||
m.Ha=function(a,b,d){if(!id(this))return!1;this.I=0;a||Hc(this)&&Ic(this,this.b.f[7],0);try{var c=this.b.Ha(a);0<c&&(this.I+=c,kc(this.b,c,!0),gc(this.b,c),this.O++)}catch(e){"number"!=typeof e&&(this.I=0,qb(this.b,e.stack||e.message))}!1!==d&&H(this.b);this.ha(b||!1);return 0<this.I};m.aa=function(a){this.b&&this.b.aa(a)};m.ha=function(a){void 0===a&&(a=!0);this.L=W(this.b.f[7]);a&&1!=this.S?jd(this):kd(this)};
|
||||
function id(a){var b;if(b=a.b&&pb(a.b))b=a.b,b.w.W?b=!0:(b.j(b.toString()+" not powered"),b=!1);b&&!ob(a.b)?(a=a.b,a.w.error?(a.j(a.toString()+" error"),a=!0):a=!1,a=!a):a=!1;return a}m.sa=function(a,b){return!b&&(this.reset(!0),a&&this.restore&&!this.restore(a))?!1:!0};m.ra=function(a,b){b&&this.j(a?"suspending":"shutting down");return a?this.save():!0};m.reset=function(a){Zc(this);this.O=this.ga=0;this.ca=null;this.I=0;this.L=W(this.b.f[7]);this.w.Y=!1;ld(this);a||this.ha()};
|
||||
m.save=function(){var a=new I(this);J(a,0,fd(this.L));J(a,1,fd(this.P));J(a,2,[this.i,this.R,this.X]);J(a,3,this.F);return a.data()};m.restore=function(a){var b=0;void 0!==a[2]&&(this.L=gd(a[b++]),this.P=gd(a[b++]),this.i=a[b][0],"string"==typeof this.i&&(this.i=[this.i]),this.R=a[b][1],this.X|=a[b][2]);a[3]&&(this.F=a[3]);return!0};m.start=function(a,b){this.S||this.j("running");this.w.Y=!0;this.Ka=a;this.La=b};
|
||||
m.stop=function(a,b){if(this.w.Y){this.w.Y=!1;this.I=b-this.La;if(!this.S){var d="stopped";if(this.I){var c=a-this.Ka,e=0<c?Math.round(1E3*this.I/c):0,d=d+" (";Hc(this)&&(d+=this.O+" opcodes, ",this.ga-=this.O,this.O=0);d+=this.I+" cycles, "+c+" ms, "+e+" hz)"}else mb(this,-2147483648)&&(d+=" (use the 't' command to execute blocked faults)");this.j(d)}this.ha(!0);this.Ra();ld(this,this.b.f[7])}};function Hc(a){return 1<a.g.length||!!a.ba}
|
||||
function Ic(a,b,d){var c=a.b;if(0<d&&(a.ba&&!--a.ba||Yb(a,b,1,a.g)))return!0;0<=d&&a.U.length&&(a.O++,null!=zb(a.G,b)&&(b=a.K[a.V],b.A=c.f[7],b.ma=!1,++a.V==a.K.length&&(a.V=0)));return!1}function Yc(a){var b,d;a.g=["bp"];if(void 0!==a.M)for(b=1;b<a.M.length;b++){d=a.M[b];var c=a.G;Zb(c.N[X(d)>>>c.$],!1)}a.M=["br"];if(void 0!==a.B)for(b=1;b<a.B.length;b++)d=a.B[b],c=a.G,Zb(c.N[X(d)>>>c.$],!0);a.B=["bw"];a.oa=0}
|
||||
m.va=function(a,b,d){var c=!0;d||md(this,a,b,!1,!0);if(a!=this.g){var e=X(b);if(-1===e)this.j("invalid address: "+p(b.A,4)),c=!1;else{var f=this.G;f.N[e>>>f.$].va(e&f.g,a==this.B)}}c&&(a.push(b),d?b.ma=!0:(nd(this,a,a.length-1,"set"),Zc(this)));return c};function md(a,b,d,c,e){var f=!1;d=X(d);for(var h=1;h<b.length;h++){var g=b[h];if(d==X(g)&&(!c||g.ma)){f=!0;g.ma||e||nd(a,b,h,"cleared");b.splice(h,1);b!=a.g&&(c=a.G,Zb(c.N[d>>>c.$],b==a.B));g.ma||Zc(a);break}}return f}
|
||||
function od(a,b){for(var d=1;d<b.length;d++)nd(a,b,d);return b.length-1}function nd(a,b,d,c){d=b[d];a.j(b[0]+" "+p(d.A,4)+(c?" "+c:d.wb?' "'+d.wb+'"':""))}function ld(a,b){if(void 0!==b)Yb(a,b,1,a.g,!0),a.S=0;else for(var d=1;d<a.g.length;d++){var c=a.g[d];if(c.ma){if(!md(a,a.g,c,!0))break;d=0}}}
|
||||
function Yb(a,b,d,c,e){var f=!1;if(!a.oa++)for(var h=1;!f&&h<c.length;h++){var g=c[h];if(!e||g.ma)for(var k=X(g),l=0;l<d;l++)if(b+l==k){var n,f=!0;g.ma&&(md(a,c,g,!0),e=!0);if(n=g.zb){for(var f=!1,q=0;q<n.length;q++)if(!pd(a,n[q],!0)){if(n[q].indexOf("if")){f=!0;break}for(var u=q+1;u<n.length&&n[u].indexOf("else");u++)q++;if(u==n.length){f=!0;break}}a.b.w.Y||(f=!0)}if(f){e||nd(a,c,h,"hit");break}}}a.oa--;return f}
|
||||
function qd(a,b,d,c){var e=W(b.A),f=a.ua(b,2),h,g;for(g in a.Ca)if(h=a.Ca[g][f&g])break;h||(h=[0]);g="";for(var k=bd[h[0]],l=h.length-1,n=1;n<=l;n++){var q=h[n];if(void 0!==q){var u;u=a;var C=q,q=b,z="";if(C&4096)z=r(q.A+((f&255)<<24>>24)&65535);else{var za=f&C;C&4032&&(za>>=6,C>>=6);if(C&63){var C=void 0,w=za&7;switch(za&56){case 0:z="R"+w;break;case 1:z="@R"+w;break;case 2:7>w?z="(R"+w+")+":(C=u.ua(q,2),z="#"+r(C));break;case 3:7>w?z="@(R"+w+")+":(C=u.ua(q,2),z="@#"+r(C));break;case 4:z="-(R"+w+
|
||||
")";break;case 5:z="@-R("+w+")";break;case 6:C=u.ua(q,2);z=r(C)+(7>w?"(R"+w+")":"(PC)");break;case 7:C=u.ua(q,2),z="@"+r(C)+(7>w?"(R"+w+")":"(PC)")}}}u=z;if(!u||!u.length){g="INVALID";break}0<g.length&&(g+=",");g+=u||"???"}}f="";h=p(e.A,4)+" ";if(-1!==e.A&&-1!==b.A){do if(f+=p(a.Ta(e,1),2),null==e.A)break;while(e.A!=b.A)}h+=na(f,10);h+=na(k,7);g&&(h+=" "+g);d&&(h=na(h,40)+";"+d,h=a.b.w.Ea?h+("cycles="+hc(a.b).toString()+" cs="+p(a.b.Na)):h+(null!=c?"="+c.toString():""));return h}
|
||||
function rd(a,b){var d;switch(b){case "N":d=0;break;case "Z":d=a.b.ka&255?0:4;break;case "C":d=a.b.ka&256?1:0;break;default:d=0}return b.charAt(0)+(d?"1":"0")+" "}function Qd(a,b){var d="",c=a.b;8>b?d=(6>b?"R"+b:6==b?"SP":"PC")+("="+p(c.f[b],4)):13>b?d="A"+(b-8)+"="+p(c.bb[b-8],4):16<=b&&20>b?d="S"+(b-16)+"="+p(c.Aa[b-16],4):20==b&&(d="PS="+p(c.H&-14|0|(c.ka&255?0:4)|(c.ka&256?1:0),4));d&&(d+=" ");return d}m.hb=function(a,b){return a[0]>b[0]?1:a[0]<b[0]?-1:0};
|
||||
function Rd(a,b,d){var c=[],e=X(b)>>>0;for(b=0;b<a.F.length;b++){var f=a.F[b],h=f.A>>>0,g=f.Db;if(e>=h&&e<h+g){e=sa(f.fb,[e-h],a.hb);0<=e?Sd(a,b,e,c):d&&(e=~e,Sd(a,b,e-1,c),Sd(a,b,e,c));break}}return c}function Sd(a,b,d,c){var e={},f=a.F[b].fb,h=0,g=null;0<=d&&d<f.length&&(h=f[d][0],g=f[d][1]);g&&(e=a.F[b].qa[g],g="."==g.charAt(0)?null:e.l||g);c.push(g);c.push(h);c.push(e.a);c.push(e.c)}
|
||||
function Td(a,b){var d=b.match(/^\s*([A-Z_]?[A-Z0-9_]*)\s*(=?)\s*(.*)$/i);if(d){if(!d[1])return Wc(a)||a.j("no variables"),!0;if(!d[2])return Wc(a,d[1]);if(!d[3])return delete a.T[d[1]],!0;var c=Sc(a,d[3]);return void 0!==c?(a.T[d[1]]=c,!0):!1}a.j("invalid assignment:"+b);return!1}
|
||||
function Ud(a,b,d){var c=null;if(b=Y(a,b,!0)){var e=Rd(a,b,!0);if(e.length){var f,h;e[0]&&(h="",(f=b.A-e[1])&&(h=" + "+r(f)),f=e[0]+" ("+p(e[1],4)+")"+h,d&&a.j(f),c=f);4<e.length&&e[4]&&(h="",(f=e[5]-b.A)&&(h=" - "+r(f)),f=e[4]+" ("+p(e[5],4)+")"+h,d&&a.j(f),c||(c=f))}else d&&a.j("no symbols")}return c}
|
||||
function jd(a,b){var d;if(b&&"?"==b[1])a.j("register commands:"),a.j("\tr\tdump registers"),a.j("\trx [#]\tset flag or register x to [#]");else{var c=a.b;null==d&&(d=!0);if(null!=b&&1<b.length){var e=b[1],f=null,h=e.indexOf("=");if(0<h)f=e.substr(h+1),e=e.substr(0,h);else if(2<b.length)f=b[2];else{a.j("missing value for "+b[1]);return}var h=!1,g=Sc(a,f);if(void 0!==g)switch(h=!0,e.toUpperCase()){case "PC":c.f[7]=g;a.L=W(c.f[7]);break;case "CF":c.ka=g?c.ka|256:c.ka&255;break;case "ZF":c.ka=g?c.ka&
|
||||
-256:c.ka|255;break;case "SF":break;default:a.j("unknown register: "+e);return}if(!h){a.j("invalid value: "+f);return}H(c);a.j("updated registers:")}f="";for(e=0;6>e;e++)f+=Qd(a,e);f=f+"\n"+(Qd(a,6)+Qd(a,7));f+=rd(a,"T")+rd(a,"N")+rd(a,"Z")+rd(a,"V")+rd(a,"C");a.j(f);d&&(a.L=W(c.f[7]),kd(a,p(a.L.A,4)))}}function Vd(a,b){b=oa(b);var d=b.match(/^(['"])(.*?)\1$/);d?a.j(d[2]):Sc(a,b,!0)}
|
||||
function Wd(a,b,d){var c="t"!=b;d=Uc(a,d,null,!0)||1;var e=1==d?0:1;"tc"==b&&(e=d,d=1);Ia(d,function(){return nb(a,!0)&&a.Ha(e,c,!1)},function(){H(a.b);nb(a,!1)})}
|
||||
function kd(a,b,d,c){if(b=Y(a,b,!0)){void 0===c&&(c=1);var e=256;if(void 0!==d){c=Y(a,d,!0);if(!c||c.A<b.A)return;e=c.A-b.A;if(256<e){a.j("range too large");return}c=-1}d=0;for(var f;0<e&&c--;){f=ob(a,!1)||a.S?a.I:null;var h=null!=f?"cycles":null,g=Rd(a,b),k=b.A;if(g[0]&&c&&(!d&&c||0>g[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.j(l)}g[3]&&(h=g[3],f=null);f=qd(a,b,h,f);a.j(f);a.L=b;e-=b.A-k;d++}}}
|
||||
function pd(a,b,d){var c=!0;try{b.length&&"end"!=b?d||a.j(">> "+b):(a.R&&(a.j("ended assemble at "+p(a.P.A,4)),a.L=a.P,a.R=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.ca=null;if(pb(a)&&0<b.length){a.R&&(b="a "+p(a.P.A,4)+" "+b);var f=b.replace(/ +/g," ").split(" ");if(f&&f.length)for(var h=f[0],g=h.charAt(0),k=1;k<h.length;k++){var l=h.charAt(k);if("?"==g||"r"==g||"a">l||"z"<l){f[0]=h.substr(k);f.unshift(h.substr(0,k));break}}switch(f[0].charAt(0)){case "a":var n=Y(a,f[1],!0);if(n)if(a.P=
|
||||
n,void 0===f[2])a.j("begin assemble at "+p(n.A,4)),a.R=!0,H(a.b);else{var q;a.j("not supported yet");q=[];if(q.length){for(var u=0;u<q.length;u++)a.eb(n,q[u],1);a.j(qd(a,a.P))}}break;case "b":a:{var C=f[0],z=f[1],za=b;if("?"==z)a.j("breakpoint commands:"),a.j("\tbp [a]\tset exec breakpoint at addr [a]"),a.j("\tbr [a]\tset read breakpoint at addr [a]"),a.j("\tbw [a]\tset write breakpoint at addr [a]"),a.j("\tbc [a]\tclear breakpoint at addr [a]"),a.j("\tbl\tlist all breakpoints"),a.j("\tbn [n]\tbreak after [n] instruction(s)");
|
||||
else{var w=C.charAt(1);if("l"==w){var Aa=0,Aa=Aa+od(a,a.g),Aa=Aa+od(a,a.M);(Aa+=od(a,a.B))||a.j("no breakpoints")}else if("n"==w)a.ba=Uc(a,z),a.j("break after "+a.ba+" instruction(s)");else if(void 0===z)a.j("missing breakpoint address");else{var O=W();if("*"!=z&&(O=Y(a,z,!0),!O))break a;"c"==w?null==O.A?(Yc(a),a.j("all breakpoints cleared")):md(a,a.g,O)||md(a,a.M,O)||md(a,a.B,O)||a.j("breakpoint missing: "+p(O.A,4)):null!=O.A&&(hd(a,O,za),"p"==w?a.va(a.g,O):"r"==w?a.va(a.M,O):"w"==w?a.va(a.B,O):
|
||||
a.j("unknown breakpoint command: "+w))}}}break;case "c":a.wa&&(a.wa.value="");break;case "d":a:{var Ba,Ca=f[0],Z=f[1],pa=f[2],pe=f[3];if("?"==Z){var aa="";for(Ba in F)a.ia[Ba]&&(aa&&(aa+=","),aa+=Ba);aa+=",state,symbols";a.j("dump memory commands:");a.j("\tdb [a] [#] dump # bytes at address a");a.j("\tdw [a] [#] dump # words at address a");a.j("\tdd [a] [#] dump # dwords at address a");a.j("\tdh [#] [#] dump # instructions from history");aa.length&&a.j("dump extension commands:\n\t"+aa)}else if("state"==
|
||||
Z){var sd=Xd(a.C,!0);"console"==pa?console.log(sd):(a.wa&&(a.wa.value=""),a.j(sd))}else if("symbols"==Z)for(var mc=0;mc<a.F.length;mc++){var nc=a.F[mc],Da;for(Da in nc.qa)if("."!=Da.charAt(0)){var td=nc.qa[Da].o;if(void 0!==td){var ud=nc.qa[Da].l;ud&&(Da=ud);a.j(p(td,4)+" "+Da)}}}else{if("d"==Ca){for(Ba in F)if(f[1]==Ba){var vd=a.ia[Ba];vd?(f.shift(),f.shift(),vd(f)):a.j("no dump registered for "+Z);break a}Z||(Ca=a.Ma||"db")}else a.Ma=Ca;if("dh"==Ca){var wd=Z,xd=pa,yd="",zd=0,K=a.V,ba=a.K;if(ba.length){var P=
|
||||
+wd||a.pa,Ea=+xd||10;isNaN(P)?P=Ea:yd="more ";P>ba.length&&(a.j("note: only "+ba.length+" available"),P=ba.length);K-=P;0>K&&(null==ba[ba.length-1].A?(P=K+P,K=0):K+=ba.length);var oc=[];"call"==xd&&(Ea=1E5,oc=["CALL"]);for(void 0!==wd&&a.j(P+" instructions earlier:");0<Ea&&K!=a.V;){var Ad=ba[K++];if(null==Ad.A)break;var bb=W(Ad.A),qe=P--,Bd=qd(a,bb,"history",qe);(!oc.length||0<=Bd.indexOf(oc[0]))&&a.j(Bd);bb.Xa&&(K+=bb.Xa,Ea-=bb.Xa,P-=bb.Xa);K>=ba.length&&(K=0);a.pa=P;zd++;Ea--}}zd||(a.j("no "+yd+
|
||||
"history available"),a.pa=void 0)}else{var Bb=Y(a,Z);if(Bb){var Cb=0;pa&&("l"==pa.charAt(0)&&(pa=pa.substr(1)||pe),Cb=Uc(a,pa)>>>0,65536<Cb&&(Cb=65536));for(var qa="",Db="dd"==Ca?4:"dw"==Ca?2:1,Eb=Db*Cb||128,re=Eb+15>>4||1;re--&&0<Eb;){var Fb=0,pc=0,cb,db="",qc="",Z=p(Bb.A,4);for(cb=16;0<cb&&0<Eb;cb--){var Gb=a.Ta(Bb,1),Fb=Fb|Gb<<(pc++<<3);pc==Db&&(db+=p(Fb,2*Db),db+=1==Db?9==cb?"-":" ":" ",Fb=pc=0);qc+=32<=Gb&&128>Gb?String.fromCharCode(Gb):".";Eb--}qa&&(qa+="\n");qa+=Z+" "+db+(0==cb?" "+qc:"")}qa&&
|
||||
a.j(qa);a.na=Bb}}}}break;case "e":if("else"==f[0])break;var Hb=1,Cd=255,Dd=a.Ta,Ed=a.eb;"ew"==f[0]&&(Hb=2,Cd=65535,Dd=a.ua,Ed=a.yb);var Fd=Hb<<1,Gd=f[1];if(null==Gd)a.j("edit memory commands:"),a.j("\teb [a] [...] edit bytes at address a"),a.j("\tew [a] [...] edit words at address a");else{var Ib=Y(a,Gd);if(Ib)for(var Jb=2;Jb<f.length;Jb++){var eb=Sc(a,f[Jb]);if(void 0===eb){a.j("unrecognized value: "+f[Jb]);break}eb&~Cd&&a.j("warning: "+p(eb)+" exceeds "+Hb+"-byte value");var se=Dd.call(a,Ib);
|
||||
a.j("changing "+p(Ib.A,4)+" from "+p(se,Fd,!0)+" to "+p(eb,Fd,!0));Ed.call(a,Ib,eb,Hb)}}break;case "g":a:{var Hd=f[1],te=b;if(void 0!==Hd){var rc=Y(a,Hd,!0);if(!rc)break a;hd(a,rc,te);a.va(a.g,rc,!0)}a.Ba(!0)||d||a.j("cpu busy or unavailable, run command ignored")}break;case "h":a:{var sc;if(a.w.Y)sc="halting",a.aa();else{if(ob(a,!0))break a;sc="already halted"}d||a.j(sc)}break;case "i":if("if"==f[0]){var tc;var fb=b.substr(2),fb=oa(fb);Sc(a,fb)?(d||a.j("true: "+fb),tc=!0):(d||a.j("false: "+fb),tc=
|
||||
!1);tc||(c=!1)}break;case "k":var ue=f[0];if("?"==f[1])a.j("stack trace commands:"),a.j("\tk\tshow frame addresses"),a.j("\tks\tshow symbol information");else{var uc=0,Id=W(),gb=W(a.b.f[6]);for(a.j("stack trace for "+p(gb.A,4));10>uc;){for(var ra=null,ve=256;65536>gb.A>>>0;){Id.A=a.ua(gb,2);if(null==gb.A||!ve--)break;for(var we=a,Kb=Id,Jd=null,hb=Kb.A,Kd=hb,vc=1;6>=vc&&hb;vc++){if(2<vc){Kb.A=hb;var Lb=qd(we,Kb);if(0<=Lb.indexOf("CALL")){var Ld=Lb.indexOf(" ");if(hb+(Lb.indexOf(" ",Ld+1)-Ld-1)/2==
|
||||
Kd){Jd=Lb;break}}}hb--}Kb.A=Kd;if(ra=Jd)break}if(!ra||null==ra)break;var Md=null;if("ks"==ue){var Nd=ra.match(/[0-9A-F]+$/);Nd&&(Md=Ud(a,Nd[0]))}ra=na(ra,50)+" ;"+(Md||"stack="+p(gb.A,4));a.j(ra);uc++}uc||a.j("no return addresses found")}break;case "l":if("ln"==f[0]){Ud(a,f[1],!0);break}break;case "m":a:{var ca,da=null,A=f[1];"?"==A&&(A=void 0);if(void 0!==A){var ha=0;if("all"==A)ha=1878917119,A=null;else if("on"==A)da=!0,A=null;else if("off"==A)da=!1,A=null;else{"keys"==A&&(A="key");"kbd"==A&&(A=
|
||||
"keyboard");for(ca in F)if(A==ca){ha=F[ca];da=!!(a.X&ha);break}if(!ha){a.j("unknown message category: "+A);break a}}if(ha)if("on"==f[2])a.X|=ha,da=!0;else if("off"==f[2]&&(a.X&=~ha,da=!1,1073741824==ha)){for(var wc=0;wc<a.ea.length;wc++)a.j(a.ea[wc]);a.ea=[]}}var xe=0,ia="";for(ca in F)if(!A||A==ca){var ye=!!(a.X&F[ca]);if(null===da||da==ye)ia&&(ia+=","),++xe%10||(ia+="\n\t"),"key"==ca&&(ca="keys"),ia+=ca}void 0===A&&a.j("message commands:\n\tm [category] [on|off]\tturn categories on/off");a.j((null!==
|
||||
da?da?"messages on: ":"messages off: ":"message categories:\n\t")+(ia||"none"));Zc(a)}break;case "p":if("print"==f[0]){Vd(a,b.substr(5));break}var ze="pr"==f[0]?1:0;if(a.S)a.j("step in progress");else{var Od=W(a.b.f[7]);a.Ta(Od);a.S?(a.va(a.g,Od,!0),a.Ba()||(a.C&&a.C.Ra(),a.S=0)):Wd(a,ze?"tr":"t")}break;case "r":if("reset"==b){a.C&&a.C.reset();break}jd(a,f);break;case "s":a:switch(f[1]){case "cs":var ib;void 0!==f[3]&&(ib=+f[3]);switch(f[2]){case "int":a.b.Fa=ib;break;case "start":a.b.Oa=ib;break;
|
||||
case "stop":a.b.Ga=ib;break;default:a.j("unknown cs option");break a}void 0!==ib&&ec(a.b);a.j("checksums "+(a.b.w.Ea?"enabled":"disabled"));break;case "sp":void 0!==f[2]&&(jc(a.b,+f[2])||a.j("warning: using 1x multiplier, previous target not reached"));a.j("target speed: "+(a.b.ya.toFixed(2)+"Mhz")+" ("+a.b.za+"x)");break;case "?":a.j("debugger options:");a.j("\tcs int #\tset checksum cycle interval to #");a.j("\tcs start #\tset checksum cycle start count to #");a.j("\tcs stop #\tset checksum cycle stop count to #");
|
||||
a.j("\tsp #\t\tset speed multiplier to #");break;default:f[1]&&a.j("unknown option: "+f[1])}break;case "t":Wd(a,f[0],f[1]);break;case "u":kd(a,f[1],f[2],8);break;case "v":if("var"==f[0]){Td(a,b.substr(3))||(c=!1);break}a.j("PDP11js version 1.30.0 ("+a.b.rb+",RELEASE"+(rb?",TYPEDARRAYS":",LONGARRAYS")+")");a.j(window?window.navigator.userAgent:"");break;case "?":if(f[1]){Vd(a,b.substr(1));break}var jb="commands:",xc;for(xc in ad)jb+="\n"+na(xc,9)+ad[xc];Hc(a)||(jb+="\nnote: history disabled if no exec breakpoints");
|
||||
a.j(jb);break;default:a.j("unknown command: "+b),c=!1}}}catch(Pd){a.j("debugger error: "+(Pd.stack||Pd.message)),c=!1}return c}function fc(a,b,d){b=Qc(a,b,d);for(var c in b)if(!pd(a,b[c]))return!1;return!0}Pa(function(){for(var a=D(document,"pdp11","debugger"),b=0;b<a.length;b++){var d=a[b],c=B(d),c=new Xc(c);lb(c,d)}});
|
||||
function Yd(a,b,d){v.call(this,"Computer",a,Yd,67108864);this.w.W=!1;Zd(this,b);this.M=cc(this,"autoPower",a);this.u=0;this.T=a.busWidth||a.buswidth;this.g=$d;this.K=null;this.F=this.R=!1;this.U=cc(this,"url")||"";(Math.random()+.1).toString(36);this.i=ae(this);if(this.b=kb("CPU",this.id)){this.D=kb("Debugger",this.id);this.G=new ub({id:this.nb+".bus",busWidth:this.T},this.b,this.D);var c,e=ab(this.id);if((this.C=kb("Panel",this.id))&&this.C.wa)for(b=0;b<e.length;b++)c=e[b],c.da=this.C.da,c.j=this.C.j,
|
||||
c.wa=this.C.wa;this.j("PDP11js v1.30.0\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");this.j("Portions adapted from the PDP-11/70 Emulator v1.3 by Paul Nankervis <paulnank@hotmail.com>");for(b=0;b<e.length;b++)c=e[b],c.xa&&c.xa(this,this.G,this.b,this.D);b=null;c=a.resume;void 0!==c&&(1<c.length?b=this.I=c:this.g=parseInt(c,10));var f;if(a=cc(this,"state")||(f=!0,a.state))b=this.O=a,f||(this.F=!0,this.g=$d),this.g&&(this.L=
|
||||
new I(this,"1.30.0"),be(this.L)?b=null:delete this.L);!b&&this.g&&(b=ce(this))&&(this.F=!0);if(b){var h=this;va(b,null,!0,function(a,b,c){c?(h.I=null,h.F=!1,h.da("Unable to load machine state from server (error "+c+(b?": "+oa(b):"")+")")):(h.K=b,h.R=!0);E(h)})}else E(this);this.J.power||(this.M=!0);!d&&this.M&&de(this,this.Pa)}else t("Unable to find CPU component")}y(Yd);var $d=0;
|
||||
function Zd(a,b){if(!b){var d;if("object"==typeof resources&&(d=resources.parms))try{b=eval("("+d+")")}catch(c){t(c.message+" ("+d+")")}}a.S=b}function cc(a,b,d){var c=b.toLowerCase(),c=Ua[b]||Ua[c];void 0===c&&a.S&&(c=a.S[b]);void 0===c&&d&&(c=d[b]);void 0===c&&"object"==typeof resources&&resources[b]&&(c=b);return c}function de(a,b,d){for(var c=ab(a.id),e=0;e<=c.length;e++){var f=e<c.length?c[e]:a;if(!pb(f)){pb(f,function(){de(a,b,d)});return}}b.call(a,d)}
|
||||
function ee(a,b){var d=new I(a,"1.30.0","validate");if(be(d)&&fe(d)){var c=ge(d,"timestamp"),e=b?ge(b,"timestamp"):"unknown";c!=e&&(a.da("Machine state may be out-of-date\n("+c+" vs. "+e+")\nCheck your browser's local storage limits"),b||d.clear())}}m=Yd.prototype;
|
||||
m.Pa=function(a){void 0===a&&(a=this.g||(this.K?1:$d));if(!this.u){this.u++;var b=!1,d=!1;this.P=!1;var c=this.L||new I(this,"1.30.0");if(-1==a)b=!0;else if(a>$d){if(be(c,this.K)){this.B=new I(this,"1.30.0","failsafe");be(this.B)&&(he(this,c),a=2,ie(this.B));J(this.B,"timestamp",ua());je(this.B);var e=this.g&&!this.F;if(1==a||wa("Click OK to restore the previous PDP11js machine state, or CANCEL to reset the machine.")){if(d=fe(c)){var f=ge(c,"code"),h=ge(c,"data");f&&("ok"==f?be(c,h):("error"==f&&
|
||||
"no machine state"!=h?(this.da("Error: "+h),"unable to verify user"==h&&(Ga("user",""),this.i=null)):this.j(f+": "+h),ie(c),be(c)?(d=fe(c),e=!0):d=!1))}e&&ee(this,d?c:null)}else 2==a&&c.clear()}else ee(this);delete this.K;delete this.L}e=ab(this.id);for(f=0;f<e.length;f++)h=e[f],h!==this&&h!=this.b&&(d=ke(this,h,c,b,d));b=[c,a,d];-1!=a?de(this,this.jb,b):this.jb(b)}};
|
||||
function ke(a,b,d,c,e){if(!b.w.W){b.w.W=!0;if(b.sa){var f=null;e&&((f=ge(d,b.id))||(f=ge(d,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.sa(f,c)&&f&&(t("Unable to restore state for "+b.type),a.O&&!a.R?(d.clear(),a.g=$d,window&&window.location.reload()):a.P=!0,b.sa(null),e=!1)}if(!c&&b.mb)for(a=b.mb.split("|"),d=0;d<a.length;d++)b.status(a[d])}return e}
|
||||
m.jb=function(a){var b=a[0],d=0>a[1];a=a[2];this.V=!0;this.w.W=!0;var c=this.J.power;c&&(c.textContent="Shutdown");this.b&&(ke(this,this.b,b,d,a),this.b.Ja());this.P&&(he(this,b),b.clear());!d&&this.B&&(this.B.clear(),delete this.B);this.u=0};
|
||||
function he(a,b){if(wa("There may be a problem with your PDP11js machine.\n\nTo help us diagnose it, click OK to send this PDP11js machine state to http://www.pcjs.org.")){var d=a.i||"",c=b.toString(),e={app:"PDP11js",ver:"1.30.0"};e.url=a.U;e.user=d;e.type="bug";e.data=c;va("http://www.pcjs.org/api/v1/report",e,!0)}}
|
||||
function Xd(a,b,d){var c,e="none";if(a.u)return null;a.u--;var f=new I(a,"1.30.0"),h=new I(a,"1.30.0","validate"),g=ua();J(h,"timestamp",g);J(f,"timestamp",g);J(f,"version","1.30.0");J(f,"url",window?window.location.href:null);J(f,"browser",window?window.navigator.userAgent:"");a.b&&a.b.ra&&(d&&a.b.aa(),c=a.b.ra(b,d),"object"===typeof c&&J(f,a.b.id,c),d&&(a.b.w.W=!1,!1===c&&(e=null)));for(var g=ab(a.id),k=0;k<g.length;k++){var l=g[k];l.w.W&&(l.ra&&(c=l.ra(b,d),"object"===typeof c&&J(f,l.id,c)),d&&
|
||||
(l.w.W=!1,!1===c&&(e=null)))}e&&(d?(g=c=!1,b?(a.i&&le(a,a.i,f.toString()),je(h)&&je(f)||(e=null,c=g=!0)):a.g&&(c=!0,g=3==a.g),c&&f.clear(g)):e=f.toString());d&&(a.w.W=!1,b=a.J.power)&&(b.textContent="Power");a.u=0;return e}m.reset=function(){this.G&&this.G.reset&&(this.D&&mb(this,0)&&this.D.message("Resetting "+this.G.type,void 0),this.G.reset());for(var a=ab(this.id),b=0;b<a.length;b++){var d=a[b];d!==this&&d!==this.G&&d.reset&&(this.D&&mb(this,0)&&this.D.message("Resetting "+d.type,void 0),d.reset())}};
|
||||
function Tc(a,b,d){var c;if(b){b=Uc(a,b);for(var e=0,f=!1,h=b,g=[],k=[],l=b.split(/(\|\||&&|\||^|&|!=|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*)/);e<l.length;){var n=l[e++],q=n.length,n=pa(n);if(!n){f=!0;break}n=Vc(a,n,null,!1===d);if(void 0===n){f=!0;d=!1;break}g.push(n);if(e==l.length)break;var n=l[e++],v=n.length;k.length&&Qc[n]<Qc[k[k.length-1]]&&Sc(g,k,1);k.push(n);b=b.substr(q+v)}Sc(g,k)&&1==g.length||(f=!0);f?d&&a.g("error parsing '"+h+"' at character "+(h.length-b.length)):(c=g.pop(),d&&Wc(a,null,
|
||||
c))}return c}function Uc(a,b){for(var d;(d=b.match(/\{(.*?)}/))&&!(0<=d[1].indexOf("{"));){var c=Tc(a,d[1]);b=b.replace("{"+d[1]+"}",null!=c?p(c):"undefined")}for(;(d=b.match(/\[(.*?)]/))&&!(0<=d[1].indexOf("["));)b=b.replace("["+d[1]+"]","unimplemented");for(d=b;c=d.match(/\$([a-z]+)/i);){var e=null;switch(c[1].toLowerCase()){case "ops":e=a.S-a.ka}if(null==e)break;d=d.replace(c[0],e.toString())}return d}
|
||||
function Vc(a,b,d,c){var e;null!=b?(e=a.W[b],null==e&&(e=fa(b)),null!=e||c||a.g("invalid "+(d?d:"value")+": "+b)):c||a.g("missing "+(d||"value"));return e}
|
||||
function Wc(a,b,d){var c,e=!1;if(void 0!==d){var e=!0,f=d,h=0;c="";if(!h||4<h)h=4;for(var g=0;g<h;g++){c&&(c=","+c);var k=f&255,l=8,n="";l?32<l&&(l=32):l=32;if(null==k||isNaN(k))for(;0<l--;)n="?"+n;else for(;0<l--;)n=(k&1?"1":"0")+n,k>>=1;c=n+c;f>>=8}f=d;h=0;g="";h?11<h&&(h=11):h=f&-65536?11:6;if(null==f||isNaN(f))for(;0<h--;)g="?"+g;else for(;0<h--;)g=String.fromCharCode((f&7)+48)+g,f>>=3;c=p(d,0,!0)+" "+d+". "+("0o"+g)+" "+("0b"+c)}a.g((null!=b?b+": ":"")+c);return e}
|
||||
function Xc(a,b){if(b)return Wc(a,b,a.W[b]);var d=0;for(b in a.W)Wc(a,b,a.W[b]),d++;return 0<d}function Yc(a){Pc.call(this,a);this.O=X();this.sa=X();this.T=X();this.K=[];this.B=this.R=this.J=[];Zc(this);this.fa=0;$c(this);this.ma=[];ad(this,a.messages);this.na=a.commands;var b=this;window?void 0===window.pdp11&&(window.pdp11=function(a){return fc(b,a)}):void 0===global.pdp11&&(global.pdp11=function(a){return fc(b,a)})}A(Yc,Pc);
|
||||
var bd={"?":"help/print","a [#]":"assemble","b [#]":"breakpoint",c:"clear output","d [#]":"dump memory","e [#]":"edit memory","g [#]":"go [to #]",h:"halt","if":"eval expression","int [#]":"request interrupt",k:"stack trace",ln:"list nearest symbol(s)",m:"messages",p:"step over",print:"print expression",r:"dump/set registers",reset:"reset machine",s:"set options","t [#]":"trace","u [#]":"unassemble",v:"print version","var":"assign variable"},cd="NONE ADC ADCB ADD ASL ASLB ASR ASRB BCC BCS BEQ BGE BGT BHI BIC BICB BIS BISB BIT BITB BLE BLOS BLT BMI BNE BPL BPT BR BVC BVS CCC CLC CLCN CLCV CLCVN CLCVZ CLCZ CLCZN CLN CLR CLRB CLV CLVN CLVZ CLVZN CLZ CLZN CMP CMPB COM COMB DEC DECB INC INCB HALT JMP JSR MARK MFPD MFPI MFPS MOV MOVB MTPD MTPI MTPS NEG NEGB NOP RESET ROL ROLB ROR RORB RTI RTS SBC SBCB SCC SEC SECN SECV SECVN SECVZ SECZ SECZN SEN SEV SEVN SEVZ SEVZN SEZ SEZN SUB SWAB SXT TST TSTB WAIT MUL DIV ASH ASHC XOR SOB EMT TRAP SPL IOT RTT MFPT".split(" "),
|
||||
dd={61440:{4096:[62,4032,63],8192:[47,4032,63],12288:[18,4032,63],16384:[14,4032,63],20480:[16,4032,63],24576:[3,4032,63],36864:[63,4032,63],40960:[48,4032,63],45056:[19,4032,63],49152:[15,4032,63],53248:[17,4032,63],57344:[94,4032,63]},65024:{2048:[57,448,63],28672:[100,63,448],29184:[101,63,448],29696:[102,63,448],30208:[103,63,448],30720:[104,448,63],32256:[105,448,8192]},65280:{256:[27,4096],512:[24,4096],768:[10,4096],1024:[11,4096],1280:[22,4096],1536:[12,4096],1792:[20,4096],32768:[25,4096],
|
||||
33024:[23,4096],33280:[13,4096],33536:[21,4096],33792:[28,4096],34048:[29,4096],34304:[8,4096],34560:[9,4096],34816:[106],35072:[107]},65472:{64:[56,63],192:[95,63],2560:[38,63],2624:[49,63],2688:[53,63],2752:[51,63],2816:[67,63],2880:[1,63],2944:[77,63],3008:[97,63],3072:[73,63],3136:[71,63],3200:[6,63],3264:[4,63],3328:[58,24576],3392:[60,63],3456:[65,63],3520:[96,63],35328:[40,63],35392:[50,63],35456:[54,63],35520:[52,63],35584:[68,63],35648:[2,63],35712:[78,63],35776:[98,63],35840:[74,63],35904:[72,
|
||||
63],35968:[7,63],36032:[5,63],36096:[66,63],36160:[59,63],36224:[64,63],36288:[61,63]},65528:{128:[76,7],152:[108,12288]},65535:{0:[55],1:[99],2:[75],3:[26],4:[109],5:[70],6:[110],7:[111],160:[69],161:[31],162:[41],163:[32],164:[45],165:[35],166:[43],167:[34],168:[37],169:[32],170:[42],171:[33],172:[46],173:[36],174:[44],175:[30],176:[69],177:[80],178:[88],179:[82],180:[92],181:[85],182:[90],183:[84],184:[87],185:[81],186:[89],187:[83],188:[93],189:[86],190:[91],191:[79]}};m=Yc.prototype;
|
||||
m.ya=function(a,b,d,c){this.H=b;this.f=d;this.A=a;(a=cc(a,"messages"))&&ad(this,a);this.Ea=dd;ed(this,function(a){a:{var b=c.H.P,d=a[0],g=a=0,k=b.length;if(d){a=Y(Z(c,d));if(-1===a){c.g("invalid address: "+d);break a}g=a>>>c.H.ba;k=1}c.g("blockid physical blockaddr used size type");c.g("-------- --------- ---------- ------ ------ ----");for(var d=-1,l=0;k--;){var n=b[g];n.type==d?l++||c.g("..."):(d=n.type,l=yb[d],n&&c.g(p(n.id)+" %"+p(g<<c.H.ba)+" %%"+p(n.D)+" "+r(n.Va)+" "+r(n.size)+
|
||||
" "+l),d!=Pb&&(d=-1),l=0);a+=c.H.la;g++}}});F(this)};
|
||||
m.ha=function(a,b,d){var c=this;switch(b){case "debugInput":return this.da=this.L[b]=d,d.onkeydown=function(a){var b;if(13==a.keyCode)b=d.value,d.value="",fc(c,b,!0);else if(27==a.keyCode)d.value=b="";else if(38==a.keyCode?(b=null,c.G<c.F.length-1&&(b=c.F[++c.G])):40==a.keyCode&&(0<c.G?b=c.F[--c.G]:(b="",c.G=-1)),null!=b){var h=b.length;d.value=b;d.setSelectionRange(h,h)}null!=b&&a.preventDefault&&a.preventDefault()},!0;case "debugEnter":return this.L[b]=d,Ja(d,function(){if(c.da){var a=c.da.value;
|
||||
c.da.value="";fc(c,a,!0);return!0}return!1}),!0;case "step":return this.L[b]=d,Ja(d,function(a){var b=!1;ob(c,!0)||(nb(c,!0),b=c.Ja(a?1:0),nb(c,!1));return b}),!0}return!1};m.Ua=function(){this.da&&this.da.focus()};function Y(a){a=a&&a.D;null==a&&(a=-1);return a}m.Wa=function(a,b){var d=255,c=Y(a);-1!==c&&(d=this.H,d=d.P[(c&d.A)>>>d.ba].Ta(c&d.H,c),b&&fd(a,b));return d};m.va=function(a,b){var d=65535,c=Y(a);-1!==c&&(d=zb(this.H,c),b&&fd(a,b));return d};
|
||||
m.cb=function(a,b,d){var c=Y(a);if(-1!==c){var e=this.H;e.P[(c&e.A)>>>e.ba].Ka(c&e.H,b&255,c);d&&fd(a,d);I(this.f,!0)}};m.xb=function(a,b,d){var c=Y(a);if(-1!==c){var e=this.H,f=c&e.H,h=(c&e.A)>>>e.ba;f!=e.H?e.P[h].wb(f,b&65535,c):(e.P[h++].Ka(f,b&255,c),e.P[h&e.K].Ka(0,b>>8&255,c+1));d&&fd(a,d);I(this.f,!0)}};function X(a){return{D:a,oa:!1}}function gd(a){return[a.D,a.oa]}function hd(a){return{D:a[0],oa:a[1]}}
|
||||
function Z(a,b,d){var c;d=(d?a.O:a.sa).D;if(void 0!==b){c=b=Uc(a,b);var e;if(c.match(/^[a-z_][a-z0-9_]*$/i))for(c=c.toUpperCase(),d=0;d<a.K.length;d++){var f=a.K[d].pa[c];if(void 0!==f){c=f.o;void 0!==c&&(e=X(c));break}}if(c=e)return c;d=Tc(a,b,void 0)}null!=d&&(c=X(d));return c}function id(a,b,d){d&&(d=d.match(/(['"])(.*?)\1/))&&(b.yb=Rc(a,b.vb=d[2]))}function fd(a,b){null!=a.D&&(a.D+=b||1)}
|
||||
function ad(a,b){a.I=a;a.$=a.zb=536870912;a.ga=null;a.ja=[];var d=Rc(a,b.replace("keys","key").replace("kbd","keyboard"),!1,"|");if(d.length)for(var c in G){var e;a:if(e=void 0,Array.prototype.indexOf)e=d.indexOf(c,e);else{e=e||0;0>e&&(e+=d.length);0>e&&(e=0);for(var f=d.length;e<f;e++)if(e in d&&d[e]===c)break a;e=-1}0<=e&&(a.$|=G[c],a.g(c+" messages enabled"))}}function ed(a,b){for(var d in G)if(64==G[d]){a.ma[d]=b;break}}
|
||||
m.message=function(a,b){b&&(a+=" at "+p(X(this.f.b[7]).D,4));if(this.$&1073741824)this.ja.push(a);else if(!this.ga||a!=this.ga)if(this.ga=a,this.$&-2147483648&&(this.ca(),a+=" (cpu halted)"),this.g(a),this.f){var d=this.f;yc(d);d.Y=0;I(d)}};
|
||||
function $c(a){var b;if(Ic(a)){if(!a.N||!a.N.length){a.N=Array(1E3);for(b=0;b<a.N.length;b++)a.N[b]=X();a.Y=0;a.g("instruction history buffer allocated")}if(!a.X||!a.X.length)for(a.X=Array(256),b=0;b<a.X.length;b++)a.X[b]=[b,0]}else a.N&&a.N.length&&a.g("instruction history buffer freed"),a.Y=0,a.N=[],a.X=[]}m.Ca=function(a){if(!jd(this))return!1;this.f.Ca(a);return!0};
|
||||
m.Ja=function(a,b,d){if(!jd(this))return!1;this.M=0;a||Ic(this)&&Jc(this,this.f.b[7],0);try{var c=this.f.Ja(a);0<c&&(this.M+=c,kc(this.f,c,!0),gc(this.f,c),this.S++)}catch(e){"number"!=typeof e&&(this.M=0,qb(this.f,e.stack||e.message))}!1!==d&&I(this.f);this.ia(b||!1);return 0<this.M};m.ca=function(a){this.f&&this.f.ca(a)};m.ia=function(a){void 0===a&&(a=!0);this.O=X(this.f.b[7]);a&&1!=this.V?kd(this):ld(this)};
|
||||
function jd(a){var b;if(b=a.f&&pb(a.f))b=a.f,b.w.Z?b=!0:(b.g(b.toString()+" not powered"),b=!1);b&&!ob(a.f)?(a=a.f,a.w.error?(a.g(a.toString()+" error"),a=!0):a=!1,a=!a):a=!1;return a}m.ra=function(a,b){return!b&&(this.reset(!0),a&&this.restore&&!this.restore(a))?!1:!0};m.qa=function(a,b){b&&this.g(a?"suspending":"shutting down");return a?this.save():!0};m.reset=function(a){$c(this);this.S=this.ka=0;this.ga=null;this.M=0;this.O=X(this.f.b[7]);this.w.aa=!1;md(this);a||this.ia()};
|
||||
m.save=function(){var a=new J(this);K(a,0,gd(this.O));K(a,1,gd(this.T));K(a,2,[this.F,this.U,this.$]);K(a,3,this.K);return a.data()};m.restore=function(a){var b=0;void 0!==a[2]&&(this.O=hd(a[b++]),this.T=hd(a[b++]),this.F=a[b][0],"string"==typeof this.F&&(this.F=[this.F]),this.U=a[b][1],this.$|=a[b][2]);a[3]&&(this.K=a[3]);return!0};m.start=function(a,b){this.V||this.g("running");this.w.aa=!0;this.Na=a;this.Oa=b};
|
||||
m.stop=function(a,b){if(this.w.aa){this.w.aa=!1;this.M=b-this.Oa;if(!this.V){var d="stopped";if(this.M){var c=a-this.Na,e=0<c?Math.round(1E3*this.M/c):0,d=d+" (";Ic(this)&&(d+=this.S+" opcodes, ",this.ka-=this.S,this.S=0);d+=this.M+" cycles, "+c+" ms, "+e+" hz)"}else mb(this,-2147483648)&&(d+=" (use the 't' command to execute blocked faults)");this.g(d)}this.ia(!0);this.Ua();md(this,this.f.b[7])}};function Ic(a){return 1<a.B.length||!!a.fa}
|
||||
function Jc(a,b,d){var c=a.f;if(0<d&&(a.fa&&!--a.fa||Yb(a,b,1,a.B)))return!0;0<=d&&a.X.length&&(a.S++,null!=zb(a.H,b)&&(b=a.N[a.Y],b.D=c.b[7],b.oa=!1,++a.Y==a.N.length&&(a.Y=0)));return!1}function Zc(a){var b,d;a.B=["bp"];if(void 0!==a.R)for(b=1;b<a.R.length;b++){d=a.R[b];var c=a.H;Zb(c.P[Y(d)>>>c.ba],!1)}a.R=["br"];if(void 0!==a.J)for(b=1;b<a.J.length;b++)d=a.J[b],c=a.H,Zb(c.P[Y(d)>>>c.ba],!0);a.J=["bw"];a.ta=0}
|
||||
m.wa=function(a,b,d){var c=!0;d||nd(this,a,b,!1,!0);if(a!=this.B){var e=Y(b);if(-1===e)this.g("invalid address: "+p(b.D,4)),c=!1;else{var f=this.H;f.P[e>>>f.ba].wa(e&f.H,a==this.J)}}c&&(a.push(b),d?b.oa=!0:(od(this,a,a.length-1,"set"),$c(this)));return c};function nd(a,b,d,c,e){var f=!1;d=Y(d);for(var h=1;h<b.length;h++){var g=b[h];if(d==Y(g)&&(!c||g.oa)){f=!0;g.oa||e||od(a,b,h,"cleared");b.splice(h,1);b!=a.B&&(c=a.H,Zb(c.P[d>>>c.ba],b==a.J));g.oa||$c(a);break}}return f}
|
||||
function pd(a,b){for(var d=1;d<b.length;d++)od(a,b,d);return b.length-1}function od(a,b,d,c){d=b[d];a.g(b[0]+" "+p(d.D,4)+(c?" "+c:d.vb?' "'+d.vb+'"':""))}function md(a,b){if(void 0!==b)Yb(a,b,1,a.B,!0),a.V=0;else for(var d=1;d<a.B.length;d++){var c=a.B[d];if(c.oa){if(!nd(a,a.B,c,!0))break;d=0}}}
|
||||
function Yb(a,b,d,c,e){var f=!1;if(!a.ta++)for(var h=1;!f&&h<c.length;h++){var g=c[h];if(!e||g.oa)for(var k=Y(g),l=0;l<d;l++)if(b+l==k){var n,f=!0;g.oa&&(nd(a,c,g,!0),e=!0);if(n=g.yb){for(var f=!1,q=0;q<n.length;q++)if(!qd(a,n[q],!0)){if(n[q].indexOf("if")){f=!0;break}for(var v=q+1;v<n.length&&n[v].indexOf("else");v++)q++;if(v==n.length){f=!0;break}}a.f.w.aa||(f=!0)}if(f){e||od(a,c,h,"hit");break}}}a.ta--;return f}
|
||||
function rd(a,b,d,c){var e=X(b.D),f=a.va(b,2),h,g;for(g in a.Ea)if(h=a.Ea[g][f&g])break;h||(h=[0]);g="";for(var k=cd[h[0]],l=h.length-1,n=1;n<=l;n++){var q=h[n];if(void 0!==q){var v;v=a;var D=q,q=b,w="",t=void 0,t=void 0,t=D&61440;if(4096==t)t=(f&255)<<24>>24,t=q.D+t&65535,w=r(t);else if(8192==t)t=(f&63)<<1,t=q.D-t&65535,w=r(t);else if(12288==t)t=f&7,w=p(t,2,!0);else if(24576==t)t=f&63,w=p(t,2,!0);else if(t=f&D,D&4032&&(t>>=6,D>>=6),D&63){var D=void 0,y=t&7;switch(t&56){case 0:w="R"+y;break;case 1:w=
|
||||
"@R"+y;break;case 2:7>y?w="(R"+y+")+":(D=v.va(q,2),w="#"+r(D));break;case 3:7>y?w="@(R"+y+")+":(D=v.va(q,2),w="@#"+r(D));break;case 4:w="-(R"+y+")";break;case 5:w="@-R("+y+")";break;case 6:D=v.va(q,2);w=r(D)+(7>y?"(R"+y+")":"(PC)");break;case 7:D=v.va(q,2),w="@"+r(D)+(7>y?"(R"+y+")":"(PC)")}}v=w;if(!v||!v.length){g="INVALID";break}0<g.length&&(g+=",");g+=v||"???"}}f="";h=p(e.D,4)+": ";if(-1!==e.D&&-1!==b.D){do if(f+=p(a.Wa(e,1),2),null==e.D)break;while(e.D!=b.D)}h+=oa(f,10);h+=oa(k,7);g&&(h+=" "+
|
||||
g);d&&(h=oa(h,40)+";"+d,h=a.f.w.Ga?h+("cycles="+hc(a.f).toString()+" cs="+p(a.f.Qa)):h+(null!=c?"="+c.toString():""));return h}function sd(a,b){var d;switch(b){case "N":d=a.f.i>>12&8;break;case "Z":d=a.f.u&65535?0:4;break;case "V":d=a.f.j&32768?2:0;break;case "C":d=a.f.C&65536?1:0;break;default:d=0}return b.charAt(0)+(d?"1":"0")+" "}
|
||||
function Rd(a,b){var d="",c=a.f;8>b?d=(6>b?"R"+b:6==b?"SP":"PC")+("="+p(c.b[b],4)):13>b?d="A"+(b-8)+"="+p(c.Ya[b-8],4):16<=b&&20>b?d="S"+(b-16)+"="+p(c.Ba[b-16],4):20==b&&(d="PS="+p(Bc(c),4));d&&(d+=" ");return d}m.gb=function(a,b){return a[0]>b[0]?1:a[0]<b[0]?-1:0};function Sd(a,b,d){var c=[],e=Y(b)>>>0;for(b=0;b<a.K.length;b++){var f=a.K[b],h=f.D>>>0,g=f.Cb;if(e>=h&&e<h+g){e=ta(f.eb,[e-h],a.gb);0<=e?Td(a,b,e,c):d&&(e=~e,Td(a,b,e-1,c),Td(a,b,e,c));break}}return c}
|
||||
function Td(a,b,d,c){var e={},f=a.K[b].eb,h=0,g=null;0<=d&&d<f.length&&(h=f[d][0],g=f[d][1]);g&&(e=a.K[b].pa[g],g="."==g.charAt(0)?null:e.l||g);c.push(g);c.push(h);c.push(e.a);c.push(e.c)}function Ud(a,b){var d=b.match(/^\s*([A-Z_]?[A-Z0-9_]*)\s*(=?)\s*(.*)$/i);if(d){if(!d[1])return Xc(a)||a.g("no variables"),!0;if(!d[2])return Xc(a,d[1]);if(!d[3])return delete a.W[d[1]],!0;var c=Tc(a,d[3]);return void 0!==c?(a.W[d[1]]=c,!0):!1}a.g("invalid assignment:"+b);return!1}
|
||||
function Vd(a,b,d){var c=null;if(b=Z(a,b,!0)){var e=Sd(a,b,!0);if(e.length){var f,h;e[0]&&(h="",(f=b.D-e[1])&&(h=" + "+r(f)),f=e[0]+" ("+p(e[1],4)+")"+h,d&&a.g(f),c=f);4<e.length&&e[4]&&(h="",(f=e[5]-b.D)&&(h=" - "+r(f)),f=e[4]+" ("+p(e[5],4)+")"+h,d&&a.g(f),c||(c=f))}else d&&a.g("no symbols")}return c}
|
||||
function kd(a,b){var d;if(b&&"?"==b[1])a.g("register commands:"),a.g("\tr\tdump registers"),a.g("\trx [#]\tset flag or register x to [#]");else{var c=a.f;null==d&&(d=!0);if(null!=b&&1<b.length){var e=b[1],f=null,h=e.indexOf("=");if(0<h)f=e.substr(h+1),e=e.substr(0,h);else if(2<b.length)f=b[2];else{a.g("missing value for "+b[1]);return}var h=!1,g=Tc(a,f);if(void 0!==g)switch(h=!0,e.toUpperCase()){case "PC":c.b[7]=g;a.O=X(c.b[7]);break;case "NF":break;case "ZF":break;case "VF":break;case "CF":break;
|
||||
default:a.g("unknown register: "+e);return}if(!h){a.g("invalid value: "+f);return}I(c);a.g("updated registers:")}f="";for(e=0;6>e;e++)f+=Rd(a,e);f=f+"\n"+(Rd(a,6)+Rd(a,7));f+=sd(a,"T")+sd(a,"N")+sd(a,"Z")+sd(a,"V")+sd(a,"C");a.g(f);d&&(a.O=X(c.b[7]),ld(a,p(a.O.D,4)))}}function Wd(a,b){b=pa(b);var d=b.match(/^(['"])(.*?)\1$/);d?a.g(d[2]):Tc(a,b,!0)}
|
||||
function Xd(a,b,d){var c="t"!=b;d=Vc(a,d,null,!0)||1;var e=1==d?0:1;"tc"==b&&(e=d,d=1);Ia(d,function(){return nb(a,!0)&&a.Ja(e,c,!1)},function(){I(a.f);nb(a,!1)})}
|
||||
function ld(a,b,d,c){if(b=Z(a,b,!0)){void 0===c&&(c=1);var e=256;if(void 0!==d){c=Z(a,d,!0);if(!c||c.D<b.D)return;e=c.D-b.D;if(256<e){a.g("range too large");return}c=-1}d=0;for(var f;0<e&&c--;){f=ob(a,!1)||a.V?a.M:null;var h=null!=f?"cycles":null,g=Sd(a,b),k=b.D;if(g[0]&&c&&(!d&&c||0>g[0].indexOf("+"))){var l=g[0]+":";g[2]&&(l+=" "+g[2]);a.g(l)}g[3]&&(h=g[3],f=null);f=rd(a,b,h,f);a.g(f);a.O=b;e-=b.D-k;d++}}}
|
||||
function qd(a,b,d){var c=!0;try{b.length&&"end"!=b?d||a.g(">> "+b):(a.U&&(a.g("ended assemble at "+p(a.T.D,4)),a.O=a.T,a.U=!1),b="");var e=b.charAt(0);if('"'==e||"'"==e)return!0;a.ga=null;if(pb(a)&&0<b.length){a.U&&(b="a "+p(a.T.D,4)+" "+b);var f=b.replace(/ +/g," ").split(" ");if(f&&f.length)for(var h=f[0],g=h.charAt(0),k=1;k<h.length;k++){var l=h.charAt(k);if("?"==g||"r"==g||"a">l||"z"<l){f[0]=h.substr(k);f.unshift(h.substr(0,k));break}}switch(f[0].charAt(0)){case "a":var n=Z(a,f[1],!0);if(n)if(a.T=
|
||||
n,void 0===f[2])a.g("begin assemble at "+p(n.D,4)),a.U=!0,I(a.f);else{var q;a.g("not supported yet");q=[];if(q.length){for(var v=0;v<q.length;v++)a.cb(n,q[v],1);a.g(rd(a,a.T))}}break;case "b":a:{var D=f[0],w=f[1],t=b;if("?"==w)a.g("breakpoint commands:"),a.g("\tbp [a]\tset exec breakpoint at addr [a]"),a.g("\tbr [a]\tset read breakpoint at addr [a]"),a.g("\tbw [a]\tset write breakpoint at addr [a]"),a.g("\tbc [a]\tclear breakpoint at addr [a]"),a.g("\tbl\tlist all breakpoints"),a.g("\tbn [n]\tbreak after [n] instruction(s)");
|
||||
else{var y=D.charAt(1);if("l"==y){var Aa=0,Aa=Aa+pd(a,a.B),Aa=Aa+pd(a,a.R);(Aa+=pd(a,a.J))||a.g("no breakpoints")}else if("n"==y)a.fa=Vc(a,w),a.g("break after "+a.fa+" instruction(s)");else if(void 0===w)a.g("missing breakpoint address");else{var Q=X();if("*"!=w&&(Q=Z(a,w,!0),!Q))break a;"c"==y?null==Q.D?(Zc(a),a.g("all breakpoints cleared")):nd(a,a.B,Q)||nd(a,a.R,Q)||nd(a,a.J,Q)||a.g("breakpoint missing: "+p(Q.D,4)):null!=Q.D&&(id(a,Q,t),"p"==y?a.wa(a.B,Q):"r"==y?a.wa(a.R,Q):"w"==y?a.wa(a.J,Q):a.g("unknown breakpoint command: "+
|
||||
y))}}}break;case "c":a.xa&&(a.xa.value="");break;case "d":a:{var Ba,Ca=f[0],aa=f[1],qa=f[2],qe=f[3];if("?"==aa){var ba="";for(Ba in G)a.ma[Ba]&&(ba&&(ba+=","),ba+=Ba);ba+=",state,symbols";a.g("dump memory commands:");a.g("\tdb [a] [#] dump # bytes at address a");a.g("\tdw [a] [#] dump # words at address a");a.g("\tdd [a] [#] dump # dwords at address a");a.g("\tdh [#] [#] dump # instructions from history");ba.length&&a.g("dump extension commands:\n\t"+ba)}else if("state"==aa){var td=Yd(a.A,
|
||||
!0);"console"==qa?console.log(td):(a.xa&&(a.xa.value=""),a.g(td))}else if("symbols"==aa)for(var mc=0;mc<a.K.length;mc++){var nc=a.K[mc],Da;for(Da in nc.pa)if("."!=Da.charAt(0)){var ud=nc.pa[Da].o;if(void 0!==ud){var vd=nc.pa[Da].l;vd&&(Da=vd);a.g(p(ud,4)+" "+Da)}}}else{if("d"==Ca){for(Ba in G)if(f[1]==Ba){var wd=a.ma[Ba];wd?(f.shift(),f.shift(),wd(f)):a.g("no dump registered for "+aa);break a}aa||(Ca=a.Pa||"db")}else a.Pa=Ca;if("dh"==Ca){var xd=aa,yd=qa,zd="",Ad=0,L=a.Y,ca=a.N;if(ca.length){var R=
|
||||
+xd||a.Da,Ea=+yd||10;isNaN(R)?R=Ea:zd="more ";R>ca.length&&(a.g("note: only "+ca.length+" available"),R=ca.length);L-=R;0>L&&(null==ca[ca.length-1].D?(R=L+R,L=0):L+=ca.length);var oc=[];"call"==yd&&(Ea=1E5,oc=["CALL"]);for(void 0!==xd&&a.g(R+" instructions earlier:");0<Ea&&L!=a.Y;){var Bd=ca[L++];if(null==Bd.D)break;var cb=X(Bd.D),re=R--,Cd=rd(a,cb,"history",re);(!oc.length||0<=Cd.indexOf(oc[0]))&&a.g(Cd);cb.$a&&(L+=cb.$a,Ea-=cb.$a,R-=cb.$a);L>=ca.length&&(L=0);a.Da=R;Ad++;Ea--}}Ad||(a.g("no "+zd+
|
||||
"history available"),a.Da=void 0)}else{var Bb=Z(a,aa);if(Bb){var Cb=0;qa&&("l"==qa.charAt(0)&&(qa=qa.substr(1)||qe),Cb=Vc(a,qa)>>>0,65536<Cb&&(Cb=65536));for(var ra="",Db="dd"==Ca?4:"dw"==Ca?2:1,Eb=Db*Cb||128,se=Eb+15>>4||1;se--&&0<Eb;){var Fb=0,pc=0,db,eb="",qc="",aa=p(Bb.D,4);for(db=16;0<db&&0<Eb;db--){var Gb=a.Wa(Bb,1),Fb=Fb|Gb<<(pc++<<3);pc==Db&&(eb+=p(Fb,2*Db),eb+=1==Db?9==db?"-":" ":" ",Fb=pc=0);qc+=32<=Gb&&128>Gb?String.fromCharCode(Gb):".";Eb--}ra&&(ra+="\n");ra+=aa+" "+eb+(0==db?" "+qc:
|
||||
"")}ra&&a.g(ra);a.sa=Bb}}}}break;case "e":if("else"==f[0])break;var Hb=1,Dd=255,Ed=a.Wa,Fd=a.cb;"ew"==f[0]&&(Hb=2,Dd=65535,Ed=a.va,Fd=a.xb);var Gd=Hb<<1,Hd=f[1];if(null==Hd)a.g("edit memory commands:"),a.g("\teb [a] [...] edit bytes at address a"),a.g("\tew [a] [...] edit words at address a");else{var Ib=Z(a,Hd);if(Ib)for(var Jb=2;Jb<f.length;Jb++){var fb=Tc(a,f[Jb]);if(void 0===fb){a.g("unrecognized value: "+f[Jb]);break}fb&~Dd&&a.g("warning: "+p(fb)+" exceeds "+Hb+"-byte value");var te=Ed.call(a,
|
||||
Ib);a.g("changing "+p(Ib.D,4)+" from "+p(te,Gd,!0)+" to "+p(fb,Gd,!0));Fd.call(a,Ib,fb,Hb)}}break;case "g":a:{var Id=f[1],ue=b;if(void 0!==Id){var rc=Z(a,Id,!0);if(!rc)break a;id(a,rc,ue);a.wa(a.B,rc,!0)}a.Ca(!0)||d||a.g("cpu busy or unavailable, run command ignored")}break;case "h":a:{var sc;if(a.w.aa)sc="halting",a.ca();else{if(ob(a,!0))break a;sc="already halted"}d||a.g(sc)}break;case "i":if("if"==f[0]){var tc;var gb=b.substr(2),gb=pa(gb);Tc(a,gb)?(d||a.g("true: "+gb),tc=!0):(d||a.g("false: "+
|
||||
gb),tc=!1);tc||(c=!1)}break;case "k":var ve=f[0];if("?"==f[1])a.g("stack trace commands:"),a.g("\tk\tshow frame addresses"),a.g("\tks\tshow symbol information");else{var uc=0,Jd=X(),hb=X(a.f.b[6]);for(a.g("stack trace for "+p(hb.D,4));10>uc;){for(var sa=null,we=256;65536>hb.D>>>0;){Jd.D=a.va(hb,2);if(null==hb.D||!we--)break;for(var xe=a,Kb=Jd,Kd=null,ib=Kb.D,Ld=ib,vc=1;6>=vc&&ib;vc++){if(2<vc){Kb.D=ib;var Lb=rd(xe,Kb);if(0<=Lb.indexOf("JSR")){var Md=Lb.indexOf(" ");if(ib+(Lb.indexOf(" ",Md+1)-Md-
|
||||
1)/2==Ld){Kd=Lb;break}}}ib--}Kb.D=Ld;if(sa=Kd)break}if(!sa||null==sa)break;var Nd=null;if("ks"==ve){var Od=sa.match(/[0-9A-F]+$/);Od&&(Nd=Vd(a,Od[0]))}sa=oa(sa,50)+" ;"+(Nd||"stack="+p(hb.D,4));a.g(sa);uc++}uc||a.g("no return addresses found")}break;case "l":if("ln"==f[0]){Vd(a,f[1],!0);break}break;case "m":a:{var da,ea=null,B=f[1];"?"==B&&(B=void 0);if(void 0!==B){var ia=0;if("all"==B)ia=1878917119,B=null;else if("on"==B)ea=!0,B=null;else if("off"==B)ea=!1,B=null;else{"keys"==B&&(B="key");"kbd"==
|
||||
B&&(B="keyboard");for(da in G)if(B==da){ia=G[da];ea=!!(a.$&ia);break}if(!ia){a.g("unknown message category: "+B);break a}}if(ia)if("on"==f[2])a.$|=ia,ea=!0;else if("off"==f[2]&&(a.$&=~ia,ea=!1,1073741824==ia)){for(var wc=0;wc<a.ja.length;wc++)a.g(a.ja[wc]);a.ja=[]}}var ye=0,ja="";for(da in G)if(!B||B==da){var ze=!!(a.$&G[da]);if(null===ea||ea==ze)ja&&(ja+=","),++ye%10||(ja+="\n\t"),"key"==da&&(da="keys"),ja+=da}void 0===B&&a.g("message commands:\n\tm [category] [on|off]\tturn categories on/off");
|
||||
a.g((null!==ea?ea?"messages on: ":"messages off: ":"message categories:\n\t")+(ja||"none"));$c(a)}break;case "p":if("print"==f[0]){Wd(a,b.substr(5));break}var Ae="pr"==f[0]?1:0;if(a.V)a.g("step in progress");else{var Pd=X(a.f.b[7]);a.Wa(Pd);a.V?(a.wa(a.B,Pd,!0),a.Ca()||(a.A&&a.A.Ua(),a.V=0)):Xd(a,Ae?"tr":"t")}break;case "r":if("reset"==b){a.A&&a.A.reset();break}kd(a,f);break;case "s":a:switch(f[1]){case "cs":var jb;void 0!==f[3]&&(jb=+f[3]);switch(f[2]){case "int":a.f.Ha=jb;break;case "start":a.f.Ra=
|
||||
jb;break;case "stop":a.f.Ia=jb;break;default:a.g("unknown cs option");break a}void 0!==jb&&ec(a.f);a.g("checksums "+(a.f.w.Ga?"enabled":"disabled"));break;case "sp":void 0!==f[2]&&(jc(a.f,+f[2])||a.g("warning: using 1x multiplier, previous target not reached"));a.g("target speed: "+(a.f.za.toFixed(2)+"Mhz")+" ("+a.f.Aa+"x)");break;case "?":a.g("debugger options:");a.g("\tcs int #\tset checksum cycle interval to #");a.g("\tcs start #\tset checksum cycle start count to #");a.g("\tcs stop #\tset checksum cycle stop count to #");
|
||||
a.g("\tsp #\t\tset speed multiplier to #");break;default:f[1]&&a.g("unknown option: "+f[1])}break;case "t":Xd(a,f[0],f[1]);break;case "u":ld(a,f[1],f[2],8);break;case "v":if("var"==f[0]){Ud(a,b.substr(3))||(c=!1);break}a.g("PDP11js version 1.30.0 ("+a.f.tb+",RELEASE"+(rb?",TYPEDARRAYS":",LONGARRAYS")+")");a.g(window?window.navigator.userAgent:"");break;case "?":if(f[1]){Wd(a,b.substr(1));break}var kb="commands:",xc;for(xc in bd)kb+="\n"+oa(xc,9)+bd[xc];Ic(a)||(kb+="\nnote: history disabled if no exec breakpoints");
|
||||
a.g(kb);break;default:a.g("unknown command: "+b),c=!1}}}catch(Qd){a.g("debugger error: "+(Qd.stack||Qd.message)),c=!1}return c}function fc(a,b,d){b=Rc(a,b,d);for(var c in b)if(!qd(a,b[c]))return!1;return!0}Pa(function(){for(var a=E(document,"pdp11","debugger"),b=0;b<a.length;b++){var d=a[b],c=C(d),c=new Yc(c);lb(c,d)}});
|
||||
function Zd(a,b,d){x.call(this,"Computer",a,Zd,67108864);this.w.Z=!1;$d(this,b);this.R=cc(this,"autoPower",a);this.F=0;this.W=a.busWidth||a.buswidth;this.A=ae;this.N=null;this.K=this.U=!1;this.X=cc(this,"url")||"";(Math.random()+.1).toString(36);this.B=be(this);if(this.f=bb("CPU",this.id)){this.I=bb("Debugger",this.id);this.H=new ub({id:this.lb+".bus",busWidth:this.W},this.f,this.I);var c,e=ab(this.id);if((this.G=bb("Panel",this.id))&&this.G.xa)for(b=0;b<e.length;b++)c=e[b],c.ea=this.G.ea,c.g=this.G.g,
|
||||
c.xa=this.G.xa;this.g("PDP11js v1.30.0\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");this.g("Portions adapted from the PDP-11/70 Emulator v1.3 by Paul Nankervis <paulnank@hotmail.com>");for(b=0;b<e.length;b++)c=e[b],c.ya&&c.ya(this,this.H,this.f,this.I);b=null;c=a.resume;void 0!==c&&(1<c.length?b=this.M=c:this.A=parseInt(c,10));var f;if(a=cc(this,"state")||(f=!0,a.state))b=this.S=a,f||(this.K=!0,this.A=ae),this.A&&(this.O=
|
||||
new J(this,"1.30.0"),ce(this.O)?b=null:delete this.O);!b&&this.A&&(b=de(this))&&(this.K=!0);if(b){var h=this;wa(b,null,!0,function(a,b,c){c?(h.M=null,h.K=!1,h.ea("Unable to load machine state from server (error "+c+(b?": "+pa(b):"")+")")):(h.N=b,h.U=!0);F(h)})}else F(this);this.L.power||(this.R=!0);!d&&this.R&&ee(this,this.Sa)}else u("Unable to find CPU component")}A(Zd);var ae=0;
|
||||
function $d(a,b){if(!b){var d;if("object"==typeof resources&&(d=resources.parms))try{b=eval("("+d+")")}catch(c){u(c.message+" ("+d+")")}}a.V=b}function cc(a,b,d){var c=b.toLowerCase(),c=Ua[b]||Ua[c];void 0===c&&a.V&&(c=a.V[b]);void 0===c&&d&&(c=d[b]);void 0===c&&"object"==typeof resources&&resources[b]&&(c=b);return c}function ee(a,b,d){for(var c=ab(a.id),e=0;e<=c.length;e++){var f=e<c.length?c[e]:a;if(!pb(f)){pb(f,function(){ee(a,b,d)});return}}b.call(a,d)}
|
||||
function fe(a,b){var d=new J(a,"1.30.0","validate");if(ce(d)&&ge(d)){var c=he(d,"timestamp"),e=b?he(b,"timestamp"):"unknown";c!=e&&(a.ea("Machine state may be out-of-date\n("+c+" vs. "+e+")\nCheck your browser's local storage limits"),b||d.clear())}}m=Zd.prototype;
|
||||
m.Sa=function(a){void 0===a&&(a=this.A||(this.N?1:ae));if(!this.F){this.F++;var b=!1,d=!1;this.T=!1;var c=this.O||new J(this,"1.30.0");if(-1==a)b=!0;else if(a>ae){if(ce(c,this.N)){this.J=new J(this,"1.30.0","failsafe");ce(this.J)&&(ie(this,c),a=2,je(this.J));K(this.J,"timestamp",va());ke(this.J);var e=this.A&&!this.K;if(1==a||xa("Click OK to restore the previous PDP11js machine state, or CANCEL to reset the machine.")){if(d=ge(c)){var f=he(c,"code"),h=he(c,"data");f&&("ok"==f?ce(c,h):("error"==f&&
|
||||
"no machine state"!=h?(this.ea("Error: "+h),"unable to verify user"==h&&(Ga("user",""),this.B=null)):this.g(f+": "+h),je(c),ce(c)?(d=ge(c),e=!0):d=!1))}e&&fe(this,d?c:null)}else 2==a&&c.clear()}else fe(this);delete this.N;delete this.O}e=ab(this.id);for(f=0;f<e.length;f++)h=e[f],h!==this&&h!=this.f&&(d=le(this,h,c,b,d));b=[c,a,d];-1!=a?ee(this,this.ib,b):this.ib(b)}};
|
||||
function le(a,b,d,c,e){if(!b.w.Z){b.w.Z=!0;if(b.ra){var f=null;e&&((f=he(d,b.id))||(f=he(d,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.ra(f,c)&&f&&(u("Unable to restore state for "+b.type),a.S&&!a.U?(d.clear(),a.A=ae,window&&window.location.reload()):a.T=!0,b.ra(null),e=!1)}if(!c&&b.kb)for(a=b.kb.split("|"),d=0;d<a.length;d++)b.status(a[d])}return e}
|
||||
m.ib=function(a){var b=a[0],d=0>a[1];a=a[2];this.Y=!0;this.w.Z=!0;var c=this.L.power;c&&(c.textContent="Shutdown");this.f&&(le(this,this.f,b,d,a),this.f.Ma());this.T&&(ie(this,b),b.clear());!d&&this.J&&(this.J.clear(),delete this.J);this.F=0};
|
||||
function ie(a,b){if(xa("There may be a problem with your PDP11js machine.\n\nTo help us diagnose it, click OK to send this PDP11js machine state to http://www.pcjs.org.")){var d=a.B||"",c=b.toString(),e={app:"PDP11js",ver:"1.30.0"};e.url=a.X;e.user=d;e.type="bug";e.data=c;wa("http://www.pcjs.org/api/v1/report",e,!0)}}
|
||||
function Yd(a,b,d){var c,e="none";if(a.F)return null;a.F--;var f=new J(a,"1.30.0"),h=new J(a,"1.30.0","validate"),g=va();K(h,"timestamp",g);K(f,"timestamp",g);K(f,"version","1.30.0");K(f,"url",window?window.location.href:null);K(f,"browser",window?window.navigator.userAgent:"");a.f&&a.f.qa&&(d&&a.f.ca(),c=a.f.qa(b,d),"object"===typeof c&&K(f,a.f.id,c),d&&(a.f.w.Z=!1,!1===c&&(e=null)));for(var g=ab(a.id),k=0;k<g.length;k++){var l=g[k];l.w.Z&&(l.qa&&(c=l.qa(b,d),"object"===typeof c&&K(f,l.id,c)),d&&
|
||||
(l.w.Z=!1,!1===c&&(e=null)))}e&&(d?(g=c=!1,b?(a.B&&me(a,a.B,f.toString()),ke(h)&&ke(f)||(e=null,c=g=!0)):a.A&&(c=!0,g=3==a.A),c&&f.clear(g)):e=f.toString());d&&(a.w.Z=!1,b=a.L.power)&&(b.textContent="Power");a.F=0;return e}m.reset=function(){this.H&&this.H.reset&&(this.I&&mb(this,0)&&this.I.message("Resetting "+this.H.type,void 0),this.H.reset());for(var a=ab(this.id),b=0;b<a.length;b++){var d=a[b];d!==this&&d!==this.H&&d.reset&&(this.I&&mb(this,0)&&this.I.message("Resetting "+d.type,void 0),d.reset())}};
|
||||
m.start=function(a,b){for(var d=ab(this.id),c=0;c<d.length;c++){var e=d[c];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}};m.stop=function(a,b){for(var d=ab(this.id),c=0;c<d.length;c++){var e=d[c];"CPU"!=e.type&&e!==this&&e.stop&&e.stop(a,b)}};
|
||||
m.fa=function(a,b,d){var c=this;switch(b){case "power":return this.J[b]=d,d.onclick=function(){c.u||(c.w.W?Xd(c,!1,!0):de(c,c.Pa))},!0;case "reset":return this.J[b]=d,d.onclick=function(){if(c.w.W&&!c.u)if(c.g&&!c.I){var a=wa("Click OK to save changes to this PDP11js machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Xd(c,a,!0);!a&&c.O?window&&window.location.reload():c.Pa($d)}else c.reset(),c.b&&c.b.Ja()},!0;case "save":if(ja()){d.parentNode.removeChild(d);break}this.J[b]=
|
||||
d;d.onclick=function(){var a=ae(c,!0);if(a){var b=!!(c.g&&!c.I||c.O),d=Xd(c,b);b?le(c,a,d):c.da("Resume disabled, machine state not saved")}};return!0}return!1};
|
||||
function ae(a,b){var d=a.i;d||(d=Fa("user"),void 0!==d?!d&&b&&(d=null,window&&(d=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),d&&((d=me(a,d))||a.da("The user ID is invalid."))):b&&a.da("Browser local storage is not available"));return d}
|
||||
function me(a,b){a.i=null;var d=va(ka()+"/api/v1/user?req=verify&user="+b),c=d[1];if(!d[0]&&c)try{d=eval("("+c+")"),d.code&&"ok"==d.code&&(Ga("user",d.data),a.i=d.data)}catch(e){t(e.message+" ("+c+")")}return a.i}function ce(a){var b=null;a.i&&(b=ka()+"/api/v1/user?req=load&user="+a.i+"&state="+ne(a,"1.30.0"));return b}
|
||||
function le(a,b,d){if(d){var c={req:"store"};c.user=b;c.state=ne(a,"1.30.0");c.data=d;b=va(ka()+"/api/v1/user",c);c=b[0];if(b[1]){if(c){var e=c.indexOf("\n");0<e&&(c=c.substr(0,e));c.indexOf("Error: ")||(c=c.substr(7))}c='{"code":'+b[1]+',"data":"'+c+'"}'}b=JSON.parse(c);b&&"ok"==b.code?a.da("Machine state saved to server"):d&&(d=b&&b.data||"unable to save machine state",d="error"==b.code?"Error: "+d:"Error "+b.code+": "+d,a.da(d),Ga("user",""),a.i=null)}}m.Ra=function(){};
|
||||
m.ha=function(a){this.b&&this.b.ha(a);this.C&&this.C.ha(a)};Pa(function(){for(var a=D(document,"pdp11-machine"),b=0;b<a.length;b++)for(var d=a[b],c=B(d),d=D(d,"pdp11","computer"),e=0;e<d.length;e++){var f=d[e],h=B(f),h=new Yd(h,c,!0);lb(h,f);h.M&&de(h,h.Pa)}});Ka.show.push(function(){for(var a=D(document,"pdp11","computer"),b=0;b<a.length;b++){var d=B(a[b]);(d=kb("Computer",d.id))&&d.V&&!d.w.W&&d.Pa(-1)}});
|
||||
Ka.exit.push(function(){for(var a=D(document,"pdp11","computer"),b=0;b<a.length;b++){var d=B(a[b]);(d=kb("Computer",d.id))&&d.w.W&&Xd(d,!(!d.g||d.I),!0)}});function I(a,b,d){this.id=a.id;this.key=ne(a,b,d);this.D=a.D;ie(this,a.Gb)}function ne(a,b,d){a=a.id;if(b){var c=b.indexOf(".");0<c&&(a+=".v"+b.substr(0,c))}d&&(a+="."+d);return a}
|
||||
I.prototype={constructor:I,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){ie(this);var b=[];try{for(var d=0,c=window.localStorage.length;d<c;d++)b.push(window.localStorage.key(d))}catch(e){}for(d=0;d<b.length;d++)if((c=b[d])&&(a||c.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(c)}catch(e){}b.splice(d,1);d=0}}};
|
||||
function ie(a,b){a[a.id]={};b&&J(a,"parms",b);a.b=!1}function je(a){var b=!0;if(ya()){var d=JSON.stringify(a[a.id]);Ga(a.key,d)||(t("Unable to store "+d.length+" bytes in browser local storage"),b=!1)}return b}function fe(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(d){t(d.message||d),b=!1}return b}function be(a,b){return b?(a[a.id]=b,a.b=!0):a.b?!0:ya()&&(b=Fa(a.key))?(a[a.id]=b,a.b=!0):!1}function ge(a,b){return a[a.id][b]||null}function J(a,b,d){try{a[a.id][b]=d}catch(c){}}var oe=0;
|
||||
function Ae(a,b,d,c,e,f){e("Loading "+a+"...");va(a,null,!0,function(h,g,k){k?(g||(g="unable to load "+a+" ("+k+")"),f(g,null)):Be(g,a,b,d,c,e,f)})}
|
||||
function Be(a,b,d,c,e,f,h){function g(a,f){if(f)h(f,null);else{if(d){$a(d,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);c?"}"==c.slice(-1)?(c=c.slice(0,-1),1<c.length&&(c+=",")):c='{state:"'+c+'",':c="{";c+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+d+"$2"+(c?" parms='"+c+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPNAME">).*?(<\/xsl:variable>)/,"$1PDP11js$2"),
|
||||
a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pdp11$2"));g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(q){g=null,a=q.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,g)}}a?e?Ce(a,f,g):g(a,null):h("no data"+(b?" for file: "+b:""),null)}
|
||||
function Ce(a,b,d){var c;if(c=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=c[2];b("Loading "+e+"...");va(e,null,!0,function(f,h,g){if(g||!h)d(a,"unable to resolve XML reference: "+c[0]+" ("+g+")");else{if(f=c[3])if(g=h.match(new RegExp("<"+c[1]+"[^>]*>"))){for(var k=g[0],l,n=/( [a-z]+=)(['"])(.*?)\2/g;l=n.exec(f);)k=0>k.indexOf(l[1])?k.replace(">",l[0]+">"):k.replace(new RegExp(l[1]+"(['\"])(.*?)\\1"),l[0]);g[0]!=k&&(h=h.replace(g[0],k))}else{d(a,"missing <"+c[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/,
|
||||
"");a=a.replace(c[0],h);Ce(a,b,d)}})}else d(a,null)}
|
||||
function De(a,b,d,c){function e(a){if(void 0===g){var b=h&&D(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=ma(a))}function f(a){e("Error: "+a);k&&(--oe||Ra(!0));k=!1}var h,g,k=!0;oe++;Za[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var n=document.head||document.getElementsByTagName("head")[0],q=document.createElement("style");q.type="text/css";q.styleSheet?q.styleSheet.cssText=l:q.appendChild(document.createTextNode(l));n.appendChild(q)}d||
|
||||
(d="/versions/pdp11/1.30.0/components.xsl");l=function(c,g){g?Ae(d,null,null,!1,e,function(c,k){if(k)if($a(a,d,c),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(k);l?(h.outerHTML=l,--oe||Ra(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(k),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--oe||Ra(!0)):f("invalid machine element: "+
|
||||
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(c)}):f(c)};"<"!=b.charAt(0)?Ae(b,a,c,!0,e,l):Be(b,null,a,c,!1,e,l)}else f("missing machine element: "+a)}catch(u){f(u.message)}return k}window.embedPDP11=function(a,b,d,c){Ra(!1);return De(a,b,d,c)};window.enableEvents=Ra;window.sendEvent=Sa;})();
|
||||
m.ha=function(a,b,d){var c=this;switch(b){case "power":return this.L[b]=d,d.onclick=function(){c.F||(c.w.Z?Yd(c,!1,!0):ee(c,c.Sa))},!0;case "reset":return this.L[b]=d,d.onclick=function(){if(c.w.Z&&!c.F)if(c.A&&!c.M){var a=xa("Click OK to save changes to this PDP11js machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");Yd(c,a,!0);!a&&c.S?window&&window.location.reload():c.Sa(ae)}else c.reset(),c.f&&c.f.Ma()},!0;case "save":if(ka()){d.parentNode.removeChild(d);break}this.L[b]=
|
||||
d;d.onclick=function(){var a=be(c,!0);if(a){var b=!!(c.A&&!c.M||c.S),d=Yd(c,b);b?me(c,a,d):c.ea("Resume disabled, machine state not saved")}};return!0}return!1};
|
||||
function be(a,b){var d=a.B;d||(d=Fa("user"),void 0!==d?!d&&b&&(d=null,window&&(d=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),d&&((d=ne(a,d))||a.ea("The user ID is invalid."))):b&&a.ea("Browser local storage is not available"));return d}
|
||||
function ne(a,b){a.B=null;var d=wa(la()+"/api/v1/user?req=verify&user="+b),c=d[1];if(!d[0]&&c)try{d=eval("("+c+")"),d.code&&"ok"==d.code&&(Ga("user",d.data),a.B=d.data)}catch(e){u(e.message+" ("+c+")")}return a.B}function de(a){var b=null;a.B&&(b=la()+"/api/v1/user?req=load&user="+a.B+"&state="+oe(a,"1.30.0"));return b}
|
||||
function me(a,b,d){if(d){var c={req:"store"};c.user=b;c.state=oe(a,"1.30.0");c.data=d;b=wa(la()+"/api/v1/user",c);c=b[0];if(b[1]){if(c){var e=c.indexOf("\n");0<e&&(c=c.substr(0,e));c.indexOf("Error: ")||(c=c.substr(7))}c='{"code":'+b[1]+',"data":"'+c+'"}'}b=JSON.parse(c);b&&"ok"==b.code?a.ea("Machine state saved to server"):d&&(d=b&&b.data||"unable to save machine state",d="error"==b.code?"Error: "+d:"Error "+b.code+": "+d,a.ea(d),Ga("user",""),a.B=null)}}m.Ua=function(){};
|
||||
m.ia=function(a){this.f&&this.f.ia(a);this.G&&this.G.ia(a)};Pa(function(){for(var a=E(document,"pdp11-machine"),b=0;b<a.length;b++)for(var d=a[b],c=C(d),d=E(d,"pdp11","computer"),e=0;e<d.length;e++){var f=d[e],h=C(f),h=new Zd(h,c,!0);lb(h,f);h.R&&ee(h,h.Sa)}});Ka.show.push(function(){for(var a=E(document,"pdp11","computer"),b=0;b<a.length;b++){var d=C(a[b]);(d=bb("Computer",d.id))&&d.Y&&!d.w.Z&&d.Sa(-1)}});
|
||||
Ka.exit.push(function(){for(var a=E(document,"pdp11","computer"),b=0;b<a.length;b++){var d=C(a[b]);(d=bb("Computer",d.id))&&d.w.Z&&Yd(d,!(!d.A||d.M),!0)}});function J(a,b,d){this.id=a.id;this.key=oe(a,b,d);this.I=a.I;je(this,a.Eb)}function oe(a,b,d){a=a.id;if(b){var c=b.indexOf(".");0<c&&(a+=".v"+b.substr(0,c))}d&&(a+="."+d);return a}
|
||||
J.prototype={constructor:J,value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){je(this);var b=[];try{for(var d=0,c=window.localStorage.length;d<c;d++)b.push(window.localStorage.key(d))}catch(e){}for(d=0;d<b.length;d++)if((c=b[d])&&(a||c.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(c)}catch(e){}b.splice(d,1);d=0}}};
|
||||
function je(a,b){a[a.id]={};b&&K(a,"parms",b);a.f=!1}function ke(a){var b=!0;if(za()){var d=JSON.stringify(a[a.id]);Ga(a.key,d)||(u("Unable to store "+d.length+" bytes in browser local storage"),b=!1)}return b}function ge(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(d){u(d.message||d),b=!1}return b}function ce(a,b){return b?(a[a.id]=b,a.f=!0):a.f?!0:za()&&(b=Fa(a.key))?(a[a.id]=b,a.f=!0):!1}function he(a,b){return a[a.id][b]||null}function K(a,b,d){try{a[a.id][b]=d}catch(c){}}var pe=0;
|
||||
function Be(a,b,d,c,e,f){e("Loading "+a+"...");wa(a,null,!0,function(h,g,k){k?(g||(g="unable to load "+a+" ("+k+")"),f(g,null)):Ce(g,a,b,d,c,e,f)})}
|
||||
function Ce(a,b,d,c,e,f,h){function g(a,f){if(f)h(f,null);else{if(d){$a(d,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);c?"}"==c.slice(-1)?(c=c.slice(0,-1),1<c.length&&(c+=",")):c='{state:"'+c+'",':c="{";c+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+d+"$2"+(c?" parms='"+c+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPNAME">).*?(<\/xsl:variable>)/,"$1PDP11js$2"),
|
||||
a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pdp11$2"));g=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(g=new window.ActiveXObject("Microsoft.XMLDOM"),g.async=!1,g.loadXML(a)):g=(new window.DOMParser).parseFromString(a,"text/xml")}catch(q){g=null,a=q.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);h(a,g)}}a?e?De(a,f,g):g(a,null):h("no data"+(b?" for file: "+b:""),null)}
|
||||
function De(a,b,d){var c;if(c=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=c[2];b("Loading "+e+"...");wa(e,null,!0,function(f,h,g){if(g||!h)d(a,"unable to resolve XML reference: "+c[0]+" ("+g+")");else{if(f=c[3])if(g=h.match(new RegExp("<"+c[1]+"[^>]*>"))){for(var k=g[0],l,n=/( [a-z]+=)(['"])(.*?)\2/g;l=n.exec(f);)k=0>k.indexOf(l[1])?k.replace(">",l[0]+">"):k.replace(new RegExp(l[1]+"(['\"])(.*?)\\1"),l[0]);g[0]!=k&&(h=h.replace(g[0],k))}else{d(a,"missing <"+c[1]+"> in "+e);return}h=h.replace(/<\?xml[^>]*>[\r\n]*/,
|
||||
"");a=a.replace(c[0],h);De(a,b,d)}})}else d(a,null)}
|
||||
function Ee(a,b,d,c){function e(a){if(void 0===g){var b=h&&E(h,"machine-warning");g=b&&b[0]||h}g&&(g.innerHTML=na(a))}function f(a){e("Error: "+a);k&&(--pe||Ra(!0));k=!1}var h,g,k=!0;pe++;Za[a]={};try{if(h=document.getElementById(a)){var l;if("object"==typeof resources&&(l=resources.css)){var n=document.head||document.getElementsByTagName("head")[0],q=document.createElement("style");q.type="text/css";q.styleSheet?q.styleSheet.cssText=l:q.appendChild(document.createTextNode(l));n.appendChild(q)}d||
|
||||
(d="/versions/pdp11/1.30.0/components.xsl");l=function(c,g){g?Be(d,null,null,!1,e,function(c,k){if(k)if($a(a,d,c),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window){var l=g.transformNode(k);l?(h.outerHTML=l,--pe||Ra(!0)):f("transformNodeToObject failed")}else document.implementation&&document.implementation.createDocument?(l=new XSLTProcessor,l.importStylesheet(k),(l=l.transformToFragment(g,document))?h.parentNode?(h.parentNode.replaceChild(l,h),--pe||Ra(!0)):f("invalid machine element: "+
|
||||
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser");else f(c)}):f(c)};"<"!=b.charAt(0)?Be(b,a,c,!0,e,l):Ce(b,null,a,c,!1,e,l)}else f("missing machine element: "+a)}catch(v){f(v.message)}return k}window.embedPDP11=function(a,b,d,c){Ra(!1);return Ee(a,b,d,c)};window.enableEvents=Ra;window.sendEvent=Sa;})();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ typeof b){var k="",l;for(l in b)b.hasOwnProperty(l)&&(k&&(k+="&"),k+=l+"="+encod
|
|||
function t(a){window&&window.alert(a)}function ha(a){var b=!1;window&&(b=window.confirm(a));return b}var ia=null;function ja(){if(null==ia){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}ia=a}return ia}function ka(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
|
||||
function la(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function ma(a){if(window){var b=window?window.navigator.userAgent:"";return"iOS"==a&&b.match(/(iPod|iPhone|iPad)/)&&b.match(/AppleWebKit/)||"MSIE"==a&&b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)?!0:!1}return!1}var u={init:[],show:[],exit:[]},na=!1,oa=!1,pa=!0;function qa(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function v(a){u.init.push(a)}
|
||||
function ra(a){if(pa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){t(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function sa(a){!pa&&a?(pa=!0,na&&ta("init"),oa&&ta("show")):pa=a}function ta(a){u[a]&&ra(u[a])}qa("onload",function(){na=!0;ra(u.init)});qa("onpageshow",function(){oa=!0;ra(u.show)});qa(ma("Opera")||ma("iOS")?"onunload":"onbeforeunload",function(){ra(u.exit)});
|
||||
function w(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.Ja=b.comment;this.$a=b;b=this.id.indexOf(".");0>b?this.ta=this.id:(this.Ka=this.id.substr(0,b),this.ta=this.id.substr(b+1));this[a]=c;this.h={ready:!1,ha:!1,ua:!1,A:!1,error:!1};this.qa=null;this.h.error=!1;this.o={};this.B=null;x.push(this)}var ua=void 0,va={};
|
||||
function w(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.Ka=b.comment;this.$a=b;b=this.id.indexOf(".");0>b?this.ta=this.id:(this.La=this.id.substr(0,b),this.ta=this.id.substr(b+1));this[a]=c;this.h={ready:!1,ha:!1,ua:!1,A:!1,error:!1};this.qa=null;this.h.error=!1;this.o={};this.B=null;x.push(this)}var ua=void 0,va={};
|
||||
if(window){ua||(ua=window.location.search.substr(1));for(var wa,xa=/\+/g,ya=/([^&=]+)=?([^&]*)/g;wa=ya.exec(ua);)va[decodeURIComponent(wa[1].replace(xa," "))]=decodeURIComponent(wa[2].replace(xa," "))}function za(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
|
||||
function y(a,b){b||(b=w);a.prototype=za(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}if(window){window.PCjs||(window.PCjs={});var Aa=window.PCjs.Machines||(window.PCjs.Machines={}),x=window.PCjs.Components||(window.PCjs.Components=[])}else Aa={},x=[];function Ba(a,b,c){Aa[a]&&b&&(Aa[a][b]=c)}function A(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<x.length;b++){var d=x[b];a&&d.id.indexOf(a)||c.push(d)}return c}
|
||||
function Ca(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<x.length;d++)if(c)c==x[d]&&(c=null);else if(!(a!=x[d].type||b&&x[d].id.indexOf(b)))return x[d]}return null}function B(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){t(c.message+" ("+a+")")}return b}
|
||||
|
|
@ -26,31 +26,32 @@ F.prototype={constructor:F,parent:null,save:function(){var a,b;if(Fa)for(a=Array
|
|||
2]>>>((a&3)<<3)&255},P:function(a){var b=a>>2;a=(a&3)<<3;var c=this.a[b]>>a;return 24>a?c&65535:c&255|(this.a[b+1]&255)<<8},U:function(a,b){var c=a>>2,d=(a&3)<<3;this.a[c]=this.a[c]&~(255<<d)|b<<d;this.W=!0},ca:function(a,b){var c=a>>2,d=(a&3)<<3;24>d?this.a[c]=this.a[c]&~(65535<<d)|b<<d:(this.a[c]=this.a[c]&16777215|b<<24,c++,this.a[c]=this.a[c]&-256|b>>8);this.W=!0},C:function(a,b){return this.D(a,b)},J:function(a,b){return this.N(a,b)},S:function(a,b,c){this.o||this.Ua(a,b,c)},Z:function(a,b,c){this.o||
|
||||
this.aa(a,b,c)},v:function(a){return this.b[a]},F:function(a){return this.b[a]},I:function(a){return this.f.getUint16(a,!0)},O:function(a){return a&1?this.b[a]|this.b[a+1]<<8:this.j[a>>1]},R:function(a,b){this.b[a]=b;this.W=!0},T:function(a,b){this.b[a]=b;this.W=!0},V:function(a,b){this.f.setUint16(a,b,!0);this.W=!0},ba:function(a,b){a&1?(this.b[a]=b,this.b[a+1]=b>>8):this.j[a>>1]=b;this.W=!0}};function Ja(a,b,c){a.B=b;a.g=a.i=0;c&&((a.g=c.g)&&Xa(a,Ya,!1),(a.i=c.i)&&Za(a,Ya,!1))}
|
||||
function Za(a,b,c){c&&a.i||(a.u=!a.o&&b[2]||a.s);if(c||void 0===c)a.Ua=b[2]||a.s,a.aa=b[3]||a.$}function Xa(a,b,c){c&&a.g||(a.l=b[0]||a.m);if(c||void 0===c)a.D=b[0]||a.m,a.N=b[1]||a.K}function Ta(a,b){b||(b=$a);Xa(a,b,void 0);Za(a,b,void 0)}var $a=[],Wa=[F.prototype.G,F.prototype.P,F.prototype.U,F.prototype.ca],Ya=[F.prototype.C,F.prototype.J,F.prototype.S,F.prototype.Z];if(Fa)var Va=[F.prototype.v,F.prototype.I,F.prototype.R,F.prototype.V],Ua=[F.prototype.F,F.prototype.O,F.prototype.T,F.prototype.ba];
|
||||
function ab(a,b){w.call(this,"CPU",a,ab);var c=a.multiplier||1;this.Aa=a.cycles||b;this.T=c;this.va=Math.round(this.Aa/1E4)/100;this.R=this.va*this.T;this.h.M=!1;this.h.Sa=!1;this.h.ga=a.autoStart;this.h.Fa=!1;this.h.pa=!1;this.na=this.S=0;this.oa=a.csStart;this.$=a.csInterval;this.aa=a.csStop;this.ka=[];this.Za=this.Da.bind(this);E(this)}y(ab);var bb=["power","reset"];m=ab.prototype;
|
||||
function ab(a,b){w.call(this,"CPU",a,ab);var c=a.multiplier||1;this.Aa=a.cycles||b;this.T=c;this.va=Math.round(this.Aa/1E4)/100;this.R=this.va*this.T;this.h.M=!1;this.h.Sa=!1;this.h.ga=a.autoStart;this.h.Ga=!1;this.h.pa=!1;this.na=this.S=0;this.oa=a.csStart;this.$=a.csInterval;this.aa=a.csStop;this.ka=[];this.Za=this.Ea.bind(this);E(this)}y(ab);var bb=["power","reset"];m=ab.prototype;
|
||||
m.ea=function(a,b,c,d){this.l=a;this.u=b;this.B=d;for(b=0;b<bb.length;b++)(c=this.o[bb[b]])&&this.l.L(null,bb[b],c);this.Z=null;a=cb(a,"autoStart");null!=a&&(this.h.ga="true"==a?!0:"false"==a?!1:!!a);E(this)};m.reset=function(){};m.save=function(){return null};m.restore=function(){return!1};m.Y=function(a,b){if(!b){if(a&&this.restore){db(this);if(!this.restore(a))return!1;eb(this)}else this.reset();this.H("No debugger detected")}fb(this);return!0};m.X=function(a){return a?this.save():!0};
|
||||
m.ga=function(){return this.h.ga||void 0===this.o.run?(this.Da(),!0):!1};m.Ha=function(){return 0};function eb(a){void 0===a.oa&&(a.oa=0);void 0===a.$&&(a.$=-1);void 0===a.aa&&(a.aa=-1);a.h.pa=0<=a.oa&&0<a.$;a.h.pa&&(a.na=0,a.S=a.oa-a.N)}function gb(a,b,c,d){a.o[b]&&(void 0===c&&(a.h.error=!0,a.w("Value for "+b+" is invalid"),G(a)),c=!a.h.M||a.h.Fa?n(c,d):"--------".substr(0,d),a.o[b].textContent!=c&&(a.o[b].textContent=c))}
|
||||
m.L=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.o[b]=c;a=!0;break;case "run":this.o[b]=c;c.onclick=function(){var a;if(a=d.l)if(a=d.l,a.h.A)a=!0;else{var b=null,c,g=A(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.h.ready);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.h.A);c++);c==g.length&&(b=a);t("The "+b.type+" component ("+b.id+") is not "+(b.h.ready?"powered yet":"ready yet"+(b.qa?" (waiting for notification)":""))+".");a=!1}a&&(d.h.M?G(d):d.Da())};a=!0;break;
|
||||
case "speed":this.o[b]=c;a=!0;break;case "setSpeed":this.o[b]=c,c.onclick=function(){hb(d,d.T<<1)},c.textContent=this.R.toFixed(2)+"Mhz",a=!0}return a};function ib(a,b,c){a.N+=b;c&&(a.K=a.G=0)}function jb(a,b){var c=1;b&&1<a.T&&a.I&&(c=a.I/a.va);a.Oa=Math.round(1E3/30);a.ja=Math.floor(a.Aa/30*c);b||(a.ba=a.ja);a.Ba=0}function kb(a){return a.N+a.F+a.K-a.G}function db(a){a.I=0;a.Pa=0;a.N=a.F=a.K=a.G=0;eb(a);hb(a,1)}
|
||||
m.ga=function(){return this.h.ga||void 0===this.o.run?(this.Ea(),!0):!1};m.Ia=function(){return 0};function eb(a){void 0===a.oa&&(a.oa=0);void 0===a.$&&(a.$=-1);void 0===a.aa&&(a.aa=-1);a.h.pa=0<=a.oa&&0<a.$;a.h.pa&&(a.na=0,a.S=a.oa-a.N)}function gb(a,b,c,d){a.o[b]&&(void 0===c&&(a.h.error=!0,a.w("Value for "+b+" is invalid"),G(a)),c=!a.h.M||a.h.Ga?n(c,d):"--------".substr(0,d),a.o[b].textContent!=c&&(a.o[b].textContent=c))}
|
||||
m.L=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.o[b]=c;a=!0;break;case "run":this.o[b]=c;c.onclick=function(){var a;if(a=d.l)if(a=d.l,a.h.A)a=!0;else{var b=null,c,g=A(a.id);for(c=0;c<g.length&&(b=g[c],b===a||b.h.ready);c++);if(c==g.length)for(c=0;c<g.length&&(b=g[c],b===a||b.h.A);c++);c==g.length&&(b=a);t("The "+b.type+" component ("+b.id+") is not "+(b.h.ready?"powered yet":"ready yet"+(b.qa?" (waiting for notification)":""))+".");a=!1}a&&(d.h.M?G(d):d.Ea())};a=!0;break;
|
||||
case "speed":this.o[b]=c;a=!0;break;case "setSpeed":this.o[b]=c,c.onclick=function(){hb(d,d.T<<1)},c.textContent=this.R.toFixed(2)+"Mhz",a=!0}return a};function ib(a,b,c){a.N+=b;c&&(a.K=a.G=0)}function jb(a,b){var c=1;b&&1<a.T&&a.I&&(c=a.I/a.va);a.Pa=Math.round(1E3/30);a.ja=Math.floor(a.Aa/30*c);b||(a.ba=a.ja);a.Ba=0}function kb(a){return a.N+a.F+a.K-a.G}function db(a){a.I=0;a.Qa=0;a.N=a.F=a.K=a.G=0;eb(a);hb(a,1)}
|
||||
function hb(a,b){if(void 0!==b){.8>a.I/a.R&&(b=1);a.T=b;var c=a.va*a.T;if(a.R!=c){a.R=c;var c=a.R.toFixed(2)+"Mhz",d=a.o.setSpeed;d&&(d.textContent=c);a.H("target speed: "+c)}}ib(a,a.F);a.F=0;a.D=q();a.J=0;jb(a)}function lb(a){a.K-=a.G;a.G=0}
|
||||
m.Da=function(){if(Da(this,!0)){if(!this.h.M){hb(this);this.l&&this.l.start(this.D,kb(this));this.h.M=!0;this.h.Sa=!0;this.Z&&this.Z.start();var a=this.o.run;a&&(a.textContent="Halt");this.l&&this.l.da(!0)}this.Ba>=this.Aa&&jb(this,!0);this.ca=0;this.ma=q();this.J&&(a=this.ma-this.J,a>this.Oa&&(this.D+=a,this.D>this.ma&&(this.D=this.ma)));try{do{for(var b=this.h.pa?1:this.ja,c=this.ka.length-1;0<=c;c--){var d=this.ka[c];0>d[0]||b>d[0]&&(b=d[0])}this.Ta(b);for(var f=this.K-this.G,a=f,e=this.ka.length-
|
||||
1;0<=e;e--){var h=this.ka[e];0>h[0]||(h[0]-=a,0>=h[0]&&(h[0]=-1,h[1]()))}this.ca+=f;this.F+=f;ib(this,0,!0);a=f;if(this.h.pa){var g=!1;this.na=this.na+this.Ha()|0;this.S-=a;0>=this.S&&(this.S+=this.$,g=!0);0<=this.aa&&this.aa<=kb(this)&&(this.$=this.aa=-1,eb(this),G(this),g=!0);g&&this.H(kb(this)+" cycles: checksum="+n(this.na))}this.ba-=f;if(0>=this.ba){this.ba+=this.ja;15<=++this.Pa&&(this.l&&this.l.da(),this.Pa=0);break}}while(this.h.M)}catch(k){G(this);fb(this);this.l&&this.l.stop(q(),kb(this));
|
||||
Da(this,!1);b=k.stack||k.message;this.h.error=!0;this.w(b);return}b=setTimeout;c=this.Za;this.J=q();d=this.Oa;this.ca&&(d=Math.round(d*this.ca/this.ja));d=d-(this.J-this.ma);if(f=this.J-this.D)this.I=Math.round(this.F/(10*f))/100,864E5<=f&&(this.N=0,hb(this));if(0>d||this.I<this.R)-1E3>d&&(this.D-=d),d=0;this.Ba+=this.ca;this.J+=d;b(c,d)}else fb(this),this.l&&this.l.stop(q(),kb(this))};m.Ta=function(){return 0};
|
||||
m.Ea=function(){if(Da(this,!0)){if(!this.h.M){hb(this);this.l&&this.l.start(this.D,kb(this));this.h.M=!0;this.h.Sa=!0;this.Z&&this.Z.start();var a=this.o.run;a&&(a.textContent="Halt");this.l&&this.l.da(!0)}this.Ba>=this.Aa&&jb(this,!0);this.ca=0;this.ma=q();this.J&&(a=this.ma-this.J,a>this.Pa&&(this.D+=a,this.D>this.ma&&(this.D=this.ma)));try{do{for(var b=this.h.pa?1:this.ja,c=this.ka.length-1;0<=c;c--){var d=this.ka[c];0>d[0]||b>d[0]&&(b=d[0])}this.Ta(b);for(var f=this.K-this.G,a=f,e=this.ka.length-
|
||||
1;0<=e;e--){var h=this.ka[e];0>h[0]||(h[0]-=a,0>=h[0]&&(h[0]=-1,h[1]()))}this.ca+=f;this.F+=f;ib(this,0,!0);a=f;if(this.h.pa){var g=!1;this.na=this.na+this.Ia()|0;this.S-=a;0>=this.S&&(this.S+=this.$,g=!0);0<=this.aa&&this.aa<=kb(this)&&(this.$=this.aa=-1,eb(this),G(this),g=!0);g&&this.H(kb(this)+" cycles: checksum="+n(this.na))}this.ba-=f;if(0>=this.ba){this.ba+=this.ja;15<=++this.Qa&&(this.l&&this.l.da(),this.Qa=0);break}}while(this.h.M)}catch(k){G(this);fb(this);this.l&&this.l.stop(q(),kb(this));
|
||||
Da(this,!1);b=k.stack||k.message;this.h.error=!0;this.w(b);return}b=setTimeout;c=this.Za;this.J=q();d=this.Pa;this.ca&&(d=Math.round(d*this.ca/this.ja));d=d-(this.J-this.ma);if(f=this.J-this.D)this.I=Math.round(this.F/(10*f))/100,864E5<=f&&(this.N=0,hb(this));if(0>d||this.I<this.R)-1E3>d&&(this.D-=d),d=0;this.Ba+=this.ca;this.J+=d;b(c,d)}else fb(this),this.l&&this.l.stop(q(),kb(this))};m.Ta=function(){return 0};
|
||||
function G(a){a.h.ha&&(a.h.ua=!0);lb(a);ib(a,a.F);a.F=0;if(a.h.M){a.h.M=!1;a.Z&&a.Z.stop();var b=a.o.run;b&&(b.textContent="Run")}a.h.complete=void 0}function fb(a){a.l&&a.l.da(void 0)}
|
||||
function mb(a){this.Ya=+a.model||1170;ab.call(this,a,1E6);this.Ia=0;this.g=65536;this.c=this.b=32768;this.f=65535;this.i=15;this.a=[0,0,0,0,0,0,0,0];this.Ra=[0,0,0,0,0,0];this.U=[0,0,0,0];this.memory=[];this.s=[];this.Ca=this.Qa=0;this.O=2;this.P=255;this.m=0;this.V=-1;this.Na=this.xa=this.Ma=this.j=this.sa=this.C=this.v=0;this.la=[7,7,7,7];this.za=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[65535,65535,65535,
|
||||
65535,65535,65535,65535,65535,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];this.bb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h.complete=this.h.Va=!1}y(mb,ab);m=mb.prototype;m.reset=function(){this.h.M&&G(this);nb(this);db(this);this.h.error=!1;this.parent.reset.call(this)};
|
||||
function nb(a){a.P=255;a.s=[];a.Qa=0;a.v=a.C=a.sa=a.Ma=0;a.la[0]=a.la[1]=a.la[3]=7;a.xa=0}m.Ha=function(){return 0};m.save=function(){var a=new H(this);I(a,0,[]);I(a,1,[this.La,this.N,this.T]);for(var b=this.u,c=0,d=[],f=0;f<b.i;f++){var e=b.b[f];if(e.W||e.Wa){d[c++]=f;var h=c++;a:if(e=e.save()){for(var g=0,k=0,l=[];g<e.length;){for(var Q=e[g],z=g+1;z<e.length&&e[z]===Q;)z++;l[k++]=z-g;l[k++]=Q;g=z}if(l.length<e.length){e=l;break a}}d[h]=e}}I(a,2,d);return a.data()};
|
||||
m.restore=function(a){var b=a[1];this.La=b[0];this.N=b[1];hb(this,b[3]);a:{b=this.u;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],f=a[c+1];if(f&&f.length<b.l){for(var e=0,h=Array(b.l),g=0;g<f.length-1;)for(var k=f[g++],l=f[g++];k--;)h[e++]=l;f=h}e=b.b[d];if(!e||!e.restore(f)){t("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
|
||||
m.L=function(a,b,c){var d=!1;switch(b){case "PC":case "PSW":case "SF":case "ZF":case "CF":this.o[b]=c;this.Ia++;d=!0;break;default:d=this.parent.L.call(this,a,b,c)}return d};m.da=function(a){this.Ia&&(a||!this.h.M||this.h.Fa)&&(a=this.i&-14|0|(this.ab&255?0:4)|(this.ab&256?1:0),gb(this,"PSW",a,4),gb(this,"SF",a&8?1:0,1),gb(this,"ZF",a&4?1:0,1),gb(this,"CF",a&1?1:0,1));if(a=this.o.speed)a.textContent=this.h.M&&this.I?this.I.toFixed(2)+"Mhz":"Stopped"};
|
||||
function ob(a,b){var c,d;a.b=b<<12;a.f=~b&4;a.c=b<<14;a.g=b<<16;if((b^a.i)&2048)for(c=0;6>c;c++)d=a.a[c],a.a[c]=a.Ra[c],a.Ra[c]=d;(a.j=b>>14&3)!==(a.i>>14&3)&&(a.U[d]=a.a[6],a.a[6]=a.U[a.j]);a.O=2;a.i=b}
|
||||
function J(a,b){var c,d,f=0;0>a.V?(a.i=a.i&63728|a.b>>12&8|a.c>>14&2|a.g>>16&1,a.f&65535||(a.i|=4),a.V=a.i):a.j||(b=4,f=1);a.v&57344||(a.C=63222);a.j=0;0<=(c=K(a,b|65536))&&0<=(d=K(a,b+2&65535|65536))&&(ob(a,d&53247|a.V>>2&12288),f&&(a.a[6]=4),0<=L(a,a.V)&&0<=L(a,a.a[7])&&(a.a[7]=c));a.m=0;return a.V=-1}
|
||||
function pb(a,b,c){var d,f,e,h=0;if(c&a.Ma){d=b>>13&a.la[a.j];f=a.za[a.j][d];e=(a.za[a.j][d+16]<<6)+(b&8191)&4194303;if(a.sa&16){if(3932160<=e&&4186112>e){e=e&262143;var g=e>>13&31;31>g?a.sa&32&&(e=a.bb[g]+(e&8190)&4194302,3932160<=e&&4186112>e&&console.log("panic(898)")):e|=4186112}}else e&=262143,253952<=e&&(e|=4186112);if(3932160>e&&(3915776<=e||e&1&&!(c&1)))return J(a,4);switch(f&7){case 1:h=4096;case 2:f|=128;c&4&&(h=8192);break;case 4:h=4096;case 5:c&4&&(h=4096);case 6:f|=c&4?192:128;break;
|
||||
default:h=32768}32512!==(f&32520)&&(f&8?f&32512&&(b&8128)<(f>>2&8128)&&(h|=16384):(b&8128)>(f>>2&8128)&&(h|=16384));a.za[a.j][d]=f;if(4194170!==e||a.j)a.xa=a.j,a.Na=d;if(h){if(h&57344)return 0<=a.V&&(h|=128),a.v&57344||(a.v=a.v|h|a.xa<<5|a.Na<<1),J(a,168);a.v&61440||!(4191360>e||4194239<e)||(a.v|=4096,a.v&512&&(a.m|=2))}}else if(e=b&65535,57344<=e)e|=4186112;else if(e&1&&!(c&1))return J(a,4);return e}function M(a,b){return 4194304<=b?a.a[b-4194304]:3932160<=b?-1:0<=b?a.memory[b>>1]:b}
|
||||
function mb(a){this.Ya=+a.model||1170;ab.call(this,a,1E6);this.Ja=0;this.g=65536;this.c=this.b=32768;this.f=65535;this.i=15;this.a=[0,0,0,0,0,0,0,0];this.Ca=[0,0,0,0,0,0];this.U=[0,0,0,0];this.memory=[];this.s=[];this.Da=this.Ra=0;this.O=2;this.P=255;this.m=0;this.V=-1;this.Oa=this.xa=this.Na=this.j=this.sa=this.C=this.v=0;this.la=[7,7,7,7];this.za=[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[65535,65535,65535,
|
||||
65535,65535,65535,65535,65535,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];this.ab=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h.complete=this.h.Va=!1}y(mb,ab);m=mb.prototype;m.reset=function(){this.h.M&&G(this);nb(this);db(this);this.h.error=!1;this.parent.reset.call(this)};
|
||||
function nb(a){a.P=255;a.s=[];a.Ra=0;a.v=a.C=a.sa=a.Na=0;a.la[0]=a.la[1]=a.la[3]=7;a.xa=0}m.Ia=function(){return 0};m.save=function(){var a=new H(this);I(a,0,[]);I(a,1,[this.Ma,this.N,this.T]);for(var b=this.u,c=0,d=[],f=0;f<b.i;f++){var e=b.b[f];if(e.W||e.Wa){d[c++]=f;var h=c++;a:if(e=e.save()){for(var g=0,k=0,l=[];g<e.length;){for(var Q=e[g],z=g+1;z<e.length&&e[z]===Q;)z++;l[k++]=z-g;l[k++]=Q;g=z}if(l.length<e.length){e=l;break a}}d[h]=e}}I(a,2,d);return a.data()};
|
||||
m.restore=function(a){var b=a[1];this.Ma=b[0];this.N=b[1];hb(this,b[3]);a:{b=this.u;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],f=a[c+1];if(f&&f.length<b.l){for(var e=0,h=Array(b.l),g=0;g<f.length-1;)for(var k=f[g++],l=f[g++];k--;)h[e++]=l;f=h}e=b.b[d];if(!e||!e.restore(f)){t("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
|
||||
m.L=function(a,b,c){var d=!1;switch(b){case "PC":case "PSW":case "NF":case "ZF":case "VF":case "CF":this.o[b]=c;this.Ja++;d=!0;break;default:d=this.parent.L.call(this,a,b,c)}return d};
|
||||
m.da=function(a){this.Ja&&(a||!this.h.M||this.h.Ga)&&(a=this.i&-16|this.b>>12&8|(this.f&65535?0:4)|(this.c&32768?2:0)|(this.g&65536?1:0),gb(this,"PSW",a,4),gb(this,"NF",a&8?1:0,1),gb(this,"ZF",a&4?1:0,1),gb(this,"VF",a&2?1:0,1),gb(this,"CF",a&1?1:0,1));if(a=this.o.speed)a.textContent=this.h.M&&this.I?this.I.toFixed(2)+"Mhz":"Stopped"};
|
||||
function ob(a,b){a.b=b<<12;a.f=~b&4;a.c=b<<14;a.g=b<<16;if((b^a.i)&2048)for(var c=a.Ca.length;0<=--c;){var d=a.a[c];a.a[c]=a.Ca[c];a.Ca[c]=d}a.j=b>>14&3;c=a.i>>14&3;a.j!=c&&(a.U[c]=a.a[6],a.a[6]=a.U[a.j]);a.O=2;a.i=b}
|
||||
function J(a,b){var c,d,f=0;0>a.V?a.V=a.i=a.i&63728|a.b>>12&8|(a.f&65535?0:4)|(a.c&32768?2:0)|(a.g&65536?1:0):a.j||(b=4,f=1);a.v&57344||(a.C=63222);a.j=0;0<=(c=K(a,b|65536))&&0<=(d=K(a,b+2&65535|65536))&&(ob(a,d&53247|a.V>>2&12288),f&&(a.a[6]=4),0<=L(a,a.V)&&0<=L(a,a.a[7])&&(a.a[7]=c));a.m=0;return a.V=-1}
|
||||
function pb(a,b,c){var d,f,e,h=0;if(c&a.Na){d=b>>13&a.la[a.j];f=a.za[a.j][d];e=(a.za[a.j][d+16]<<6)+(b&8191)&4194303;if(a.sa&16){if(3932160<=e&&4186112>e){e=e&262143;var g=e>>13&31;31>g?a.sa&32&&(e=a.ab[g]+(e&8190)&4194302,3932160<=e&&4186112>e&&console.log("panic(898)")):e|=4186112}}else e&=262143,253952<=e&&(e|=4186112);if(3932160>e&&(3915776<=e||e&1&&!(c&1)))return J(a,4);switch(f&7){case 1:h=4096;case 2:f|=128;c&4&&(h=8192);break;case 4:h=4096;case 5:c&4&&(h=4096);case 6:f|=c&4?192:128;break;
|
||||
default:h=32768}32512!==(f&32520)&&(f&8?f&32512&&(b&8128)<(f>>2&8128)&&(h|=16384):(b&8128)>(f>>2&8128)&&(h|=16384));a.za[a.j][d]=f;if(4194170!==e||a.j)a.xa=a.j,a.Oa=d;if(h){if(h&57344)return 0<=a.V&&(h|=128),a.v&57344||(a.v=a.v|h|a.xa<<5|a.Oa<<1),J(a,168);a.v&61440||!(4191360>e||4194239<e)||(a.v|=4096,a.v&512&&(a.m|=2))}}else if(e=b&65535,57344<=e)e|=4186112;else if(e&1&&!(c&1))return J(a,4);return e}function M(a,b){return 4194304<=b?a.a[b-4194304]:3932160<=b?-1:0<=b?a.memory[b>>1]:b}
|
||||
function N(a,b,c){c&=65535;return 4194304<=b?a.a[b-4194304]=c:3932160<=b?-1:0<=b?a.memory[b>>1]=c:b}function O(a,b){var c;return 4194304<=b?a.a[b-4194304]&255:3932160<=b?-1:0<=b?(c=a.memory[b>>1],b&1&&(c=c>>8),c&255):b}function P(a,b,c){c&=255;return 4194304<=b?a.a[b-4194304]=a.a[b-4194304]&65280|c:3932160<=b?-1:0<=b?b&1?a.memory[b>>1]=c<<8|a.memory[b>>1]&255:a.memory[b>>1]=a.memory[b>>1]&65280|c:b}function K(a,b){return M(a,pb(a,b,2))}
|
||||
function qb(a){var b=K(a,a.a[6]|65536);0<=b&&(a.a[6]=a.a[6]+2&65535);return b}function L(a,b){var c,d;a.a[6]=d=a.a[6]-2&65535;a.v&57344||(a.C=a.C<<8|246);if(!a.j&&d<=a.P&&4<d){if(d<=a.P-32)return a.a[6]=4,J(a,4);a.m|=4}return 0<=(c=pb(a,d|65536,4))?N(a,c,b):c}
|
||||
function R(a,b,c){var d,f,e=b&7;switch(b>>3&7){case 0:return J(a,4);case 1:if(6===e&&!a.j&&c&4&&(a.a[6]<=a.P||65534<=a.a[6])){if(a.a[6]<=a.P-32||65534<=a.a[6])return a.a[6]=4,J(a,4);a.m|=4}return 7===e?a.a[e]:a.a[e]|65536;case 2:f=2;d=a.a[e];7!==e&&(d|=65536,6>e&&c&1&&(f=1));break;case 3:f=2;d=a.a[e];7!==e&&(d|=65536);if(0>(d=K(a,d)))return d;d|=65536;break;case 4:f=-2;6>e&&c&1&&(f=-1);d=a.a[e]+f&65535;7!==e&&(d|=65536);break;case 5:f=-2;d=a.a[e]-2&65535;7!==e&&(d|=65536);if(0>(d=K(a,d)))return d;
|
||||
d|=65536;break;case 6:if(0>(d=K(a,a.a[7])))return d;a.a[7]=a.a[7]+2&65535;d=d+a.a[e]&65535;return d|65536;case 7:if(0>(d=K(a,a.a[7])))return d;a.a[7]=a.a[7]+2&65535;d=d+a.a[e]&65535;return 0>(d=K(a,d|65536))?d:d|65536}a.a[e]=a.a[e]+f&65535;a.v&57344||(a.C=a.C<<8|f<<3&248|e);if(6===e&&!a.j&&c&4&&0>=f&&(a.a[6]<=a.P||65534<=a.a[6])){if(a.a[6]<=a.P-32)return a.a[6]=4,J(a,4);a.m|=4}return d}function S(a,b,c){var d;return b&56?(0<=(d=R(a,b,c))&&(d=pb(a,d,c)),d):4194304+(b&7)}
|
||||
function T(a,b){var c;b&56?0<=(c=S(a,b,2))&&(c=M(a,c)):c=a.a[b&7];return c}function U(a,b){var c;b&56?0<=(c=S(a,b,3))&&(c=O(a,c)):c=a.a[b&7]&255;return c}function V(a,b){return((b&128?b|65280:b&255)<<1)+a&65535}
|
||||
m.Ta=function(a){this.h.complete=!0;this.h.Va=!1;this.h.Sa=!1;this.K=this.G=a;this.La&256?(lb(this),a=!1):a=!0;if(a){do{var b,c,d,f,e;if(this.O)if(1===this.O)this.O=2;else{this.O=0;e=-1;b=this.Qa&224;if(0<(a=this.s.length))for(;0<a--;){if(0<this.s[a].ya){this.s[a].ya--;this.O=2;break}if(this.s[a].Ea){if(!this.s[a].Ea()){this.s.splice(a,1);e--;continue}this.s[a].Ea=null}this.s[a].Xa>b&&(b=this.s[a].Xa,e=a)}b>(this.i&224)&&(0>e?J(this,160):(J(this,this.s[e].cb),this.s.splice(e,1)))}this.v&57344||(this.C=
|
||||
m.Ta=function(a){this.h.complete=!0;this.h.Va=!1;this.h.Sa=!1;this.K=this.G=a;this.Ma&256?(lb(this),a=!1):a=!0;if(a){do{var b,c,d,f,e;if(this.O)if(1===this.O)this.O=2;else{this.O=0;e=-1;b=this.Ra&224;if(0<(a=this.s.length))for(;0<a--;){if(0<this.s[a].ya){this.s[a].ya--;this.O=2;break}if(this.s[a].Fa){if(!this.s[a].Fa()){this.s.splice(a,1);e--;continue}this.s[a].Fa=null}this.s[a].Xa>b&&(b=this.s[a].Xa,e=a)}b>(this.i&224)&&(0>e?J(this,160):(J(this,this.s[e].bb),this.s.splice(e,1)))}this.v&57344||(this.C=
|
||||
0);this.m=this.i&16;if(0<=(a=K(this,this.a[7])))switch(this.a[7]=this.a[7]+2&65535,a&61440){case 4096:0<=(b=T(this,a>>6))&&(a&56?0<=(d=S(this,a,4))&&0<=N(this,d,b)&&(this.b=this.f=b,this.c=0):(this.b=this.f=this.a[a&7]=b,this.c=0));break;case 8192:0<=(b=T(this,a>>6))&&0<=(c=T(this,a))&&(this.b=this.f=this.g=a=b-c,this.c=(b^c)&(b^a));break;case 12288:0<=(b=T(this,a>>6))&&0<=(c=T(this,a))&&(this.b=this.f=b&c,this.c=0);break;case 16384:0<=(b=T(this,a>>6))&&(a&56?0<=(c=M(this,d=S(this,a,6)))&&(a=c&~b,
|
||||
0<=N(this,d,a)&&(this.b=this.f=a,this.c=0)):(this.b=this.f=a=this.a[a&7]&=~b,this.c=0));break;case 20480:0<=(b=T(this,a>>6))&&(a&56?0<=(c=M(this,d=S(this,a,6)))&&(a=c|b,0<=N(this,d,a)&&(this.b=this.f=a,this.c=0)):(this.b=this.f=a=this.a[a&7]|=b,this.c=0));break;case 24576:0<=(b=T(this,a>>6))&&(a&56?0<=(c=M(this,d=S(this,a,6)))&&(a=b+c,0<=N(this,d,a)&&(this.b=this.f=this.g=a,this.c=(b^a)&(c^a))):(e=a&7,c=this.a[e],this.a[e]=(a=b+c)&65535,this.b=this.f=this.g=a,this.c=(b^a)&(c^a)));break;case 36864:0<=
|
||||
(b=U(this,a>>6))&&(a&56?0<=(d=S(this,a,5))&&0<=P(this,d,b)&&(this.b=this.f=b<<8,this.c=0):(b&128&&(b|=65280),this.b=this.f=this.a[a&7]=b,this.c=0));break;case 40960:0<=(b=U(this,a>>6))&&0<=(c=U(this,a))&&(a=b-c,this.b=this.f=this.g=a<<8,this.c=((b^c)&(b^a))<<8);break;case 45056:0<=(b=U(this,a>>6))&&0<=(c=U(this,a))&&(this.b=this.f=(b&c)<<8,this.c=0);break;case 49152:0<=(b=U(this,a>>6))&&0<=(c=O(this,d=S(this,a,7)))&&(a=c&~b,0<=P(this,d,a)&&(this.b=this.f=a<<8,this.c=0));break;case 53248:0<=(b=U(this,
|
||||
|
|
@ -70,26 +71,26 @@ a)&&(this.f=a,this.c=0));break;case 35328:a&56?0<=(d=S(this,a,5))&&0<=P(this,d,0
|
|||
break;case 35584:0<=(c=O(this,d=S(this,a,7)))&&(a=-c,0<=P(this,d,a)&&(this.g=this.b=this.f=a<<8,this.c=(a&c)<<8));break;case 35648:0<=(c=O(this,d=S(this,a,7)))&&(a=c+(this.g>>16&1),0<=P(this,d,a)&&(this.b=this.f=this.g=a<<8,this.c=(a&(a^c))<<8));break;case 35712:0<=(c=O(this,d=S(this,a,7)))&&(a=c-(this.g>>16&1),0<=P(this,d,a)&&(this.b=this.f=this.g=a<<8,this.c=((a^c)&c)<<8));break;case 35776:0<=(c=U(this,a))&&(this.b=this.f=c<<8,this.g=this.c=0);break;case 35840:0<=(c=O(this,d=S(this,a,7)))&&(a=((this.g&
|
||||
65536)>>8|c)>>1,0<=P(this,d,a)&&(this.g=c<<16,this.b=this.f=a<<8,this.c=this.b^this.g>>1));break;case 35904:0<=(c=O(this,d=S(this,a,7)))&&(a=c<<1|this.g>>16&1,0<=P(this,d,a)&&(this.g=this.b=this.f=a<<8,this.c=(a^c)<<8));break;case 35968:0<=(c=O(this,d=S(this,a,7)))&&(a=c&128|c>>1,0<=P(this,d,a)&&(this.g=c<<16,this.b=this.f=a<<8,this.c=this.b^this.g>>1));break;case 36032:0<=(c=O(this,d=S(this,a,7)))&&(a=c<<1,0<=P(this,d,a)&&(this.g=this.b=this.f=a<<8,this.c=(a^c)<<8));break;case 36160:a&56?0<=(f=R(this,
|
||||
a,0))&&(this.j=this.i>>12&3,0<=(b=K(this,f|65536))&&(this.j=this.i>>14&3,0<=L(this,b)&&(this.b=this.f=b,this.c=0))):(e=a&7,b=6!==e||(this.i>>2&12288)===(this.i&12288)?this.a[e]:this.U[this.i>>12&3],0<=L(this,b)&&(this.b=this.f=b,this.c=0));break;case 36224:0<=(c=qb(this))&&((this.v&57344||(this.C=22),a&56)?0<=(f=R(this,a,0))&&(this.j=this.i>>12&3,0<=(d=pb(this,f|65536,4))&&(this.j=this.i>>14&3,0<=N(this,d,c)&&(this.b=this.f=c,this.c=0))):(e=a&7,6!==e||(this.i>>2&12288)===(this.i&12288)?this.a[e]=
|
||||
c:this.U[this.i>>12&3]=c,this.b=this.f=c,this.c=0));break;default:switch(a&65528){case 128:0<=(b=qb(this))&&(e=a&7,this.a[7]=this.a[e],this.a[e]=b);break;case 152:this.i&49152||(this.i=this.i&63519|(a&7)<<5,this.O=1);break;case 160:case 168:a&1&&(this.g=0);a&2&&(this.c=0);a&4&&(this.f=1);a&8&&(this.b=0);break;case 176:case 184:a&1&&(this.g=65536);a&2&&(this.c=32768);a&4&&(this.f=0);a&8&&(this.b=32768);break;default:switch(a){case 0:49152&this.i?J(this,4):(this.Ca=3,lb(this),console.log("HALT at "+
|
||||
this.a[7].toString(8)));break;case 1:e=0;if(0<(a=this.s.length))for(;0<a--;)e+=this.s[a].ya,this.s[a].ya=0;0===e&&0===this.Ca&&(this.Ca=2,lb(this));break;case 3:J(this,12);break;case 4:J(this,16);break;case 5:this.i&49152||nb(this);break;case 2:case 6:d=this.a[6];0<=(f=K(this,d|65536))&&(d=d+2&65535,0<=(b=K(this,d|65536))&&(this.a[6]=d+2&65535,b&=63743,this.i&49152&&(b=b&63519|this.i&63712),this.a[7]=f,ob(this,b),this.m&=-17,2===a&&(this.m|=this.i&16)));break;default:J(this,8)}}}}}}this.m&&(this.m&
|
||||
c:this.U[this.i>>12&3]=c,this.b=this.f=c,this.c=0));break;default:switch(a&65528){case 128:0<=(b=qb(this))&&(e=a&7,this.a[7]=this.a[e],this.a[e]=b);break;case 152:this.i&49152||(this.i=this.i&63519|(a&7)<<5,this.O=1);break;case 160:case 168:a&1&&(this.g=0);a&2&&(this.c=0);a&4&&(this.f=1);a&8&&(this.b=0);break;case 176:case 184:a&1&&(this.g=65536);a&2&&(this.c=32768);a&4&&(this.f=0);a&8&&(this.b=32768);break;default:switch(a){case 0:49152&this.i?J(this,4):(this.Da=3,lb(this),console.log("HALT at "+
|
||||
this.a[7].toString(8)));break;case 1:e=0;if(0<(a=this.s.length))for(;0<a--;)e+=this.s[a].ya,this.s[a].ya=0;0===e&&0===this.Da&&(this.Da=2,lb(this));break;case 3:J(this,12);break;case 4:J(this,16);break;case 5:this.i&49152||nb(this);break;case 2:case 6:d=this.a[6];0<=(f=K(this,d|65536))&&(d=d+2&65535,0<=(b=K(this,d|65536))&&(this.a[6]=d+2&65535,b&=63743,this.i&49152&&(b=b&63519|this.i&63712),this.a[7]=f,ob(this,b),this.m&=-17,2===a&&(this.m|=this.i&16)));break;default:J(this,8)}}}}}}this.m&&(this.m&
|
||||
2?J(this,168):this.m&4?J(this,4):this.m&16&&J(this,12),this.m=0)}while(0<this.G)}return this.h.complete?this.K-this.G:void 0===this.h.complete?0:-1};v(function(){for(var a=D(document,"pdp11","cpu"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new mb(d);C(d,c)}});
|
||||
function W(a){w.call(this,"ROM",a,W);this.b=null;this.j=a.addr;this.c=a.size;this.l=a.writable;this.f=a.alias;this.g=a.file;this.m=ba(this.g);if(this.g){a=this.g;var b=ca(this.m);"json"!=b&&"hex"!=b&&(a=p()+"/api/v1/dump?file="+this.g+"&format=bytes&decimal=true");var c=this;r(a,null,!0,function(a,b,e){rb(c,a,b,e)})}}y(W);W.prototype.ea=function(a,b,c,d){this.u=b;this.a=c;this.B=d;sb(this)};W.prototype.Y=function(){this.i&&(this.B&&this.B.a(this.id,this.j,this.c,this.i),delete this.i);return!0};
|
||||
W.prototype.X=function(){return!0};
|
||||
function rb(a,b,c,d){if(d)a.w("Unable to load system ROM (error "+d+": "+b+")");else{Ba(a.Ka,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var f=eval("("+c+")"),e=f.bytes,h=f.data;if(e)a.b=e;else if(h)for(a.b=Array(4*h.length),d=c=0;c<h.length;c++)a.b[d++]=h[c]&255,a.b[d++]=h[c]>>8&255,a.b[d++]=h[c]>>16&255,a.b[d++]=h[c]>>24&255;else a.b=f;a.i=f.symbols;if(!a.b.length){t("Empty ROM: "+b);return}if(1==a.b.length){t(a.b[0]);return}}catch(g){a.w("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
|
||||
function rb(a,b,c,d){if(d)a.w("Unable to load system ROM (error "+d+": "+b+")");else{Ba(a.La,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var f=eval("("+c+")"),e=f.bytes,h=f.data;if(e)a.b=e;else if(h)for(a.b=Array(4*h.length),d=c=0;c<h.length;c++)a.b[d++]=h[c]&255,a.b[d++]=h[c]>>8&255,a.b[d++]=h[c]>>16&255,a.b[d++]=h[c]>>24&255;else a.b=f;a.i=f.symbols;if(!a.b.length){t("Empty ROM: "+b);return}if(1==a.b.length){t(a.b[0]);return}}catch(g){a.w("ROM data error: "+g.message);return}else for(b=c.replace(/\n/gm,
|
||||
" ").replace(/ +$/,"").split(" "),a.b=Array(b.length),f=0;f<b.length;f++)a.b[f]=aa(b[f]);sb(a)}}
|
||||
function sb(a){if(!Ea(a))if(!a.g)E(a);else if(a.b&&a.u){a.c||(a.c=a.b.length);if(a.b.length!=a.c){var b="ROM size ("+n(a.b.length,8,!0)+") does not match specified size ("+n(a.c,8,!0)+")";a.h.error=!0;a.w(b)}else{b=a.j;if(Ka(a.u,b,a.c,a.l?1:Sa)){var c;for(c=0;c<a.b.length;c++){var d=a.u,f=b+c;d.b[(f&d.u)>>>d.f].Ua(f&d.m,a.b[c]&255,f)}b=!0}else b=!1;if(b){b=[];"number"==typeof a.f?b.push(a.f):null!=a.f&&a.f.length&&(b=a.f);for(c=0;c<b.length;c++){for(var e=a,d=b[c],f=e.u,h=e.c,g=[],k=e.j>>>f.f;0<h&&
|
||||
k<f.b.length;)g.push(f.b[k++]),h-=f.c;f=e.u;e=e.c;h=0;for(d>>>=f.f;0<e&&d<f.b.length;){k=g[h++];if(!k)break;f.b[d++]=k;e-=f.c}}delete a.b}}E(a)}}v(function(){for(var a=D(document,"pdp11","rom"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new W(d);C(d,c)}});function tb(a){w.call(this,"RAM",a,tb);this.f=a.addr;this.c=a.size;this.b=!1}y(tb);m=tb.prototype;m.ea=function(a,b,c,d){this.u=b;this.a=c;this.B=d;E(this)};m.Y=function(a,b){b||this.reset();return!0};m.X=function(a){return a?this.save():!0};
|
||||
m.reset=function(){!this.b&&this.c&&Ka(this.u,this.f,this.c,1)&&(this.b=!0);this.b||t("No RAM allocated")};m.save=function(){return null};m.restore=function(){return!0};v(function(){for(var a=D(document,"pdp11","ram"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new tb(d);C(d,c)}});function ub(a){w.call(this,"Keyboard",a,ub);E(this)}y(ub);ub.prototype.L=function(){return!1};ub.prototype.ea=function(a,b,c,d){this.l=a;this.a=c;this.B=d;this.Z=null};
|
||||
v(function(){for(var a=D(document,"pdp11","keyboard"),b=0;b<a.length;b++){var c=a[b],d=B(c),d=new ub(d);C(d,c)}});
|
||||
function vb(a,b,c){w.call(this,"Computer",a,vb);this.h.A=!1;wb(this,b);this.v=cb(this,"autoPower",a);this.f=0;this.I=a.busWidth||a.buswidth;this.b=X;this.m=null;this.j=this.F=!1;this.J=cb(this,"url")||"";(Math.random()+.1).toString(36);this.c=xb(this);if(this.a=Ca("CPU",this.id)){this.B=Ca("Debugger",this.id);this.u=new Ia({id:this.Ka+".bus",busWidth:this.I},this.a,this.B);var d,f=A(this.id);if((this.g=Ca("Panel",this.id))&&this.g.wa)for(b=0;b<f.length;b++)d=f[b],d.w=this.g.w,d.H=this.g.H,d.wa=this.g.wa;
|
||||
function vb(a,b,c){w.call(this,"Computer",a,vb);this.h.A=!1;wb(this,b);this.v=cb(this,"autoPower",a);this.f=0;this.I=a.busWidth||a.buswidth;this.b=X;this.m=null;this.j=this.F=!1;this.J=cb(this,"url")||"";(Math.random()+.1).toString(36);this.c=xb(this);if(this.a=Ca("CPU",this.id)){this.B=Ca("Debugger",this.id);this.u=new Ia({id:this.La+".bus",busWidth:this.I},this.a,this.B);var d,f=A(this.id);if((this.g=Ca("Panel",this.id))&&this.g.wa)for(b=0;b<f.length;b++)d=f[b],d.w=this.g.w,d.H=this.g.H,d.wa=this.g.wa;
|
||||
this.H("PDP11js v1.30.0\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");this.H("Portions adapted from the PDP-11/70 Emulator v1.3 by Paul Nankervis <paulnank@hotmail.com>");for(b=0;b<f.length;b++)d=f[b],d.ea&&d.ea(this,this.u,this.a,this.B);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.l=d:this.b=parseInt(d,10));var e;if(a=cb(this,"state")||(e=!0,a.state))b=this.C=a,e||(this.j=!0,this.b=X),this.b&&(this.s=new H(this,
|
||||
"1.30.0"),Y(this.s)?b=null:delete this.s);!b&&this.b&&(b=yb(this))&&(this.j=!0);if(b){var h=this;r(b,null,!0,function(a,b,c){c?(h.l=null,h.j=!1,h.w("Unable to load machine state from server (error "+c+(b?": "+(String.prototype.trim?b.trim():b.replace(/^\s+|\s+$/g,"")):"")+")")):(h.m=b,h.F=!0);E(h)})}else E(this);this.o.power||(this.v=!0);!c&&this.v&&zb(this,this.ia)}else t("Unable to find CPU component")}y(vb);var X=0;
|
||||
function wb(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){t(d.message+" ("+c+")")}}a.G=b}function cb(a,b,c){var d=b.toLowerCase(),d=va[b]||va[d];void 0===d&&a.G&&(d=a.G[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function zb(a,b,c){for(var d=A(a.id),f=0;f<=d.length;f++){var e=f<d.length?d[f]:a;if(!Ea(e)){Ea(e,function(){zb(a,b,c)});return}}b.call(a,c)}
|
||||
function Ab(a,b){var c=new H(a,"1.30.0","validate");if(Y(c)&&Bb(c)){var d=Z(c,"timestamp"),f=b?Z(b,"timestamp"):"unknown";d!=f&&(a.w("Machine state may be out-of-date\n("+d+" vs. "+f+")\nCheck your browser's local storage limits"),b||c.clear())}}m=vb.prototype;
|
||||
m.ia=function(a){void 0===a&&(a=this.b||(this.m?1:X));if(!this.f){this.f++;var b=!1,c=!1;this.D=!1;var d=this.s||new H(this,"1.30.0");if(-1==a)b=!0;else if(a>X){if(Y(d,this.m)){this.i=new H(this,"1.30.0","failsafe");Y(this.i)&&(Cb(this,d),a=2,Db(this.i));I(this.i,"timestamp",ga());Eb(this.i);var f=this.b&&!this.j;if(1==a||ha("Click OK to restore the previous PDP11js machine state, or CANCEL to reset the machine.")){if(c=Bb(d)){var e=Z(d,"code"),h=Z(d,"data");e&&("ok"==e?Y(d,h):("error"==e&&"no machine state"!=
|
||||
h?(this.w("Error: "+h),"unable to verify user"==h&&(la("user",""),this.c=null)):this.H(e+": "+h),Db(d),Y(d)?(c=Bb(d),f=!0):c=!1))}f&&Ab(this,c?d:null)}else 2==a&&d.clear()}else Ab(this);delete this.m;delete this.s}f=A(this.id);for(e=0;e<f.length;e++)h=f[e],h!==this&&h!=this.a&&(c=Fb(this,h,d,b,c));b=[d,a,c];-1!=a?zb(this,this.Ga,b):this.Ga(b)}};
|
||||
function Fb(a,b,c,d,f){if(!b.h.A){b.h.A=!0;if(b.Y){var e=null;f&&((e=Z(c,b.id))||(e=Z(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof e&&(e=null);!b.Y(e,d)&&e&&(t("Unable to restore state for "+b.type),a.C&&!a.F?(c.clear(),a.b=X,window&&window.location.reload()):a.D=!0,b.Y(null),f=!1)}if(!d&&b.Ja)for(a=b.Ja.split("|"),c=0;c<a.length;c++)b.status(a[c])}return f}
|
||||
m.Ga=function(a){var b=a[0],c=0>a[1];a=a[2];this.K=!0;this.h.A=!0;var d=this.o.power;d&&(d.textContent="Shutdown");this.a&&(Fb(this,this.a,b,c,a),this.a.ga());this.D&&(Cb(this,b),b.clear());!c&&this.i&&(this.i.clear(),delete this.i);this.f=0};
|
||||
h?(this.w("Error: "+h),"unable to verify user"==h&&(la("user",""),this.c=null)):this.H(e+": "+h),Db(d),Y(d)?(c=Bb(d),f=!0):c=!1))}f&&Ab(this,c?d:null)}else 2==a&&d.clear()}else Ab(this);delete this.m;delete this.s}f=A(this.id);for(e=0;e<f.length;e++)h=f[e],h!==this&&h!=this.a&&(c=Fb(this,h,d,b,c));b=[d,a,c];-1!=a?zb(this,this.Ha,b):this.Ha(b)}};
|
||||
function Fb(a,b,c,d,f){if(!b.h.A){b.h.A=!0;if(b.Y){var e=null;f&&((e=Z(c,b.id))||(e=Z(c,b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof e&&(e=null);!b.Y(e,d)&&e&&(t("Unable to restore state for "+b.type),a.C&&!a.F?(c.clear(),a.b=X,window&&window.location.reload()):a.D=!0,b.Y(null),f=!1)}if(!d&&b.Ka)for(a=b.Ka.split("|"),c=0;c<a.length;c++)b.status(a[c])}return f}
|
||||
m.Ha=function(a){var b=a[0],c=0>a[1];a=a[2];this.K=!0;this.h.A=!0;var d=this.o.power;d&&(d.textContent="Shutdown");this.a&&(Fb(this,this.a,b,c,a),this.a.ga());this.D&&(Cb(this,b),b.clear());!c&&this.i&&(this.i.clear(),delete this.i);this.f=0};
|
||||
function Cb(a,b){if(ha("There may be a problem with your PDP11js machine.\n\nTo help us diagnose it, click OK to send this PDP11js machine state to http://www.pcjs.org.")){var c=a.c||"",d=b.toString(),f={app:"PDP11js",ver:"1.30.0"};f.url=a.J;f.user=c;f.type="bug";f.data=d;r("http://www.pcjs.org/api/v1/report",f,!0)}}
|
||||
function Gb(a,b,c){var d,f="none";if(a.f)return null;a.f--;var e=new H(a,"1.30.0"),h=new H(a,"1.30.0","validate"),g=ga();I(h,"timestamp",g);I(e,"timestamp",g);I(e,"version","1.30.0");I(e,"url",window?window.location.href:null);I(e,"browser",window?window.navigator.userAgent:"");a.a&&a.a.X&&(c&&G(a.a),d=a.a.X(b,c),"object"===typeof d&&I(e,a.a.id,d),c&&(a.a.h.A=!1,!1===d&&(f=null)));for(var g=A(a.id),k=0;k<g.length;k++){var l=g[k];l.h.A&&(l.X&&(d=l.X(b,c),"object"===typeof d&&I(e,l.id,d)),c&&(l.h.A=
|
||||
!1,!1===d&&(f=null)))}f&&(c?(g=d=!1,b?(a.c&&Hb(a,a.c,e.toString()),Eb(h)&&Eb(e)||(f=null,d=g=!0)):a.b&&(d=!0,g=3==a.b),d&&e.clear(g)):f=e.toString());c&&(a.h.A=!1,b=a.o.power)&&(b.textContent="Power");a.f=0;return f}m.reset=function(){this.u&&this.u.reset&&this.u.reset();for(var a=A(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.u&&c.reset&&c.reset()}};m.start=function(a,b){for(var c=A(this.id),d=0;d<c.length;d++){var f=c[d];"CPU"!=f.type&&f!==this&&f.start&&f.start(a,b)}};
|
||||
|
|
|
|||
Loading…
Reference in a new issue