More register refactoring (no logic changes, so hopefully nothing broken)

This commit is contained in:
Jeff Parsons 2016-11-30 13:04:02 -08:00 committed by Jeff Parsons
commit f8bc528de3
5 changed files with 495 additions and 495 deletions

View file

@ -75,8 +75,8 @@ function PC11(parms)
this.cAutoMount = 0;
this.nBaudReceive = parms['baudReceive'] || PDP11.PC11.PRS.BAUD;
this.prs = 0; // PRS register
this.prb = 0; // PRB register
this.regPRS = 0; // PRS register
this.regPRB = 0; // PRB register
this.iTapeData = 0; // buffer index
this.aTapeData = []; // buffer for the PRB register
this.sTapeSource = PC11.SOURCE.NONE;
@ -339,8 +339,8 @@ PC11.prototype.powerDown = function(fSave, fShutdown)
*/
PC11.prototype.reset = function()
{
this.prs &= ~PDP11.PC11.PRS.CLEAR;
this.prb = 0;
this.regPRS &= ~PDP11.PC11.PRS.CLEAR;
this.regPRB = 0;
};
/**
@ -806,8 +806,8 @@ PC11.prototype.getBaudTimeout = function(nBaud)
*/
PC11.prototype.advanceReader = function()
{
if ((this.prs & (PDP11.PC11.PRS.RE | PDP11.PC11.PRS.ERROR)) == PDP11.PC11.PRS.RE) {
if (!(this.prs & PDP11.PC11.PRS.DONE)) {
if ((this.regPRS & (PDP11.PC11.PRS.RE | PDP11.PC11.PRS.ERROR)) == PDP11.PC11.PRS.RE) {
if (!(this.regPRS & PDP11.PC11.PRS.DONE)) {
if (this.iTapeData < this.aTapeData.length) {
/*
* Here, as elsewhere (eg, the DL11 component), even if I trusted all incoming data
@ -815,11 +815,11 @@ PC11.prototype.advanceReader = function()
* (eg, -128 to 127, instead of 0 to 255). Both risks are good reasons to always mask
* the data assigned to PRB with 0xff.
*/
this.prb = this.aTapeData[this.iTapeData++] & 0xff;
this.regPRB = this.aTapeData[this.iTapeData++] & 0xff;
this.displayProgress(this.iTapeData / this.aTapeData.length * 100);
this.prs |= PDP11.PC11.PRS.DONE;
this.prs &= ~PDP11.PC11.PRS.BUSY;
if (this.prs & PDP11.PC11.PRS.RIE) {
this.regPRS |= PDP11.PC11.PRS.DONE;
this.regPRS &= ~PDP11.PC11.PRS.BUSY;
if (this.regPRS & PDP11.PC11.PRS.RIE) {
this.cpu.setIRQ(this.irqReader);
}
}
@ -841,7 +841,7 @@ PC11.prototype.advanceReader = function()
*/
PC11.prototype.readPRS = function(addr)
{
return this.prs & PDP11.PC11.PRS.RMASK; // RMASK honors the "write-only" nature of the RE bit by returning zero on reads
return this.regPRS & PDP11.PC11.PRS.RMASK; // RMASK honors the "write-only" nature of the RE bit by returning zero on reads
};
/**
@ -861,15 +861,15 @@ PC11.prototype.writePRS = function(data, addr)
* sets Busy, and clears the Reader Buffer (PRB). Operation of this bit is disabled if Error = 1;
* attempting to set it when Error = 1 will cause an immediate interrupt if Interrupt Enable = 1.
*/
if (this.prs & PDP11.PC11.PRS.ERROR) {
if (this.regPRS & PDP11.PC11.PRS.ERROR) {
data &= ~PDP11.PC11.PRS.RE;
if (this.prs & PDP11.PC11.PRS.RIE) {
if (this.regPRS & PDP11.PC11.PRS.RIE) {
this.cpu.setIRQ(this.irqReader);
}
} else {
this.prs &= ~PDP11.PC11.PRS.DONE;
this.prs |= PDP11.PC11.PRS.BUSY;
this.prb = 0;
this.regPRS &= ~PDP11.PC11.PRS.DONE;
this.regPRS |= PDP11.PC11.PRS.BUSY;
this.regPRB = 0;
/*
* The PC11, by virtue of its "high speed", is supposed to deliver characters at 300 CPS, so
* that's the rate we'll choose as well (ie, 1000ms / 300). As an aside, the original "low speed"
@ -878,7 +878,7 @@ PC11.prototype.writePRS = function(data, addr)
this.cpu.setTimer(this.timerReader, this.getBaudTimeout(this.nBaudReceive));
}
}
this.prs = (this.prs & ~PDP11.PC11.PRS.WMASK) | (data & PDP11.PC11.PRS.WMASK);
this.regPRS = (this.regPRS & ~PDP11.PC11.PRS.WMASK) | (data & PDP11.PC11.PRS.WMASK);
};
/**
@ -894,9 +894,9 @@ PC11.prototype.readPRB = function(addr)
* I'm guessing that the DONE and BUSY bits always remain more-or-less inverses of each other. They definitely
* start out that way when writePRS() sets the reader enable (RE) bit, and so that's how we treat them elsewhere, too.
*/
this.prs &= ~PDP11.PC11.PRS.DONE;
this.prs |= PDP11.PC11.PRS.BUSY;
return this.prb;
this.regPRS &= ~PDP11.PC11.PRS.DONE;
this.regPRS |= PDP11.PC11.PRS.BUSY;
return this.regPRB;
};
/**

View file

@ -817,13 +817,13 @@ RK11.prototype.initController = function(data)
{
var i = 0;
if (!data) data = [];
this.dsr = data[i++] || (PDP11.RK11.RKDS.RK05 | PDP11.RK11.RKDS.SOK | PDP11.RK11.RKDS.DRDY | PDP11.RK11.RKDS.RRDY);
this.err = data[i++] || 0;
this.csr = data[i++] || (PDP11.RK11.RKCS.CRDY);
this.wcr = data[i++] || 0;
this.bar = data[i++] || 0;
this.dar = data[i++] || 0;
this.dbr = data[i] || 0; // TODO: Determine if there's anything we should be doing to the RKDB register
this.regRKDS = data[i++] || (PDP11.RK11.RKDS.RK05 | PDP11.RK11.RKDS.SOK | PDP11.RK11.RKDS.DRDY | PDP11.RK11.RKDS.RRDY);
this.regRKER = data[i++] || 0;
this.regRKCS = data[i++] || (PDP11.RK11.RKCS.CRDY);
this.regRKWC = data[i++] || 0;
this.regRKBA = data[i++] || 0;
this.regRKDA = data[i++] || 0;
this.regRKDB = data[i] || 0; // TODO: Determine if there's anything we should be doing to the RKDB register
var fSuccess = true;
for (var iDrive = 0; iDrive < this.aDrives.length; iDrive++) {
@ -901,19 +901,19 @@ RK11.prototype.processCommand = function()
{
var fnReadWrite;
var fInterrupt = true;
var iDrive = (this.dar & PDP11.RK11.RKDA.DS) >> PDP11.RK11.RKDA.SHIFT.DS;
var iDrive = (this.regRKDA & PDP11.RK11.RKDA.DS) >> PDP11.RK11.RKDA.SHIFT.DS;
var drive = this.aDrives[iDrive];
var iCylinder, iHead, iSector, nWords, addr;
this.csr &= ~PDP11.RK11.RKCS.CRDY;
this.regRKCS &= ~PDP11.RK11.RKCS.CRDY;
switch(this.csr & PDP11.RK11.RKCS.FUNC) {
switch(this.regRKCS & PDP11.RK11.RKCS.FUNC) {
case PDP11.RK11.FUNC.CRESET:
this.dsr = drive.status;
this.err = 0;
this.csr = PDP11.RK11.RKCS.CRDY;
this.dar = 0;
this.regRKDS = drive.status;
this.regRKER = 0;
this.regRKCS = PDP11.RK11.RKCS.CRDY;
this.regRKDA = 0;
break;
case PDP11.RK11.FUNC.READ:
@ -922,21 +922,21 @@ RK11.prototype.processCommand = function()
case PDP11.RK11.FUNC.WRITE:
if (!fnReadWrite) fnReadWrite = this.writeData;
iCylinder = (this.dar & PDP11.RK11.RKDA.CA) >> PDP11.RK11.RKDA.SHIFT.CA;
iHead = (this.dar & PDP11.RK11.RKDA.HS) >> PDP11.RK11.RKDA.SHIFT.HS;
iSector = this.dar & PDP11.RK11.RKDA.SA;
iCylinder = (this.regRKDA & PDP11.RK11.RKDA.CA) >> PDP11.RK11.RKDA.SHIFT.CA;
iHead = (this.regRKDA & PDP11.RK11.RKDA.HS) >> PDP11.RK11.RKDA.SHIFT.HS;
iSector = this.regRKDA & PDP11.RK11.RKDA.SA;
if (iCylinder >= drive.nCylinders) {
this.err |= PDP11.RK11.RKER.DRE | PDP11.RK11.RKER.NXC;
this.csr |= PDP11.RK11.RKCS.HE | PDP11.RK11.RKCS.ERR;
this.regRKER |= PDP11.RK11.RKER.DRE | PDP11.RK11.RKER.NXC;
this.regRKCS |= PDP11.RK11.RKCS.HE | PDP11.RK11.RKCS.ERR;
break;
}
if (iSector >= drive.nSectors) {
this.err |= PDP11.RK11.RKER.DRE | PDP11.RK11.RKER.NXS;
this.csr |= PDP11.RK11.RKCS.HE | PDP11.RK11.RKCS.ERR;
this.regRKER |= PDP11.RK11.RKER.DRE | PDP11.RK11.RKER.NXS;
this.regRKCS |= PDP11.RK11.RKCS.HE | PDP11.RK11.RKCS.ERR;
break;
}
addr = (((this.csr & PDP11.RK11.RKCS.MEX)) << (16 - PDP11.RK11.RKCS.SHIFT.MEX)) | this.bar;
nWords = (0x10000 - this.wcr) & 0xffff;
addr = (((this.regRKCS & PDP11.RK11.RKCS.MEX)) << (16 - PDP11.RK11.RKCS.SHIFT.MEX)) | this.regRKBA;
nWords = (0x10000 - this.regRKWC) & 0xffff;
if (DEBUG && (this.messageEnabled(MessagesPDP11.READ) || this.messageEnabled(MessagesPDP11.WRITE))) {
var pos = ((((iCylinder << 1) + iHead) * drive.nSectors) + iSector) * 256;
console.log((fnReadWrite == this.readData? "readData" : "writeData") + "(pos=" + pos + ",addr=" + str.toOct(addr) + ",bytes=" + (nWords * 2) + ")");
@ -949,14 +949,14 @@ RK11.prototype.processCommand = function()
}
/*
* TODO: Determine what's up with the "dar % 9"....
* TODO: Determine what's up with the "regRKDA % 9"....
*/
this.dsr = drive.status | (iDrive << PDP11.RK11.RKDS.SHIFT.ID) | ((this.dar % 9) & PDP11.RK11.RKDS.SC);
this.regRKDS = drive.status | (iDrive << PDP11.RK11.RKDS.SHIFT.ID) | ((this.regRKDA % 9) & PDP11.RK11.RKDS.SC);
if (fInterrupt) {
this.csr &= ~PDP11.RK11.RKCS.GO;
this.csr |= PDP11.RK11.RKCS.CRDY;
if (this.csr & PDP11.RK11.RKCS.IE) this.cpu.setIRQ(this.irq);
this.regRKCS &= ~PDP11.RK11.RKCS.GO;
this.regRKCS |= PDP11.RK11.RKCS.CRDY;
if (this.regRKCS & PDP11.RK11.RKCS.IE) this.cpu.setIRQ(this.irq);
}
};
@ -974,12 +974,12 @@ RK11.prototype.processCommand = function()
*/
RK11.prototype.endReadWrite = function(err, iCylinder, iHead, iSector, nWords, addr)
{
this.bar = addr & 0xffff;
this.csr = (this.csr & ~PDP11.RK11.RKCS.MEX) | ((addr >> (16 - PDP11.RK11.RKCS.SHIFT.MEX)) & PDP11.RK11.RKCS.MEX);
this.wcr = (0x10000 - nWords) & 0xffff;
this.regRKBA = addr & 0xffff;
this.regRKCS = (this.regRKCS & ~PDP11.RK11.RKCS.MEX) | ((addr >> (16 - PDP11.RK11.RKCS.SHIFT.MEX)) & PDP11.RK11.RKCS.MEX);
this.regRKWC = (0x10000 - nWords) & 0xffff;
if (err) {
this.err |= err | PDP11.RK11.RKER.DRE;
this.csr |= PDP11.RK11.RKCS.HE | PDP11.RK11.RKCS.ERR;
this.regRKER |= err | PDP11.RK11.RKER.DRE;
this.regRKCS |= PDP11.RK11.RKCS.HE | PDP11.RK11.RKCS.ERR;
}
return true;
};
@ -1123,7 +1123,7 @@ RK11.prototype.writeData = function(drive, iCylinder, iHead, iSector, nWords, ad
*/
RK11.prototype.readRKDS = function(addr)
{
return this.dsr;
return this.regRKDS;
};
/**
@ -1149,7 +1149,7 @@ RK11.prototype.writeRKDS = function(data, addr)
*/
RK11.prototype.readRKER = function(addr)
{
return this.err;
return this.regRKER;
};
/**
@ -1175,7 +1175,7 @@ RK11.prototype.writeRKER = function(data, addr)
*/
RK11.prototype.readRKCS = function(addr)
{
return this.csr & PDP11.RK11.RKCS.RMASK;
return this.regRKCS & PDP11.RK11.RKCS.RMASK;
};
/**
@ -1187,9 +1187,9 @@ RK11.prototype.readRKCS = function(addr)
*/
RK11.prototype.writeRKCS = function(data, addr)
{
this.csr = (this.csr & ~PDP11.RK11.RKCS.WMASK) | (data & PDP11.RK11.RKCS.WMASK);
this.regRKCS = (this.regRKCS & ~PDP11.RK11.RKCS.WMASK) | (data & PDP11.RK11.RKCS.WMASK);
if (this.csr & PDP11.RK11.RKCS.GO) this.processCommand();
if (this.regRKCS & PDP11.RK11.RKCS.GO) this.processCommand();
};
/**
@ -1201,7 +1201,7 @@ RK11.prototype.writeRKCS = function(data, addr)
*/
RK11.prototype.readRKWC = function(addr)
{
return this.wcr;
return this.regRKWC;
};
/**
@ -1213,7 +1213,7 @@ RK11.prototype.readRKWC = function(addr)
*/
RK11.prototype.writeRKWC = function(data, addr)
{
this.wcr = data;
this.regRKWC = data;
};
/**
@ -1225,7 +1225,7 @@ RK11.prototype.writeRKWC = function(data, addr)
*/
RK11.prototype.readRKBA = function(addr)
{
return this.bar;
return this.regRKBA;
};
/**
@ -1237,7 +1237,7 @@ RK11.prototype.readRKBA = function(addr)
*/
RK11.prototype.writeRKBA = function(data, addr)
{
this.bar = data;
this.regRKBA = data;
};
/**
@ -1249,7 +1249,7 @@ RK11.prototype.writeRKBA = function(data, addr)
*/
RK11.prototype.readRKDA = function(addr)
{
return this.dar;
return this.regRKDA;
};
/**
@ -1261,7 +1261,7 @@ RK11.prototype.readRKDA = function(addr)
*/
RK11.prototype.writeRKDA = function(data, addr)
{
this.dar = data;
this.regRKDA = data;
};
/**
@ -1273,7 +1273,7 @@ RK11.prototype.writeRKDA = function(data, addr)
*/
RK11.prototype.readRKDB = function(addr)
{
return this.dbr;
return this.regRKDB;
};
/**
@ -1285,7 +1285,7 @@ RK11.prototype.readRKDB = function(addr)
*/
RK11.prototype.writeRKDB = function(data, addr)
{
this.dbr = data;
this.regRKDB = data;
};
/*

View file

@ -313,13 +313,13 @@ SerialPortPDP11.prototype.initBus = function(cmp, bus, cpu, dbg)
this.timerReceiveInterrupt = this.cpu.addTimer(function readyReceiver() {
var b = serial.receiveByte();
if (b >= 0) {
serial.rbuf = b;
if (!(serial.rcsr & PDP11.DL11.RCSR.RD)) {
serial.rcsr |= PDP11.DL11.RCSR.RD;
serial.regRBUF = b;
if (!(serial.regRCSR & PDP11.DL11.RCSR.RD)) {
serial.regRCSR |= PDP11.DL11.RCSR.RD;
} else {
serial.rbuf |= PDP11.DL11.RBUF.OE | PDP11.DL11.RBUF.ERROR;
serial.regRBUF |= PDP11.DL11.RBUF.OE | PDP11.DL11.RBUF.ERROR;
}
if (serial.rcsr & PDP11.DL11.RCSR.RIE) {
if (serial.regRCSR & PDP11.DL11.RCSR.RIE) {
cpu.setIRQ(serial.irqReceiver);
}
}
@ -328,8 +328,8 @@ SerialPortPDP11.prototype.initBus = function(cmp, bus, cpu, dbg)
this.irqTransmitter = this.cpu.addIRQ(PDP11.DL11.XVEC, PDP11.DL11.PRI, MessagesPDP11.DL11);
this.timerTransmitInterrupt = this.cpu.addTimer(function readyTransmitter() {
serial.xcsr |= PDP11.DL11.XCSR.READY;
if (serial.xcsr & PDP11.DL11.XCSR.TIE) {
serial.regXCSR |= PDP11.DL11.XCSR.READY;
if (serial.regXCSR & PDP11.DL11.XCSR.TIE) {
cpu.setIRQ(serial.irqTransmitter);
}
});
@ -482,9 +482,9 @@ SerialPortPDP11.prototype.restore = function(data)
*/
SerialPortPDP11.prototype.initState = function(data)
{
this.rbuf = 0;
this.rcsr = 0;
this.xcsr = PDP11.DL11.XCSR.READY;
this.regRBUF = 0;
this.regRCSR = 0;
this.regXCSR = PDP11.DL11.XCSR.READY;
this.abReceive = [];
return true;
};
@ -681,7 +681,7 @@ SerialPortPDP11.prototype.transmitByte = function(b)
*/
SerialPortPDP11.prototype.readRCSR = function(addr)
{
return this.rcsr & PDP11.DL11.RCSR.RMASK;
return this.regRCSR & PDP11.DL11.RCSR.RMASK;
};
/**
@ -693,7 +693,7 @@ SerialPortPDP11.prototype.readRCSR = function(addr)
*/
SerialPortPDP11.prototype.writeRCSR = function(data, addr)
{
this.rcsr = (this.rcsr & ~PDP11.DL11.RCSR.WMASK) | (data & PDP11.DL11.RCSR.WMASK);
this.regRCSR = (this.regRCSR & ~PDP11.DL11.RCSR.WMASK) | (data & PDP11.DL11.RCSR.WMASK);
};
/**
@ -705,8 +705,8 @@ SerialPortPDP11.prototype.writeRCSR = function(data, addr)
*/
SerialPortPDP11.prototype.readRBUF = function(addr)
{
this.rcsr &= ~PDP11.DL11.RCSR.RD;
return this.rbuf;
this.regRCSR &= ~PDP11.DL11.RCSR.RD;
return this.regRBUF;
};
/**
@ -729,7 +729,7 @@ SerialPortPDP11.prototype.writeRBUF = function(data, addr)
*/
SerialPortPDP11.prototype.readXCSR = function(addr)
{
return this.xcsr;
return this.regXCSR;
};
/**
@ -750,14 +750,14 @@ SerialPortPDP11.prototype.writeXCSR = function(data, addr)
* this fix also requires a complementary change in setIRQ(), to request hardware interrupts with
* IRQ_DELAY rather than IRQ.
*/
if (this.xcsr & PDP11.DL11.XCSR.READY) {
if (this.regXCSR & PDP11.DL11.XCSR.READY) {
if (data & PDP11.DL11.XCSR.TIE) {
this.cpu.setIRQ(this.irqTransmitter);
} else {
this.cpu.clearIRQ(this.irqTransmitter);
}
}
this.xcsr = (this.xcsr & ~PDP11.DL11.XCSR.WMASK) | (data & PDP11.DL11.XCSR.WMASK);
this.regXCSR = (this.regXCSR & ~PDP11.DL11.XCSR.WMASK) | (data & PDP11.DL11.XCSR.WMASK);
};
/**
@ -782,7 +782,7 @@ SerialPortPDP11.prototype.readXBUF = function(addr)
SerialPortPDP11.prototype.writeXBUF = function(data, addr)
{
this.transmitByte(data & PDP11.DL11.XBUF.DATA);
this.xcsr &= ~PDP11.DL11.XCSR.READY;
this.regXCSR &= ~PDP11.DL11.XCSR.READY;
};
/*