Started centralizing the set of UNIBUS addresses, and adopted my first ES6 feature: octal constants (not the old-fashioned unofficial leading-zero kind, but the new "0o" kind); I will still use hex instead of octal whenever I can, but UNIBUS addresses are ALWAYS documented as octal, so I'm giving in....

This commit is contained in:
Jeff 2016-09-24 16:44:42 -07:00 committed by Jeff Parsons
commit 63b0c9c02c
3 changed files with 23 additions and 16 deletions

View file

@ -615,8 +615,8 @@ CPUStatePDP11.prototype.setPSW = function(newPSW)
this.regsAlt[i] = tmp;
}
}
this.mmuMode = (newPSW >> PDP11.PSW.CMODE_SHIFT) & PDP11.MODE.MASK;
var oldMode = (this.PSW >> PDP11.PSW.CMODE_SHIFT) & PDP11.MODE.MASK;
this.mmuMode = (newPSW >> PDP11.PSW.SHIFT.CMODE) & PDP11.MODE.MASK;
var oldMode = (this.PSW >> PDP11.PSW.SHIFT.CMODE) & PDP11.MODE.MASK;
if (this.mmuMode != oldMode) {
/*
* Swap stack pointers

View file

@ -137,23 +137,25 @@ var PDP11 = {
*/
PSW: {
CF: 0x0001, // bit 0: Carry Flag
CF_SHIFT: 0,
VF: 0x0002, // bit 1: Overflow Flag (aka OF on Intel processors)
VF_SHIFT: 1,
ZF: 0x0004, // bit 2: Zero 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: Prev Mode (see PDP11.MODE)
PMODE_SHIFT: 12,
CMODE: 0xC000, // bits 14-15: Curr Mode (see PDP11.MODE)
CMODE_SHIFT: 14
SHIFT: {
CF: 0,
VF: 1,
ZF: 2,
NF: 3,
TF: 4,
PRI: 5,
PMODE: 12,
CMODE: 14
}
},
/*
* Interrupt-related flags (stored in intFlags)
@ -236,9 +238,15 @@ var PDP11 = {
},
/*
* Assorted special (UNIBUS) addresses
*
* ES6 ALERT: By using octal constants, this is the first place I'm dipping my toe into ECMAScript 6 waters.
* If you're loading this raw source code into your browser, then by now (2016) you're almost certainly using
* an ES6-aware browser. Everyone else should be using code compiled by Google's Closure Compiler, which
* automatically produces code that's backward-compatible with ES5.1 (for example, octal constants are converted
* to decimal values).
*/
UNIBUS: {
PSW: 0o177776
UNIBUS: { // 22-bit 18-bit 16-bit 22-bit Description
PSW: 0o17777776, // 777776 177776 0x3FFFFE PSW
}
};

View file

@ -140,7 +140,6 @@ function DevicePDP11(parmsDevice)
Component.subclass(DevicePDP11);
DevicePDP11.UNIBUS_NAME = "unibus";
DevicePDP11.ADDR_PSW = 0x3FFFFE; /*017777776*/ // PSW
DevicePDP11.M9312 = [
0x101F, /*0010037*/ 0x1C0, /*0000700*/ 0x105F, /*0010137*/ 0x1C2, /*0000702*/ 0x111F, /*0010437*/ 0x1C4, /*0000704*/ 0xA1F, /*0005037*/ 0x1C6, /*0000706*/
@ -205,7 +204,7 @@ DevicePDP11.prototype.initBus = function(cmp, bus, cpu, dbg)
* readPSW(addr)
*
* @this {DevicePDP11}
* @param {number} addr (ie, ADDR_PSW)
* @param {number} addr (ie, PDP11.UNIBUS.PSW)
* @return {number}
*/
DevicePDP11.prototype.readPSW = function(addr)
@ -218,7 +217,7 @@ DevicePDP11.prototype.readPSW = function(addr)
*
* @this {DevicePDP11}
* @param {number} data
* @param {number} addr (ie, ADDR_PSW)
* @param {number} addr (ie, PDP11.UNIBUS.PSW)
*/
DevicePDP11.prototype.writePSW = function(data, addr)
{
@ -1407,7 +1406,7 @@ DevicePDP11.prototype.access = function(physicalAddress, data, byteFlag)
};
DevicePDP11.UNIBUS_TABLE = {};
DevicePDP11.UNIBUS_TABLE[DevicePDP11.ADDR_PSW] = [null, null, DevicePDP11.prototype.readPSW, DevicePDP11.prototype.writePSW];
DevicePDP11.UNIBUS_TABLE[PDP11.UNIBUS.PSW] = [null, null, DevicePDP11.prototype.readPSW, DevicePDP11.prototype.writePSW];
/**
* DevicePDP11.init()