From 8315774b1db3131b334049a3c3894c8b5a487257 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Tue, 11 Oct 2016 16:08:32 -0700 Subject: [PATCH] Implemented a fallback fix for UNIBUS addresses where a byte write is expected to modify the entire word --- modules/pdp11/lib/bus.js | 10 +++++++--- modules/pdp11/lib/device.js | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/pdp11/lib/bus.js b/modules/pdp11/lib/bus.js index cc8e7a29a..ea55b9eff 100644 --- a/modules/pdp11/lib/bus.js +++ b/modules/pdp11/lib/bus.js @@ -307,7 +307,7 @@ BusPDP11.IOController = { var afn = bus.aIOHandlers[off]; if (afn) { /* - * If a writeByte() handler exists, call it; we're done + * If a writeByte() handler exists, call it; we're done. */ if (afn[BusPDP11.IOHANDLER.WRITE_BYTE]) { afn[BusPDP11.IOHANDLER.WRITE_BYTE](b, addr); @@ -316,9 +316,13 @@ BusPDP11.IOController = { /* * If a writeWord() handler exists, call the readWord() handler first to get the original data, * then call writeWord() with the new data pre-inserted in the original data. + * + * WARNING: Whenever we call readWord() under these circumstances, we zero the address parameter, + * so that the handler can distinguish this case. Thus, if we're dealing with a special register + * where a byte write operation modifies the entire register, the handler can simply return zero. */ else if (afn[BusPDP11.IOHANDLER.WRITE_WORD]) { - w = afn[BusPDP11.IOHANDLER.READ_WORD]? afn[BusPDP11.IOHANDLER.READ_WORD](addr) : 0; + w = afn[BusPDP11.IOHANDLER.READ_WORD]? afn[BusPDP11.IOHANDLER.READ_WORD](0) : 0; if (!(addr & 0x1)) { afn[BusPDP11.IOHANDLER.WRITE_WORD]((w & ~0xff) | b, addr); fWrite = true; @@ -337,7 +341,7 @@ BusPDP11.IOController = { if (afn) { if (afn[BusPDP11.IOHANDLER.WRITE_WORD]) { addr &= ~0x1; - w = afn[BusPDP11.IOHANDLER.READ_WORD]? afn[BusPDP11.IOHANDLER.READ_WORD](addr) : 0; + w = afn[BusPDP11.IOHANDLER.READ_WORD]? afn[BusPDP11.IOHANDLER.READ_WORD](0) : 0; afn[BusPDP11.IOHANDLER.WRITE_WORD]((w & 0xff) | (b << 8), addr); fWrite = true; } diff --git a/modules/pdp11/lib/device.js b/modules/pdp11/lib/device.js index 4075c19e7..8e2c4d877 100644 --- a/modules/pdp11/lib/device.js +++ b/modules/pdp11/lib/device.js @@ -918,6 +918,7 @@ DevicePDP11.prototype.writeMB = function(data, addr) */ DevicePDP11.prototype.readPIR = function(addr) { + if (!addr) return 0; // the caller is preparing to write the low or high byte; these are the bits to return for the other byte return this.cpu.getPIR(); }; @@ -942,6 +943,7 @@ DevicePDP11.prototype.writePIR = function(data, addr) */ DevicePDP11.prototype.readSL = function(addr) { + if (!addr) return 0; // the caller is preparing to write the low or high byte; these are the bits to return for the other byte return this.cpu.getSL(); };