1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-18 15:06:07 +00:00

Tweak label file generation

Include an altered version of the uniquified local label, so that
VICE will keep the full set.

(issue #151)
This commit is contained in:
Andy McFadden 2024-04-30 13:27:07 -07:00
parent 948e4a2bf2
commit ca38b7751c
2 changed files with 9 additions and 4 deletions

View File

@ -67,16 +67,21 @@ namespace SourceGen {
// Sort alphabetically. Not necessary, but it could make a "diff" easier to read. // Sort alphabetically. Not necessary, but it could make a "diff" easier to read.
symList.Sort((a, b) => Symbol.Compare(Symbol.SymbolSortField.Name, true, a, b)); symList.Sort((a, b) => Symbol.Compare(Symbol.SymbolSortField.Name, true, a, b));
Debug.Assert(mFormat == LabelFmt.VICE);
// VICE format is "add_label <address> <label>", but may be abbreviated "al". // VICE format is "add_label <address> <label>", but may be abbreviated "al".
// We could also use ACME format ("labelname = $1234 ; Maybe a comment"). // We could also use ACME format ("labelname = $1234 ; Maybe a comment").
foreach (Symbol sym in symList) { foreach (Symbol sym in symList) {
string label = sym.LabelWithoutTag; // VICE only keeps one copy of each label, so local labels need to include the
// uniquifier. The UNIQUE_TAG_CHAR may not be accepted, so replace it with '_'.
string label = sym.Label;
label = label.Replace(Symbol.UNIQUE_TAG_CHAR, '_');
if (sym.IsNonUnique) { if (sym.IsNonUnique) {
// Use the cc65 convention for local labels. // Add the cc65 prefix convention for local labels.
label = '@' + label; label = '@' + label;
} }
// The cc65 docs (https://www.cc65.org/doc/debugging-4.html) say all labels // The cc65 docs (https://www.cc65.org/doc/debugging-4.html) say all labels
// must be prefaced with '.'. // must be prefaced with '.'. VICE rejects labels that start with a letter.
label = '.' + label; label = '.' + label;
outStream.WriteLine("al " + sym.Value.ToString("x6") + " " + label); outStream.WriteLine("al " + sym.Value.ToString("x6") + " " + label);
} }

View File

@ -23,8 +23,8 @@ namespace SourceGen {
/// </summary> /// </summary>
public class Symbol { public class Symbol {
public const char UNCERTAIN_CHAR = '?'; public const char UNCERTAIN_CHAR = '?';
public const char UNIQUE_TAG_CHAR = '\u00a7'; // SECTION SIGN
private const char NO_ANNO_CHAR = '\ufffd'; // REPLACEMENT CHARACTER '<27>' private const char NO_ANNO_CHAR = '\ufffd'; // REPLACEMENT CHARACTER '<27>'
private const char UNIQUE_TAG_CHAR = '\u00a7'; // SECTION SIGN
private const int NON_UNIQUE_LEN = 7; // NON_UNIQUE_CHAR + 6 hex digits private const int NON_UNIQUE_LEN = 7; // NON_UNIQUE_CHAR + 6 hex digits
/// <summary> /// <summary>