Internal PSW getter/setter are now getPSW/setPSW

This commit is contained in:
Jeff 2016-09-22 08:03:43 -07:00 committed by Jeff Parsons
commit 122ca78fd5
5 changed files with 301 additions and 317 deletions

View file

@ -104,7 +104,7 @@ function BusPDP11(parmsBus, cpu, dbg)
this.assert(this.nBlockMask <= BusPDP11.BlockInfo.num.mask);
/*
* aIONotify is an array (ie, a hash) of I/O notification handlers, indexed by address, where each
* aIOHandlers is an array (ie, a hash) of I/O notification handlers, indexed by address, where each
* entry contains an array:
*
* [0]: readByte(addr)
@ -126,7 +126,7 @@ function BusPDP11(parmsBus, cpu, dbg)
* The false case is important if fIOBreakAll is set, because it allows the Debugger to selectively
* ignore specific addresses.
*/
this.aIONotify = [];
this.aIOHandlers = [];
this.fIOBreakAll = false;
this.fnReset = null;
@ -170,7 +170,7 @@ BusPDP11.ERROR = {
*
* TODO: Another small potential improvement would be for addIOHandlers() to predefine fall-backs for all
* missing handlers, so there's never a need to check each entry (eg, afn[0], afn[1], etc) before calling
* it. However, since there's no avoiding checking afn itself (unless we FULLY populate the aIONotify
* it. However, since there's no avoiding checking afn itself (unless we FULLY populate the aIOHandlers
* array), and since these I/O accesses should be pretty infrequent relative to all other memory accesses,
* the benefit seems pretty minimal.
*/
@ -186,7 +186,7 @@ BusPDP11.controller = {
*/
readIOPageByte: function(off, addr)
{
var afn = this.controller.aIONotify[off];
var afn = this.controller.aIOHandlers[off];
if (afn) {
if (afn[0]) {
return afn[0](addr);
@ -198,7 +198,7 @@ BusPDP11.controller = {
}
}
} else if (addr & 0x1) {
afn = this.controller.aIONotify[off & ~0x1];
afn = this.controller.aIOHandlers[off & ~0x1];
if (afn[2]) {
return afn[2](addr & ~0x1) >> 8;
}
@ -217,7 +217,7 @@ BusPDP11.controller = {
writeIOPageByte: function(off, b, addr)
{
var w;
var afn = this.controller.aIONotify[off];
var afn = this.controller.aIOHandlers[off];
if (afn) {
if (afn[1]) {
afn[1](b, addr);
@ -232,7 +232,7 @@ BusPDP11.controller = {
return;
}
} else if (addr & 0x1) {
afn = this.controller.aIONotify[off & ~0x1];
afn = this.controller.aIOHandlers[off & ~0x1];
if (afn[3]) {
addr &= ~0x1;
w = afn[2]? afn[2](addr) : 0;
@ -254,7 +254,7 @@ BusPDP11.controller = {
readIOPageShort: function(off, addr)
{
Component.assert(!(addr & 1)); // unaligned addresses should be getting trapped at a higher level
var afn = this.controller.aIONotify[off];
var afn = this.controller.aIOHandlers[off];
if (afn) {
if (afn[2]) {
return afn[2](addr);
@ -276,7 +276,7 @@ BusPDP11.controller = {
writeIOPageShort: function(off, w, addr)
{
Component.assert(!(addr & 1)); // unaligned addresses should be getting trapped at a higher level
var afn = this.controller.aIONotify[off];
var afn = this.controller.aIOHandlers[off];
if (afn) {
if (afn[3]) {
afn[3](w, addr);
@ -943,7 +943,7 @@ BusPDP11.prototype.restoreMemory = function(a)
/**
* addIOHandlers(start, end, fnReadByte, fnWriteByte, fnReadShort, fnWriteShort)
*
* Add I/O notification handlers to the master list (aIONotify). The start and end addresses are typically
* Add I/O notification handlers to the master list (aIOHandlers). The start and end addresses are typically
* relative to the starting IOPAGE address, but they can also be absolute; we simply mask all addresses with
* IOPAGE_MASK.
*
@ -959,11 +959,11 @@ BusPDP11.prototype.addIOHandlers = function(start, end, fnReadByte, fnWriteByte,
{
for (var addr = start; addr <= end; addr += 2) {
var off = addr & BusPDP11.IOPAGE_MASK;
if (this.aIONotify[off] !== undefined) {
if (this.aIOHandlers[off] !== undefined) {
Component.warning("I/O address already registered: " + str.toHexLong(this.addrIOPage + off));
continue;
}
this.aIONotify[off] = [fnReadByte, fnWriteByte, fnReadShort, fnWriteShort, false];
this.aIOHandlers[off] = [fnReadByte, fnWriteByte, fnReadShort, fnWriteShort, false];
if (MAXDEBUG) this.log("addIOHandlers(" + str.toHexLong(this.addrIOPage + off) + ")");
}
};

View file

@ -457,17 +457,6 @@ CPUStatePDP11.prototype.setPC = function(addr)
this.regsGen[7] = addr;
};
/**
* getPSW()
*
* @this {CPUStatePDP11}
* @return {number}
*/
CPUStatePDP11.prototype.getPSW = function()
{
return (this.PSW & ~PDP11.PSW.FLAGS) | (this.getNF() | this.getZF() | this.getVF() | this.getCF());
};
/**
* getSP()
*
@ -583,13 +572,20 @@ CPUStatePDP11.prototype.interrupt = function(delay, priority, vector, callback)
};
/**
* readPSW()
* getPSW()
*
* @this {CPUStatePDP11}
* @return {number}
*/
CPUStatePDP11.prototype.readPSW = function()
CPUStatePDP11.prototype.getPSW = function()
{
/*
* I'm not sure why this function can't simply be written as:
*
* return (this.PSW & ~PDP11.PSW.FLAGS) | (this.getNF() | this.getZF() | this.getVF() | this.getCF());
*
* but for now, I'm keeping the same masking logic as pdp11.js.
*/
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();
};
@ -640,20 +636,6 @@ CPUStatePDP11.prototype.setPSW = function(newPSW)
this.PSW = newPSW;
};
/**
* writePSW(newPSW)
*
* This is a stricter version of setPSW(), used for writes to ADDR_PSW, which preserves bits that
* should not be overwritten.
*
* @this {CPUStatePDP11}
* @param {number} newPSW
*/
CPUStatePDP11.prototype.writePSW = function(newPSW)
{
this.setPSW((newPSW & 0xf8ef) | (this.PSW & 0x0710));
};
/**
* panic(reason)
*
@ -684,7 +666,7 @@ CPUStatePDP11.prototype.trap = function(vector, reason)
{
var newPC, newPSW, doubleTrap = 0;
if (this.trapPSW < 0) {
this.trapPSW = this.readPSW();
this.trapPSW = this.getPSW();
} else {
if (!this.mmuMode) {
vector = 4;
@ -2261,7 +2243,7 @@ CPUStatePDP11.prototype.stepCPU = function(nMinCycles)
break;
//case 0106700: // MTFS 1064SS
// //LOG_INSTRUCTION(instruction, 1, "MFPS");
// src = this.readPSW() & 0xff;
// src = this.getPSW() & 0xff;
// if (instruction & 0x38) {
// if ((dstAddr = this.getAddrByMode(instruction, PDP11.WRITE_MODE | PDP11.BYTE_MODE)) >= 0) { // write byte
// if (this.writeByteByAddr(dstAddr, src) >= 0) {

View file

@ -210,7 +210,7 @@ DevicePDP11.prototype.initBus = function(cmp, bus, cpu, dbg)
*/
DevicePDP11.prototype.readPSW = function(addr)
{
return this.cpu.readPSW();
return this.cpu.getPSW();
};
/**
@ -231,7 +231,8 @@ DevicePDP11.prototype.writePSW = function(data, addr)
* special one-time opcode flag is set. Because there are a number of arithmetic instructions besides
* CLR that could be used to modify ADDR_PSW.
*/
this.cpu.writePSW(data);
var maskDisallowed = PDP11.PSW.UNUSED | PDP11.PSW.TF;
this.cpu.setPSW((data & ~maskDisallowed) | (this.cpu.getPSW() & maskDisallowed));
};
/**
@ -854,14 +855,15 @@ DevicePDP11.prototype.access = function(physicalAddress, data, byteFlag)
* as it is replaced by read/write handlers in the UNIBUS_TABLE; stay tuned).
*
case 0x3FFFFE: // 017777776 // PSW
result = cpu.readPSW();
result = cpu.getPSW();
if (data >= 0) {
if (physicalAddress & 1) {
data = (data << 8) | (result & 0xff);
} else {
if (byteFlag) data = (result & 0xff00) | (data & 0xff);
}
cpu.writePSW(data);
data = (data & 0xf8ef) | (result & 0x0710);
cpu.setPSW(data);
return -1; // KLUDGE - no trap but abort any CC updates
}
break;