Fixed MACRO-10 processing of literals (requires internal labels that don't conflict with MACRO-10 labels)

This commit is contained in:
Jeff 2017-03-13 17:02:26 -07:00 committed by Jeff Parsons
commit 3e2b825bef
4 changed files with 39 additions and 35 deletions

View file

@ -35,16 +35,17 @@ DEFINE SFLAG (A)<
JRST 2,.+1(1) ;SET A FLAG> JRST 2,.+1(1) ;SET A FLAG>
SUBTTL DIAGNOSTIC SECTION SUBTTL DIAGNOSTIC SECTION
START: SETZM USER# ;CLEAR USER CONTROL WORD START:
JSP 0,.+1 ;GET FLAGS ; SETZM USER# ;CLEAR USER CONTROL WORD
TLNE USERF ;IN USER MODE? ; JSP 0,.+1 ;GET FLAGS
SETOM USER ;YES, SET USER CONTROL WORD ; TLNE USERF ;IN USER MODE?
SKIPN MONFLG ;SPECIAL USER MODE? ; SETOM USER ;YES, SET USER CONTROL WORD
SETZM USER ;YES, CLEAR USER CONTROL WORD ; SKIPN MONFLG ;SPECIAL USER MODE?
SKIPN USER ; SETZM USER ;YES, CLEAR USER CONTROL WORD
JRST C00 ; SKIPN USER
SKIPL MONCTL ; JRST C00
TTCALL 3,PGMNAM ;MENTION OUR NAME ; SKIPL MONCTL
; TTCALL 3,PGMNAM ;MENTION OUR NAME
JRST STARTA JRST STARTA
PGMNAM: ASCIZ/ PGMNAM: ASCIZ/

View file

@ -8,5 +8,5 @@
<device id="default" type="default"/> <device id="default" type="default"/>
<serial id="serial" adapter="0" binding="print" upperCase="true"/> <serial id="serial" adapter="0" binding="print" upperCase="true"/>
<panel ref="/devices/pdp10/panel/test/debugger/terminal.xml"/> <panel ref="/devices/pdp10/panel/test/debugger/terminal.xml"/>
<debugger id="debugger" base="8" messages="" commands="a 100 http://archive.pcjs.org/apps/pdp10/tapes/diags/klad/dakadm.mac.html"/> <debugger id="debugger" base="8" messages="" commands="a 100 /apps/pdp10/tapes/diags/klad/dakad/DAKAD.MAC"/>
</machine> </machine>

View file

@ -1703,12 +1703,16 @@ class DebuggerPDP10 extends Debugger {
break; break;
} }
sOperand = match[2]; sOperand = match[2];
if (i) { if (i || aOperands.length == 1) {
/* /*
* If this is NOT the first operand, then replace all periods NOT preceded * If this is NOT the first operand, then replace all periods NOT preceded
* by a digit with the current address. * by a digit with the current address.
*/ */
sOperand = sOperand.replace(/(^|[^0-9])\./g, "$1" + this.toStrOffset(addr)); if (!sOperand) {
sOperand = "0";
} else {
sOperand = sOperand.replace(/(^|[^0-9])\./g, "$1" + this.toStrOffset(addr));
}
} }
var operand = this.parseExpression(sOperand); var operand = this.parseExpression(sOperand);
if (operand == undefined) { if (operand == undefined) {
@ -1718,17 +1722,15 @@ class DebuggerPDP10 extends Debugger {
if (!i && aOperands.length > 1) { if (!i && aOperands.length > 1) {
if (opMask == PDP10.OPCODE.OPIO) { if (opMask == PDP10.OPCODE.OPIO) {
if (operand < 0 || operand > PDP10.OPCODE.IO_MASK) { if (operand < 0 || operand > PDP10.OPCODE.IO_MASK) {
this.println("device code out of range: " + sOperand); operand &= PDP10.OPCODE.IO_MASK;
opCode = -1; this.println("device code (" + sOperand + ") truncated to " + this.toStrBase(operand));
break;
} }
opCode += (operand * PDP10.OPCODE.IO_SCALE); opCode += (operand * PDP10.OPCODE.IO_SCALE);
} }
else { else {
if (operand < 0 || operand > PDP10.OPCODE.A_MASK) { if (operand < 0 || operand > PDP10.OPCODE.A_MASK) {
this.println("accumulator address out of range: " + sOperand); operand &= PDP10.OPCODE.A_MASK;
opCode = -1; this.println("accumulator (" + sOperand + ") truncated to " + this.toStrBase(operand));
break;
} }
opCode += (operand << PDP10.OPCODE.A_SHIFT); opCode += (operand << PDP10.OPCODE.A_SHIFT);
} }
@ -1748,15 +1750,12 @@ class DebuggerPDP10 extends Debugger {
break; break;
} }
if (operand < 0 || operand > PDP10.OPCODE.X_MASK) { if (operand < 0 || operand > PDP10.OPCODE.X_MASK) {
this.println("memory index out of range: " + sOperand); operand &= PDP10.OPCODE.X_MASK;
opCode = -1; this.println("index (" + sOperand + ") truncated to " + this.toStrBase(operand));
break;
} }
opCode += operand << PDP10.OPCODE.X_SHIFT; opCode += operand << PDP10.OPCODE.X_SHIFT;
} }
if (match[1]) { if (match[1]) opCode += PDP10.OPCODE.I_BIT;
opCode += PDP10.OPCODE.I_BIT;
}
} }
} }
// //
@ -2552,7 +2551,7 @@ class DebuggerPDP10 extends Debugger {
return; return;
} }
if (sOpcode.indexOf(':') >= 0) { if (sOpcode[0] == '/' || sOpcode.indexOf(':') >= 0) {
var dbg = this; var dbg = this;
if (this.macro10) { if (this.macro10) {
dbg.println("assembly already in progress"); dbg.println("assembly already in progress");

View file

@ -123,6 +123,9 @@ class Macro10 {
* auto-generated label based on the current line number), but they are never immediately invoked; * auto-generated label based on the current line number), but they are never immediately invoked;
* instead, after we've finished processing all the lines in the original input file, we run through * instead, after we've finished processing all the lines in the original input file, we run through
* all the LITERAL entries in the Macros table and process the associated statement(s). * all the LITERAL entries in the Macros table and process the associated statement(s).
*
* REPEAT and LITERAL blocks are assigned internal labels, using a leading underscore ('_') so that
* they don't conflict with normal MACRO-10 labels.
*/ */
/** /**
@ -222,9 +225,10 @@ class Macro10 {
} }
for (i = 0; i < this.aLiterals.length; i++) { for (i = 0; i < this.aLiterals.length; i++) {
var macro = this.tblMacros[this.aLiterals[i]]; var name = this.aLiterals[i];
var macro = this.tblMacros[name];
if (!macro) { if (!macro) {
this.error("missing definition for literal: " + this.aLiterals[i]); this.error("missing definition for literal: " + name);
continue; continue;
} }
this.parseText(macro.sText); this.parseText(macro.sText);
@ -301,7 +305,7 @@ class Macro10 {
sLine = this.addASCII(sLine); sLine = this.addASCII(sLine);
} }
var reLine = /\s*([A-Z$%.][0-9A-Z$%.]*[:=]|)\s*([A-Z$%.][0-9A-Z$%.]*|)\s*([^;]+|)\s*(;?.*)/i; var reLine = /\s*([A-Z$%._][0-9A-Z$%.]*[:=]|)\s*([A-Z$%.][0-9A-Z$%.]*|)\s*([^;]+|)\s*(;?.*)/i;
var match = sLine.match(reLine); var match = sLine.match(reLine);
if (!match || match[4] && match[4].slice(0, 1) != ';') { if (!match || match[4] && match[4].slice(0, 1) != ';') {
this.error("failed to parse line: " + sLine); this.error("failed to parse line: " + sLine);
@ -420,7 +424,7 @@ class Macro10 {
return true; return true;
} }
if (name[0] != '@') return false; if (name[0] != '_') return false;
switch(name.substr(1)) { switch(name.substr(1)) {
case Macro10.PSEUDO_OP.IFE: case Macro10.PSEUDO_OP.IFE:
@ -628,7 +632,7 @@ class Macro10 {
var match, sReserved = null; var match, sReserved = null;
if (match = sOperands.match(/([A-Z$%.][0-9A-Z$%.]*)#/i)) { if (match = sOperands.match(/([A-Z$%.][0-9A-Z$%.]*)#/i)) {
var sLabel = match[1]; var sLabel = match[1];
var name = '@' + sLabel; var name = '_' + sLabel;
this.tblMacros[name] = {name: name, nOperand: 0, aParms: [], aDefaults: [], sText: sLabel + ": 0"}; this.tblMacros[name] = {name: name, nOperand: 0, aParms: [], aDefaults: [], sText: sLabel + ": 0"};
this.aLiterals.push(name); this.aLiterals.push(name);
sReserved = match[0]; sReserved = match[0];
@ -726,7 +730,7 @@ class Macro10 {
* REPEAT block instead. * REPEAT block instead.
* *
* REPEAT blocks piggy-back on this code because they're essentially anonymous immediately-invoked macros; * REPEAT blocks piggy-back on this code because they're essentially anonymous immediately-invoked macros;
* we use an illegal MACRO-10 symbol ('@REPEAT') to name the anonymous macro while it's being defined, and the * we use an illegal MACRO-10 symbol ('_REPEAT') to name the anonymous macro while it's being defined, and the
* macro's nOperand field will contain the repeat count (-1 for regular macros). * macro's nOperand field will contain the repeat count (-1 for regular macros).
* *
* The piggy-backing continues with other pseudo-ops like IFE, which again contain an anonymous block of text * The piggy-backing continues with other pseudo-ops like IFE, which again contain an anonymous block of text
@ -765,9 +769,9 @@ class Macro10 {
else if (sOperator == Macro10.PSEUDO_OP.LITERAL) { else if (sOperator == Macro10.PSEUDO_OP.LITERAL) {
this.chMacroOpen = '['; this.chMacroOpen = '[';
this.chMacroClose = ']'; this.chMacroClose = ']';
name = '@' + Str.toDec(this.nLocation, 5); name = '_' + Str.toDec(this.nLocation, 5);
this.aLiterals.push(name); this.aLiterals.push(name);
match = [sOperands[0], sOperands.substr(1)]; match = [sOperands[0], name + ": " + sOperands.substr(1)];
aParms = []; aParms = [];
nOperand = this.nLine; nOperand = this.nLine;
iBracket = 0; iBracket = 0;
@ -781,7 +785,7 @@ class Macro10 {
sOperands = sOperands.substr(sOperand.length + 1); sOperands = sOperands.substr(sOperand.length + 1);
sOperand = sOperand.trim(); sOperand = sOperand.trim();
match = sOperands.match(/\s*(<|)(.*)/i); match = sOperands.match(/\s*(<|)(.*)/i);
name = '@' + sOperator; name = '_' + sOperator;
aParms = []; aParms = [];
nOperand = this.parseExpression(sOperand) || 0; nOperand = this.parseExpression(sOperand) || 0;
iBracket = 1; iBracket = 1;