Implemented a fallback fix for UNIBUS addresses where a byte write is expected to modify the entire word

This commit is contained in:
Jeff Parsons 2016-10-11 16:08:32 -07:00 committed by Jeff Parsons
commit 8315774b1d
2 changed files with 9 additions and 3 deletions

View file

@ -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;
}

View file

@ -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();
};