Skip to content

Commit

Permalink
Make label files look more like cc65 output
Browse files Browse the repository at this point in the history
The cc65 docs say VICE labels start with '.'.  Also, output local
labels prefixed with '@', per ca65 convention.  The default output
file is now "labels.lbl".

Added some minimal documentation.

(issue #151)
  • Loading branch information
fadden committed Apr 22, 2024
1 parent 4322a0c commit 9e82ff8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
10 changes: 9 additions & 1 deletion SourceGen/LabelFileGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ public void Generate(StreamWriter outStream) {
// 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) {
outStream.WriteLine("al " + sym.Value.ToString("x6") + " " + sym.Label);
string label = sym.LabelWithoutTag;
if (sym.IsNonUnique) {
// Use the cc65 convention for local labels.
label = '@' + label;
}
// The cc65 docs (https://www.cc65.org/doc/debugging-4.html) say all labels
// must be prefaced with '.'.
label = '.' + label;
outStream.WriteLine("al " + sym.Value.ToString("x6") + " " + label);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions SourceGen/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2566,8 +2566,8 @@ public void GenerateLabels() {
string filter;
switch (dlg.Format) {
case LabelFileGenerator.LabelFmt.VICE:
ext = ".vs";
filter = "VICE commands (*.vs)|*.vs";
ext = ".lbl";
filter = "VICE labels (*.lbl)|*.lbl";
break;
default:
Debug.Assert(false, "bad format");
Expand Down
1 change: 1 addition & 0 deletions SourceGen/Symbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public enum LabelAnnotation {
/// <remarks>
/// Non-unique labels have extra stuff at the end to make them unique. That is
/// included here, so that the Label field is still viable as a unique identifier.
/// Use <see cref="LabelWithoutTag"/> to get just the label.
/// </remarks>
public string Label { get; private set; }

Expand Down
9 changes: 8 additions & 1 deletion docs/sgmanual/codegen.html
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ <h2 id="export-source">Exporting Source Code</h2>
control over which columns are included. The HTML version is augmented
with links and (optionally) images.</p>

<p>Use File &gt; Export to open the export dialog. You have several
<p>Use <samp>File &gt; Export</samp> to open the export dialog. You have several
options:</p>
<ul>
<li><b>Include only selected lines</b>. This allows you to choose between
Expand Down Expand Up @@ -425,6 +425,13 @@ <h2 id="export-source">Exporting Source Code</h2>
<p>All output uses UTF-8 encoding. Filenames of HTML files will have '#'
replaced with '_' to make linking easier.</p>


<h2 id="generate-labels">Generating Label Files</h2>
<p>Some debuggers allow the import of labels associated with addresses.
To generate such a file, use <samp>File &gt; Generate Label File</samp>.</p>
<p>Select the desired output format (currently only VICE label commands
are supported), and whether or not to include auto-generated labels.</p>

</div>

<div id="footer">
Expand Down
1 change: 1 addition & 0 deletions docs/sgmanual/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ <h2>Contents</h2>
</ul></li>
</ul></li>
<li><a href="codegen.html#export-source">Exporting Source Code</a>
<li><a href="codegen.html#generate-labels">Generating Label Files</a>
</ul></li>

<li><a href="settings.html">Properties &amp; Settings</a>
Expand Down

0 comments on commit 9e82ff8

Please sign in to comment.