Fixed the Debugger's arithmetic truncation function (truncate())
This commit is contained in:
parent
46ed7c77e8
commit
75b9a9c2ba
9 changed files with 84 additions and 149 deletions
|
|
@ -519,7 +519,14 @@ class DebuggerPDP10 extends Debugger {
|
|||
*/
|
||||
evalMUL(dst, src)
|
||||
{
|
||||
/*
|
||||
* The CPU requires that all 36-bit inputs/outputs be UNSIGNED, whereas our expression evaluator allows signed
|
||||
* inputs/outputs. So we perform two's complement conversions on all inputs/outputs as needed.
|
||||
*/
|
||||
if (dst < 0) dst += PDP10.WORD_LIMIT;
|
||||
if (src < 0) src += PDP10.WORD_LIMIT;
|
||||
var result = PDP10.doMUL.call(this.cpu, dst, src, false, true);
|
||||
if (result >= PDP10.INT_LIMIT) result -= PDP10.WORD_LIMIT;
|
||||
if (MAXDEBUG) {
|
||||
var resultJS = this.truncate(dst * src);
|
||||
if (resultJS !== result) {
|
||||
|
|
@ -3932,7 +3939,7 @@ class DebuggerPDP10 extends Debugger {
|
|||
*/
|
||||
doTest()
|
||||
{
|
||||
if (DEBUG) {
|
||||
if (MAXDEBUG) {
|
||||
var ops = {}, aOpXXX = [];
|
||||
var op, opXXX, opCode, sOperation;
|
||||
for (op = 0o00000; op <= 0o77774; op += 4) {
|
||||
|
|
|
|||
|
|
@ -473,15 +473,21 @@ class Debugger extends Component
|
|||
}
|
||||
else {
|
||||
if (nBits <= 32) {
|
||||
vNew = v | 0;
|
||||
} else {
|
||||
vNew = (v << (32 - nBits)) >> (32 - nBits);
|
||||
}
|
||||
else {
|
||||
limit = Math.pow(2, nBits - 1);
|
||||
if (v < -limit) {
|
||||
if (v < -limit * 2) vNew = v % (limit * 2);
|
||||
vNew += (limit * 2);
|
||||
} else if (vNew >= limit) {
|
||||
if (v >= limit * 2) vNew = v % (limit * 2);
|
||||
vNew -= (limit * 2); // the sign bit was set in this overly large value, so make it negative
|
||||
if (v >= limit) {
|
||||
vNew = (v % limit);
|
||||
if (((v / limit)|0) & 1) vNew -= limit;
|
||||
} else if (v < -limit) {
|
||||
vNew = (v % limit);
|
||||
if ((((-v - 1) / limit) | 0) & 1) {
|
||||
if (vNew) vNew += limit;
|
||||
}
|
||||
else {
|
||||
if (!vNew) vNew -= limit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue