Allow the debugger to switch to base 2

This commit is contained in:
Jeff 2017-03-17 11:20:26 -07:00 committed by Jeff Parsons
commit abd17be706
10 changed files with 677 additions and 654 deletions

View file

@ -3179,7 +3179,7 @@ class DebuggerPDP10 extends Debugger {
case "base":
if (asArgs[2]) {
var nBase = +asArgs[2];
if (nBase == 8 || nBase == 10 || nBase == 16) {
if (nBase == 2 || nBase == 8 || nBase == 10 || nBase == 16) {
this.nBase = nBase;
} else {
this.println("invalid base: " + nBase);

View file

@ -1,5 +1,5 @@
/**
* @fileoverview My homage to MACRO-10: a work-alike assembler for the PDP-10
* @fileoverview A MACRO-10 "work-alike" Mini-Assembler for the PDP-10
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
* @copyright © Jeff Parsons 2012-2017
*
@ -119,10 +119,7 @@ class Macro10 {
this.dbg = dbg;
this.done = done;
/*
* Set up shortcuts to frequently used helper services that the caller must provide.
*/
this.println = dbg.println;
this.println("starting PCjs MACRO-10 Mini-Assembler...");
/*
* Initialize all the tables that MACRO-10 uses.
@ -200,6 +197,7 @@ class Macro10 {
this.sText = "";
this.iURL = 0;
this.asURLs = sURL.split(';');
this.loadNextResource();
}
@ -218,6 +216,8 @@ class Macro10 {
var macro10 = this;
var sURL = this.asURLs[this.iURL++];
this.println("loading " + Str.getBaseName(sURL));
/*
* We know that local resources ending with ".MAC" are actually stored with a ".txt" extension.
*/
@ -1090,6 +1090,21 @@ class Macro10 {
}
return w;
}
/**
* println(s)
*
* @this {Macro10}
* @param {string} s
*/
println(s)
{
if (!this.dbg) {
console.log(s);
} else {
this.dbg.println(s);
}
}
}
Macro10.PSEUDO_OP = {

View file

@ -926,7 +926,11 @@ class Debugger extends Component
var fDefined = false;
if (value !== undefined) {
fDefined = true;
sValue = Str.toHex(value, 0, true) + " " + value + ". " + Str.toOct(value, 0, true) + " " + Str.toBinBytes(value, 4, true);
if (this.nBase == 8) {
sValue = value + ". " + Str.toOct(value, 0, true);
} else {
sValue = Str.toHex(value, 0, true) + " " + value + ". " + Str.toOct(value, 0, true) + " " + Str.toBinBytes(value, 4, true);
}
if (value >= 0x20 && value < 0x7F) {
sValue += " '" + String.fromCharCode(value) + "'";
}
@ -1029,6 +1033,9 @@ class Debugger extends Component
{
var s;
switch(this.nBase) {
case 2:
s = Str.toBin(n, nBits > 0? nBits : 0);
break;
case 8:
s = Str.toOct(n, nBits > 0? ((nBits + 2)/3)|0 : 0);
break;