From b8b774696b048558af8a433b6ce6dc1c3494da05 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Sun, 19 Feb 2017 15:49:08 -0800 Subject: [PATCH] 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) --- modules/pdp10/lib/memory.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/pdp10/lib/memory.js b/modules/pdp10/lib/memory.js index 7381b68f5..96d7b05f3 100644 --- a/modules/pdp10/lib/memory.js +++ b/modules/pdp10/lib/memory.js @@ -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;