1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-09-29 16:54:50 +00:00

Minor tweaks

- Renamed "strip label prefix/suffix" to "omit label prefix/suffix".

- Changed a Merlin operand workaround so it doesn't apply to code
  that is explicitly not in bank zero.

- Changed {addr}/{const} annotations on project/platform symbol
  equates so they line up a little better on screen and in exported
  sources.
This commit is contained in:
Andy McFadden 2019-11-15 16:15:31 -08:00
parent 5dd7576529
commit be65f280a3
6 changed files with 42 additions and 32 deletions

View File

@ -388,7 +388,7 @@ namespace SourceGen.AsmGen {
operand = RawData.GetWord(data, offset, length, false); operand = RawData.GetWord(data, offset, length, false);
operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable, operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable,
mLocalizer.LabelMap, dfd, operand, length, mLocalizer.LabelMap, dfd, operand, length,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
break; break;
case FormatDescriptor.Type.NumericBE: case FormatDescriptor.Type.NumericBE:
opcodeStr = sDataOpNames.GetDefineBigData(length); opcodeStr = sDataOpNames.GetDefineBigData(length);
@ -399,7 +399,7 @@ namespace SourceGen.AsmGen {
operand = RawData.GetWord(data, offset, length, true); operand = RawData.GetWord(data, offset, length, true);
operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable, operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable,
mLocalizer.LabelMap, dfd, operand, length, mLocalizer.LabelMap, dfd, operand, length,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
} }
break; break;
case FormatDescriptor.Type.Fill: case FormatDescriptor.Type.Fill:
@ -516,7 +516,7 @@ namespace SourceGen.AsmGen {
string valueStr = PseudoOp.FormatNumericOperand(SourceFormatter, string valueStr = PseudoOp.FormatNumericOperand(SourceFormatter,
Project.SymbolTable, null, defSym.DataDescriptor, defSym.Value, 1, Project.SymbolTable, null, defSym.DataDescriptor, defSym.Value, 1,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
OutputEquDirective(SourceFormatter.FormatVariableLabel(defSym.Label), OutputEquDirective(SourceFormatter.FormatVariableLabel(defSym.Label),
valueStr, defSym.Comment); valueStr, defSym.Comment);
} }

View File

@ -422,7 +422,7 @@ namespace SourceGen.AsmGen {
operand = RawData.GetWord(data, offset, length, false); operand = RawData.GetWord(data, offset, length, false);
operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable, operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable,
mLocalizer.LabelMap, dfd, operand, length, mLocalizer.LabelMap, dfd, operand, length,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
break; break;
case FormatDescriptor.Type.NumericBE: case FormatDescriptor.Type.NumericBE:
opcodeStr = sDataOpNames.GetDefineBigData(length); opcodeStr = sDataOpNames.GetDefineBigData(length);
@ -433,7 +433,7 @@ namespace SourceGen.AsmGen {
operand = RawData.GetWord(data, offset, length, true); operand = RawData.GetWord(data, offset, length, true);
operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable, operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable,
mLocalizer.LabelMap, dfd, operand, length, mLocalizer.LabelMap, dfd, operand, length,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
} }
break; break;
case FormatDescriptor.Type.Fill: case FormatDescriptor.Type.Fill:
@ -548,7 +548,7 @@ namespace SourceGen.AsmGen {
// Use an operand length of 1 so values are shown as concisely as possible. // Use an operand length of 1 so values are shown as concisely as possible.
string valueStr = PseudoOp.FormatNumericOperand(SourceFormatter, string valueStr = PseudoOp.FormatNumericOperand(SourceFormatter,
Project.SymbolTable, null, defSym.DataDescriptor, defSym.Value, 1, Project.SymbolTable, null, defSym.DataDescriptor, defSym.Value, 1,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
OutputLine(SourceFormatter.FormatVariableLabel(defSym.Label), OutputLine(SourceFormatter.FormatVariableLabel(defSym.Label),
SourceFormatter.FormatPseudoOp(sDataOpNames.VarDirective), SourceFormatter.FormatPseudoOp(sDataOpNames.VarDirective),
valueStr, SourceFormatter.FormatEolComment(defSym.Comment)); valueStr, SourceFormatter.FormatEolComment(defSym.Comment));

View File

@ -249,7 +249,7 @@ namespace SourceGen.AsmGen {
operand = RawData.GetWord(data, offset, length, false); operand = RawData.GetWord(data, offset, length, false);
operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable, operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable,
mLocalizer.LabelMap, dfd, operand, length, mLocalizer.LabelMap, dfd, operand, length,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
break; break;
case FormatDescriptor.Type.NumericBE: case FormatDescriptor.Type.NumericBE:
opcodeStr = sDataOpNames.GetDefineBigData(length); opcodeStr = sDataOpNames.GetDefineBigData(length);
@ -260,7 +260,7 @@ namespace SourceGen.AsmGen {
operand = RawData.GetWord(data, offset, length, true); operand = RawData.GetWord(data, offset, length, true);
operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable, operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable,
mLocalizer.LabelMap, dfd, operand, length, mLocalizer.LabelMap, dfd, operand, length,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
} }
break; break;
case FormatDescriptor.Type.Fill: case FormatDescriptor.Type.Fill:
@ -440,7 +440,7 @@ namespace SourceGen.AsmGen {
foreach (DefSymbol defSym in newDefs) { foreach (DefSymbol defSym in newDefs) {
string valueStr = PseudoOp.FormatNumericOperand(SourceFormatter, string valueStr = PseudoOp.FormatNumericOperand(SourceFormatter,
Project.SymbolTable, null, defSym.DataDescriptor, defSym.Value, 1, Project.SymbolTable, null, defSym.DataDescriptor, defSym.Value, 1,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
OutputLine(SourceFormatter.FormatVariableLabel(defSym.Label), OutputLine(SourceFormatter.FormatVariableLabel(defSym.Label),
SourceFormatter.FormatPseudoOp(sDataOpNames.VarDirective), SourceFormatter.FormatPseudoOp(sDataOpNames.VarDirective),
valueStr, SourceFormatter.FormatEolComment(defSym.Comment)); valueStr, SourceFormatter.FormatEolComment(defSym.Comment));

View File

@ -454,7 +454,7 @@ namespace SourceGen.AsmGen {
UpdateCharacterEncoding(dfd); UpdateCharacterEncoding(dfd);
operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable, operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable,
mLocalizer.LabelMap, dfd, operand, length, mLocalizer.LabelMap, dfd, operand, length,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
break; break;
case FormatDescriptor.Type.NumericBE: case FormatDescriptor.Type.NumericBE:
opcodeStr = sDataOpNames.GetDefineBigData(length); opcodeStr = sDataOpNames.GetDefineBigData(length);
@ -466,7 +466,7 @@ namespace SourceGen.AsmGen {
operand = RawData.GetWord(data, offset, length, true); operand = RawData.GetWord(data, offset, length, true);
operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable, operandStr = PseudoOp.FormatNumericOperand(formatter, Project.SymbolTable,
mLocalizer.LabelMap, dfd, operand, length, mLocalizer.LabelMap, dfd, operand, length,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
} }
break; break;
case FormatDescriptor.Type.Fill: case FormatDescriptor.Type.Fill:
@ -583,7 +583,7 @@ namespace SourceGen.AsmGen {
foreach (DefSymbol defSym in newDefs) { foreach (DefSymbol defSym in newDefs) {
string valueStr = PseudoOp.FormatNumericOperand(SourceFormatter, string valueStr = PseudoOp.FormatNumericOperand(SourceFormatter,
Project.SymbolTable, null, defSym.DataDescriptor, defSym.Value, 1, Project.SymbolTable, null, defSym.DataDescriptor, defSym.Value, 1,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
OutputLine(SourceFormatter.FormatVariableLabel(defSym.Label), OutputLine(SourceFormatter.FormatVariableLabel(defSym.Label),
SourceFormatter.FormatPseudoOp(sDataOpNames.VarDirective), SourceFormatter.FormatPseudoOp(sDataOpNames.VarDirective),
valueStr, SourceFormatter.FormatEolComment(defSym.Comment)); valueStr, SourceFormatter.FormatEolComment(defSym.Comment));

View File

@ -157,7 +157,7 @@ namespace SourceGen.AsmGen {
// Use an operand length of 1 so values are shown as concisely as possible. // Use an operand length of 1 so values are shown as concisely as possible.
string valueStr = PseudoOp.FormatNumericOperand(formatter, proj.SymbolTable, string valueStr = PseudoOp.FormatNumericOperand(formatter, proj.SymbolTable,
gen.Localizer.LabelMap, defSym.DataDescriptor, defSym.Value, 1, gen.Localizer.LabelMap, defSym.DataDescriptor, defSym.Value, 1,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
gen.OutputEquDirective(defSym.Label, valueStr, defSym.Comment); gen.OutputEquDirective(defSym.Label, valueStr, defSym.Comment);
prevConst = defSym.IsConstant; prevConst = defSym.IsConstant;
@ -204,7 +204,7 @@ namespace SourceGen.AsmGen {
string formattedOperand = null; string formattedOperand = null;
int operandLen = instrLen - 1; int operandLen = instrLen - 1;
PseudoOp.FormatNumericOpFlags opFlags = PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix; PseudoOp.FormatNumericOpFlags opFlags = PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix;
bool isPcRelBankWrap = false; bool isPcRelBankWrap = false;
// Tweak branch instructions. We want to show the absolute address rather // Tweak branch instructions. We want to show the absolute address rather
@ -245,10 +245,10 @@ namespace SourceGen.AsmGen {
// Special handling for the double-operand block move. // Special handling for the double-operand block move.
string opstr1 = PseudoOp.FormatNumericOperand(formatter, proj.SymbolTable, string opstr1 = PseudoOp.FormatNumericOperand(formatter, proj.SymbolTable,
gen.Localizer.LabelMap, dfd, operand >> 8, 1, gen.Localizer.LabelMap, dfd, operand >> 8, 1,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
string opstr2 = PseudoOp.FormatNumericOperand(formatter, proj.SymbolTable, string opstr2 = PseudoOp.FormatNumericOperand(formatter, proj.SymbolTable,
gen.Localizer.LabelMap, dfd, operand & 0xff, 1, gen.Localizer.LabelMap, dfd, operand & 0xff, 1,
PseudoOp.FormatNumericOpFlags.StripLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
if (gen.Quirks.BlockMoveArgsReversed) { if (gen.Quirks.BlockMoveArgsReversed) {
string tmp = opstr1; string tmp = opstr1;
opstr1 = opstr2; opstr1 = opstr2;

View File

@ -409,20 +409,27 @@ namespace SourceGen {
typeStr = Res.Strings.EQU_ADDRESS; typeStr = Res.Strings.EQU_ADDRESS;
} }
string msgStr = null; if (!defSym.HasWidth && !defSym.IsConstant) {
if (defSym.HasWidth) { // It's an address without an explicit width, do not annotate.
msgStr = typeStr + "/" + defSym.DataDescriptor.Length; return operand;
} else if (defSym.IsConstant) {
// not entirely convinced we want this, but there's currently no other way
// to tell the difference between an address and a constant from the code list
msgStr = typeStr;
} }
if (msgStr == null) { StringBuilder sb = new StringBuilder(operand.Length + typeStr.Length + 16);
return operand; sb.Append(operand);
} else {
return operand + " {" + msgStr + "}"; int spacesNeeded = 7 - operand.Length;
do { // always output at least one space
sb.Append(' ');
} while (--spacesNeeded > 0);
sb.Append("{");
sb.Append(typeStr);
if (defSym.HasWidth) {
sb.Append('/');
sb.Append(defSym.DataDescriptor.Length);
} }
sb.Append("}");
return sb.ToString();
} }
/// <summary> /// <summary>
@ -552,7 +559,7 @@ namespace SourceGen {
None = 0, None = 0,
IsPcRel = 1, // opcode is PC relative, e.g. branch or PER IsPcRel = 1, // opcode is PC relative, e.g. branch or PER
HasHashPrefix = 1 << 1, // operand has a leading '#', reducing ambiguity HasHashPrefix = 1 << 1, // operand has a leading '#', reducing ambiguity
StripLabelPrefixSuffix = 1 << 2, // don't show annotation char or non-unique prefix OmitLabelPrefixSuffix = 1 << 2, // don't show annotation char or non-unique prefix
} }
/// <summary> /// <summary>
@ -711,7 +718,7 @@ namespace SourceGen {
// Now put the prefix/suffix back on if desired. We don't want to mess with it // Now put the prefix/suffix back on if desired. We don't want to mess with it
// if it's from the assembler. // if it's from the assembler.
if ((flags & FormatNumericOpFlags.StripLabelPrefixSuffix) == 0) { if ((flags & FormatNumericOpFlags.OmitLabelPrefixSuffix) == 0) {
symLabel = Symbol.ConvertLabelForDisplay(symLabel, sym.LabelAnno, symLabel = Symbol.ConvertLabelForDisplay(symLabel, sym.LabelAnno,
sym.IsNonUnique, formatter); sym.IsNonUnique, formatter);
} else { } else {
@ -854,7 +861,7 @@ namespace SourceGen {
if (labelMap != null && labelMap.TryGetValue(symLabel, out string newLabel)) { if (labelMap != null && labelMap.TryGetValue(symLabel, out string newLabel)) {
symLabel = newLabel; symLabel = newLabel;
} }
if ((flags & FormatNumericOpFlags.StripLabelPrefixSuffix) == 0) { if ((flags & FormatNumericOpFlags.OmitLabelPrefixSuffix) == 0) {
symLabel = Symbol.ConvertLabelForDisplay(symLabel, sym.LabelAnno, symLabel = Symbol.ConvertLabelForDisplay(symLabel, sym.LabelAnno,
sym.IsNonUnique, formatter); sym.IsNonUnique, formatter);
} else { } else {
@ -955,7 +962,7 @@ namespace SourceGen {
if (labelMap != null && labelMap.TryGetValue(symLabel, out string newLabel)) { if (labelMap != null && labelMap.TryGetValue(symLabel, out string newLabel)) {
symLabel = newLabel; symLabel = newLabel;
} }
if ((flags & FormatNumericOpFlags.StripLabelPrefixSuffix) == 0) { if ((flags & FormatNumericOpFlags.OmitLabelPrefixSuffix) == 0) {
symLabel = Symbol.ConvertLabelForDisplay(symLabel, sym.LabelAnno, symLabel = Symbol.ConvertLabelForDisplay(symLabel, sym.LabelAnno,
sym.IsNonUnique, formatter); sym.IsNonUnique, formatter);
} else { } else {
@ -1005,11 +1012,14 @@ namespace SourceGen {
// testing the value for DP range, this would behave correctly. Unfortunately // testing the value for DP range, this would behave correctly. Unfortunately
// there is no "force DP" modifier, so we either need to add an explicit mask // there is no "force DP" modifier, so we either need to add an explicit mask
// or just punt and use the original adjustment. // or just punt and use the original adjustment.
//
// Note DP is only relevant for bank zero.
//
// TODO(someday): we only need to do this for ambiguous DP. If the instruction // TODO(someday): we only need to do this for ambiguous DP. If the instruction
// is imm or doesn't have an abs equivalent, or it's a fixed-width data item // is imm or doesn't have an abs equivalent, or it's a fixed-width data item
// like .DD1, we can still use the nicer-looking adjustment. We don't currently // like .DD1, we can still use the nicer-looking adjustment. We don't currently
// pass the OpDef in here. // pass the OpDef in here.
if ((sym.Value & 0xff0000) != ((sym.Value + adjustment) & 0xff0000)) { if ((sym.Value & 0xff0000) == 0 && ((sym.Value + adjustment) & 0xff0000) != 0) {
adjustment = origAdjust; adjustment = origAdjust;
} }
} else if (keepLen == 2) { } else if (keepLen == 2) {