Since writeBitsMemory() must preserve unwritten bits, it can't use bit-wise operators (unless of course no bits above bit 31 are set, but it's not clear checking for that would be a win)

This commit is contained in:
Jeff Parsons 2017-02-19 15:49:08 -08:00 committed by Jeff Parsons
commit b8b774696b

View file

@ -496,15 +496,10 @@ class MemoryPDP10 {
writeBitsMemory(offBits, lenBits, bits, off, addr)
{
var w = this.aw[off];
if (offBits + lenBits <= 32) {
var bitsMask = ((1 << lenBits) - 1) << offBits;
w = (w & ~bitsMask) | ((bits << offBits) & bitsMask);
} else {
var shiftBits = Math.pow(2, offBits);
bits %= Math.pow(2, lenBits);
var v = (w % Math.pow(2, offBits + lenBits));
w = (w - v) + (bits * shiftBits) + (v % shiftBits);
}
var shiftBits = Math.pow(2, offBits);
bits %= Math.pow(2, lenBits);
var v = (w % Math.pow(2, offBits + lenBits));
w = (w - v) + (bits * shiftBits) + (v % shiftBits);
if (this.aw[off] != w) {
this.aw[off] = w;
this.fDirty = true;