Added support to FileDump for generating binary dumps from MACRO11 listing (.lst) files, since I wasn't having much success with dumpobj or obj2hex.pl; note that this assumes a listing file produced by the macro11 cross-assembler written by Richard Krehbiel in 2001, updated in 2009, and maintained here: https://github.com/shattered/macro11. There are other versions of macro11 floating around, like the one in the simtools project that accompanies simh, and the one built for the Windows-based PDP11GUI app.

This commit is contained in:
Jeff Parsons 2016-10-15 11:05:38 -07:00 committed by Jeff Parsons
commit 3a7b769fa3
31 changed files with 1117 additions and 751 deletions

View file

@ -691,10 +691,7 @@ if (DEBUGGER) {
s = str.toHex(n, nBytes * 2);
break;
}
if (fStripLeadingZeros && s.charAt(0) == '0') {
s = s.replace(/^0+([0-9A-F]+)$/i, "$1");
}
return s;
return (fStripLeadingZeros? str.stripLeadingZeros(s) : s);
};
} // endif DEBUGGER

View file

@ -67,7 +67,9 @@ var DumpAPI = {
JSON_GZ: "gz", // gzip is currently used ONLY for compressed JSON
DATA: "data", // same as "json", but built without JSON.stringify() (DiskDump only)
HEX: "hex", // deprecated
OCTAL: "octal", // displays data as octal words
BYTES: "bytes", // displays data as hex bytes; normally used only when comments are enabled
WORDS: "words", // displays data as hex words; normally used only when comments are enabled
IMG: "img", // returns the raw disk data (ie, using a Buffer object) (DiskDump only)
ROM: "rom" // returns the raw file data (ie, using a Buffer object) (FileDump only)
}

View file

@ -240,6 +240,48 @@ str.toOct = function(n, cch, fPrefix)
return (fPrefix? "0o" : "") + s;
};
/**
* toDec(n, cch)
*
* Converts an integer to decimal, with the specified number of digits (default of 5; max of 10)
*
* You might be tempted to use the built-in n.toString(10) instead, but it doesn't zero-pad and it
* doesn't properly convert negative values. Moreover, if n is undefined, n.toString() will throw
* an exception, whereas this function will return '?' characters.
*
* @param {number|null|undefined} n is 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
*/
str.toDec = function(n, cch)
{
var s = "";
if (cch) {
if (cch > 10) cch = 10;
} else {
cch = (n & ~0xffff)? 10 : 5;
}
/*
* An initial "falsey" check for null takes care of both null and undefined;
* we can't rely entirely on isNaN(), because isNaN(null) returns false, oddly enough.
*
* Alternatively, we could mask and shift n regardless of whether it's null/undefined/NaN,
* since JavaScript coerces such operands to zero, but I think there's "value" in seeing those
* values displayed differently.
*/
if (n == null || isNaN(n)) {
while (cch-- > 0) s = '?' + s;
} else {
while (cch-- > 0) {
var d = (n % 10) + 0x30;
s = String.fromCharCode(d) + s;
n /= 10;
}
}
return s;
};
/**
* toHex(n, cch, fPrefix)
*
@ -477,6 +519,21 @@ str.pad = function(s, cch, fPadLeft)
return fPadLeft? (sPadding + s).slice(-cch) : (s + sPadding).slice(0, cch);
};
/**
* stripLeadingZeros(s, fPad)
*
* @param {string} s
* @param {boolean} [fPad]
* @return {string}
*/
str.stripLeadingZeros = function(s, fPad)
{
var cch = s.length;
s = s.replace(/^0+([0-9A-F]+)$/i, "$1");
if (fPad) s = str.pad(s, cch, true);
return s;
};
/**
* trim(s)
*