Skip to content

Commit

Permalink
Tweak label file generation
Browse files Browse the repository at this point in the history
Include an altered version of the uniquified local label, so that
VICE will keep the full set.

(issue #151)
  • Loading branch information
fadden committed Apr 30, 2024
1 parent 948e4a2 commit ca38b77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions SourceGen/LabelFileGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,21 @@ public void Generate(StreamWriter outStream) {
// 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));

Debug.Assert(mFormat == LabelFmt.VICE);

// VICE format is "add_label <address> <label>", but may be abbreviated "al".
// We could also use ACME format ("labelname = $1234 ; Maybe a comment").
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) {
// Use the cc65 convention for local labels.
// Add the cc65 prefix convention for local labels.
label = '@' + label;
}
// 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;
outStream.WriteLine("al " + sym.Value.ToString("x6") + " " + label);
}
Expand Down
2 changes: 1 addition & 1 deletion SourceGen/Symbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace SourceGen {
/// </summary>
public class Symbol {
public const char UNCERTAIN_CHAR = '?';
public const char UNIQUE_TAG_CHAR = '\u00a7'; // SECTION SIGN
private const char NO_ANNO_CHAR = '\ufffd'; // REPLACEMENT CHARACTER '�'
private const char UNIQUE_TAG_CHAR = '\u00a7'; // SECTION SIGN
private const int NON_UNIQUE_LEN = 7; // NON_UNIQUE_CHAR + 6 hex digits

/// <summary>
Expand Down

0 comments on commit ca38b77

Please sign in to comment.