Added support for parsing of values (ie, integers) greater than 32 bits, and fixed PDP-10 Bus writes (parameter order differs from other emulators)

This commit is contained in:
Jeff Parsons 2017-02-24 13:07:38 -08:00 committed by Jeff Parsons
commit ef70ed74b3
11 changed files with 66 additions and 39 deletions

View file

@ -478,7 +478,7 @@ class BusPDP10 extends Component {
*
* @this {BusPDP10}
* @param {number} addr is a physical address
* @return {number} word (16-bit) value at that address
* @return {number} word (36-bit) value at that address
*/
getWord(addr)
{
@ -492,13 +492,13 @@ class BusPDP10 extends Component {
*
* @this {BusPDP10}
* @param {number} addr is a physical address
* @param {number} w is the word (16-bit) value to write
* @param {number} w is the word (36-bit) value to write
*/
setWord(addr, w)
{
var off = addr & this.nBlockLimit;
var iBlock = (addr & this.nBusMask) >>> this.nBlockShift;
this.aBusBlocks[iBlock].writeWord(off, w, addr);
this.aBusBlocks[iBlock].writeWord(w, off, addr);
}
/**
@ -520,7 +520,7 @@ class BusPDP10 extends Component {
*
* @this {BusPDP10}
* @param {number} addr is a physical address
* @return {number} word (16-bit) value at that address
* @return {number} word (36-bit) value at that address
*/
getWordDirect(addr)
{
@ -540,14 +540,14 @@ class BusPDP10 extends Component {
*
* @this {BusPDP10}
* @param {number} addr is a physical address
* @param {number} w is the word (16-bit) value to write (we truncate it to 16 bits to be safe)
* @param {number} w is the word (36-bit) value to write (we truncate it to 16 bits to be safe)
*/
setWordDirect(addr, w)
{
var off = addr & this.nBlockLimit;
var block = this.getBlockDirect(addr);
this.nDisableFaults++;
block.writeWordDirect(off, w & 0xffff, addr);
block.writeWordDirect(w, off, addr);
this.nDisableFaults--;
}

View file

@ -2487,7 +2487,7 @@ class DebuggerPDP10 extends Debugger {
sData += ' ';
}
for (var i = 0; size == 1 && i < 6; i++) {
var c = ((w % 64)|0) + 33;
var c = ((w % 64)|0) + 32;
sChars += String.fromCharCode(c);
w /= 64;
}

View file

@ -216,7 +216,7 @@ class MemoryPDP10 {
*/
if (len === undefined) len = this.size;
Component.assert(off >= 0 && off < this.size);
for (i = off; len-- && i < this.size; i++) this.writeWordDirect(off, pattern, this.addr + off);
for (i = off; len-- && i < this.size; i++) this.writeWordDirect(pattern, off, this.addr + off);
}
/**

View file

@ -132,7 +132,12 @@ class Str {
}
var v;
if (Str.isValidInt(s, base) && !isNaN(v = parseInt(s, base))) {
value = v | 0;
/*
* With the need to support larger (eg, 36-bit) integers, truncating to 32 bits is no longer helpful.
*
* value = v|0;
*/
value = v;
}
}
return value;
@ -234,6 +239,13 @@ class Str {
if (n == null || isNaN(n)) {
while (cch-- > 0) s = '?' + s;
} else {
/*
* Callers that produced an input by dividing by a power of two rather than shifting (in order
* to access more than 32 bits) may produce a fractional result, which ordinarily we would simply
* ignore, but if the integer portion is zero and the sign is negative, we should probably treat
* this value as a sign-extension.
*/
if (n < 0 && n > -1) n = -1;
while (cch-- > 0) {
var d = (n & 7) + 0x30;
s = String.fromCharCode(d) + s;
@ -254,7 +266,7 @@ class Str {
*
* @param {number|null|undefined} n (interpreted as a 32-bit value)
* @param {number} [cch] is the desired number of decimal digits (0 or undefined for default of either 5 or 10)
* @return {string} the octal representation of n
* @return {string} the decimal representation of n
*/
static toDec(n, cch)
{
@ -276,6 +288,13 @@ class Str {
if (n == null || isNaN(n)) {
while (cch-- > 0) s = '?' + s;
} else {
/*
* Callers that produced an input by dividing by a power of two rather than shifting (in order
* to access more than 32 bits) may produce a fractional result, which ordinarily we would simply
* ignore, but if the integer portion is zero and the sign is negative, we should probably treat
* this value as a sign-extension.
*/
if (n < 0 && n > -1) n = -1;
while (cch-- > 0) {
var d = (n % 10) + 0x30;
s = String.fromCharCode(d) + s;
@ -327,6 +346,13 @@ class Str {
if (n == null || isNaN(n)) {
while (cch-- > 0) s = '?' + s;
} else {
/*
* Callers that produced an input by dividing by a power of two rather than shifting (in order
* to access more than 32 bits) may produce a fractional result, which ordinarily we would simply
* ignore, but if the integer portion is zero and the sign is negative, we should probably treat
* this value as a sign-extension.
*/
if (n < 0 && n > -1) n = -1;
while (cch-- > 0) {
var d = n & 0xf;
d += (d >= 0 && d <= 9? 0x30 : 0x41 - 10);