Changed the remainder operator from '%' to '^/', mainly because '%' must be allowed in MACRO-10 symbols instead, but also because '%' led one to believe it was a "mod" operator (it wasn't); added IFDEF support to the MACRO-10 Mini-Assembler; updated the Debugger's assemble command to recognize filenames with "KLM" extensions, too.

This commit is contained in:
Jeff 2017-03-31 09:37:38 -07:00 committed by Jeff Parsons
commit e7988597c5
17 changed files with 573 additions and 142 deletions

View file

@ -2642,7 +2642,7 @@ class DebuggerPDP10 extends Debugger {
return true;
}
var match = sOpcode.match(/^(['"]?)(.*\.mac|.*\.html|.*\.txt)\1$/i);
var match = sOpcode.match(/^(['"]?)(.*\.klm|.*\.mac|.*\.html|.*\.txt)\1$/i);
if (match) {
var dbg = this;
var cpu = this.cpu;

View file

@ -656,6 +656,7 @@ class Macro10 {
break;
case Macro10.PSEUDO_OP.DEFINE:
case Macro10.PSEUDO_OP.IFDEF:
case Macro10.PSEUDO_OP.IFE:
case Macro10.PSEUDO_OP.IFG:
case Macro10.PSEUDO_OP.IFL:
@ -781,6 +782,12 @@ class Macro10 {
var sOperator = name.substr(1);
switch(sOperator) {
case Macro10.PSEUDO_OP.IFDEF:
if (macro.nOperand) {
this.parseText(macro.sText);
}
break;
case Macro10.PSEUDO_OP.IFE:
if (!macro.nOperand) {
this.parseText(macro.sText);
@ -919,18 +926,6 @@ class Macro10 {
this.println("warning" + (this.nLine? " at line " + Str.toDec(this.nLine) : "") + ": " + sWarning);
}
/**
* isSymbolChar(ch)
*
* @this {Macro10}
* @param {string} ch
* @return {boolean}
*/
isSymbolChar(ch)
{
return !!ch.match(/[0-9A-Z$%.]/i);
}
/**
* getExpression(sOperands, sDelim)
*
@ -1224,6 +1219,54 @@ class Macro10 {
return aValues;
}
/**
* isDefined(sName)
*
* @this {Macro10}
* @param {string} sName
* @return {boolean}
*/
isDefined(sName)
{
return this.isMacro(sName) || this.isSymbol(sName) || this.dbg.isVariable(sName);
}
/**
* isMacro(sName)
*
* @this {Macro10}
* @param {string} sName
* @return {boolean}
*/
isMacro(sName)
{
return this.tblMacros[sName] !== undefined;
}
/**
* isSymbol(sName)
*
* @this {Macro10}
* @param {string} sName
* @return {boolean}
*/
isSymbol(sName)
{
return this.tblSymbols[sName] !== undefined;
}
/**
* isSymbolChar(ch)
*
* @this {Macro10}
* @param {string} ch
* @return {boolean}
*/
isSymbolChar(ch)
{
return !!ch.match(/[0-9A-Z$%.]/i);
}
/**
* defASCII(sOperands)
*
@ -1385,11 +1428,16 @@ class Macro10 {
sOperand = sOperand.trim();
match = sOperands.match(/\s*(<|)([\s\S]*)/i);
name = '?' + sOperator;
/*
* The expression is either a repeat count or a condition. Either way, we must be able to
* resolve it now, so we don't set fPass1 (but that doesn't mean it's the second pass, either).
*/
nOperand = this.parseExpression(sOperand) || 0;
if (sOperator == Macro10.PSEUDO_OP.IFDEF) {
nOperand = this.isDefined(sOperand)? 1 : 0;
} else {
/*
* The expression is either a repeat count or a condition. Either way, we must be able to
* resolve it now, so we don't set fPass1 (but that doesn't mean it's the second pass, either).
*/
nOperand = this.parseExpression(sOperand) || 0;
}
iMatch = 1;
}
@ -1678,6 +1726,7 @@ Macro10.PSEUDO_OP = {
DEFINE: "DEFINE",
END: "END",
EXP: "EXP",
IFDEF: "IFDEF",
IFE: "IFE",
IFG: "IFG",
IFL: "IFL",

View file

@ -519,7 +519,7 @@ class Debugger extends Component
if (!val2) return false;
valNew = Math.trunc(val1 / val2);
break;
case '%':
case '^/':
if (!val2) return false;
valNew = val1 % val2;
break;
@ -883,6 +883,8 @@ class Debugger extends Component
* added '!' as an alias for '|' (bitwise inclusive-or), '^-' as an alias for '~' (one's complement operator),
* and '_' as a shift operator (+/- values specify a left/right shift, and the count is not limited to 32).
*
* And to avoid conflicts with MACRO-10 syntax, I've replaced the original mod operator ('%') with '^/'.
*
* The MACRO-10 binary shifting suffix ('B') is a bit more problematic, since a capital B can also appear
* inside symbols. So I pre-scan for that suffix and replace all non-symbolic occurrences with an internal
* shift operator ('^_').
@ -901,7 +903,7 @@ class Debugger extends Component
* to remove spaces entirely, because if an operator-less expression like "A B" was passed in, we would want
* that to generate an error; if we converted it to "AB", evaluation might inadvertently succeed.
*/
var regExp = /({|}|\|\||&&|\||\^!|\^B|\^O|\^D|\^L|\^-|~|\^_|_|&|!=|!|==|>=|>>>|>>|>|<=|<<|<|-|\+|%|\/|\*| )/;
var regExp = /({|}|\|\||&&|\||\^!|\^B|\^O|\^D|\^L|\^-|~|\^_|_|&|!=|!|==|>=|>>>|>>|>|<=|<<|<|-|\+|\^\/|\/|\*| )/;
sExp = sExp.replace(/(^|[^A-Z0-9$%.])([0-9]+)B/, "$1$2^_").replace(/\s+/g, ' ');
var asValues = sExp.split(regExp);
value = this.parseArray(asValues, 0, asValues.length, this.nBase, fQuiet);
@ -1150,6 +1152,18 @@ class Debugger extends Component
return this.aVariables[sVar];
}
/**
* isVariable(sVar)
*
* @this {Debugger}
* @param {string} sVar
* @return {boolean}
*/
isVariable(sVar)
{
return this.aVariables[sVar] !== undefined;
}
/**
* setVariable(sVar, value)
*
@ -1230,7 +1244,7 @@ if (DEBUGGER) {
'<<': 12, // bitwise left shift
'-': 13, // subtraction
'+': 13, // addition
'%': 14, // remainder
'^/': 14, // remainder
'/': 14, // division
'*': 14, // multiplication
'_': 19, // MACRO-10 shift operator
@ -1252,7 +1266,7 @@ if (DEBUGGER) {
'<<': 12, // bitwise left shift
'-': 13, // subtraction
'+': 13, // addition
'%': 14, // remainder
'^/': 14, // remainder
'/': 14, // division
'*': 14, // multiplication
'!': 15, // bitwise OR (conflicts with logical NOT, but we never supported that)