Skip to content

Commit

Permalink
Add "omit implicit acc operand" feature
Browse files Browse the repository at this point in the history
By default, implicit acc operands are shown, e.g. "LSR A" rather
than just "LSR".  I like showing operands for instructions that
have multiple address modes.

Not everyone agrees, so now it's a setting.  They're shown by default,
but enabling the option will strip them on-screen, in generated
assembly, and in the instruction chart.

They are always omitted for ACME output, which doesn't allow them.

(issue #162)
  • Loading branch information
fadden committed Sep 15, 2024
1 parent 6c2eee8 commit ec9017c
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions SourceGen/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public class AppSettings {
public const string SRCGEN_ADD_IDENT_COMMENT = "srcgen-add-ident-comment";
public const string SRCGEN_LABEL_NEW_LINE = "srcgen-label-new-line";
public const string SRCGEN_SHOW_CYCLE_COUNTS = "srcgen-show-cycle-counts";
public const string SRCGEN_OMIT_IMPLIED_ACC_OPERAND = "srcgen-omit-implied-acc-operand";

// Label file generation settings.
public const string LABGEN_FORMAT = "labgen-format";
Expand Down
2 changes: 1 addition & 1 deletion SourceGen/AsmGen/AsmAcme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void Configure(DisasmProject project, string workDirectory, string fileNa
/// Configures the assembler-specific format items.
/// </summary>
private void SetFormatConfigValues(ref Formatter.FormatConfig config) {
config.SuppressImpliedAcc = true;
config.SuppressImpliedAcc = true; // implied acc not allowed

config.OperandWrapLen = 64;
config.ForceDirectOpcodeSuffix = "+1";
Expand Down
2 changes: 2 additions & 0 deletions SourceGen/AsmGen/GenCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ public static void ConfigureFormatterFromSettings(AppSettings settings,
settings.GetBool(AppSettings.FMT_ADD_SPACE_FULL_COMMENT, true);
config.OperandWrapLen =
settings.GetInt(AppSettings.FMT_OPERAND_WRAP_LEN, 0);
config.SuppressImpliedAcc =
settings.GetBool(AppSettings.SRCGEN_OMIT_IMPLIED_ACC_OPERAND, false);

config.ForceAbsOpcodeSuffix =
settings.GetString(AppSettings.FMT_OPCODE_SUFFIX_ABS, string.Empty);
Expand Down
2 changes: 2 additions & 0 deletions SourceGen/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ public void ApplyAppSettings() {
settings.GetString(AppSettings.FMT_LOCAL_VARIABLE_PREFIX, string.Empty);
mFormatterConfig.CommaSeparatedDense =
settings.GetBool(AppSettings.FMT_COMMA_SEP_BULK_DATA, true);
mFormatterConfig.SuppressImpliedAcc =
settings.GetBool(AppSettings.SRCGEN_OMIT_IMPLIED_ACC_OPERAND, false);
mFormatterConfig.DebugLongComments = DebugLongComments;

string chrDelCereal = settings.GetString(AppSettings.FMT_CHAR_DELIM, null);
Expand Down
2 changes: 2 additions & 0 deletions SourceGen/Tests/GenTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ private AppSettings CreateNormalizedSettings() {
// This could be on or off. Off seems less distracting.
settings.SetBool(AppSettings.SRCGEN_SHOW_CYCLE_COUNTS, false);

settings.SetBool(AppSettings.SRCGEN_OMIT_IMPLIED_ACC_OPERAND, false);

IEnumerator<AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();
while (iter.MoveNext()) {
AssemblerInfo.Id asmId = iter.Current.AssemblerId;
Expand Down
2 changes: 2 additions & 0 deletions SourceGen/WpfGui/EditAppSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,8 @@ limitations under the License.
IsChecked="{Binding ShowCycleCountsAsm}"/>
<CheckBox Content="Identify assembler in output" Margin="0,4,0,0"
IsChecked="{Binding AddIdentComment}"/>
<CheckBox Content="Omit implied accumulator operands if allowed" Margin="0,4,0,0"
IsChecked="{Binding OmitImpliedAccOperand}"/>
<StackPanel Orientation="Vertical" Margin="0,6,0,0">
<TextBlock Text="Put labels on their own line..."/>
<RadioButton GroupName="labelLineGroup" Margin="4,4,0,0"
Expand Down
8 changes: 8 additions & 0 deletions SourceGen/WpfGui/EditAppSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,14 @@ public bool AddIdentComment {
IsDirty = true;
}
}
public bool OmitImpliedAccOperand {
get { return mSettings.GetBool(AppSettings.SRCGEN_OMIT_IMPLIED_ACC_OPERAND, false); }
set {
mSettings.SetBool(AppSettings.SRCGEN_OMIT_IMPLIED_ACC_OPERAND, value);
OnPropertyChanged();
IsDirty = true;
}
}

// label placement radio buttons
public bool LabelPlacement_PreferSameLine {
Expand Down
11 changes: 10 additions & 1 deletion docs/sgmanual/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ <h3 id="appset-asmconfig">Asm Config</h3>
of the next column will be pushed over. (The comment field width is
not currently being used, but may be used to fold lines in the future.)</p>

<p>The Code Generation Settings affect all assemblers.</p>
<p>The next section, Code Generation Settings, affects all assemblers.</p>

<p>When <samp>show cycle counts in comments</samp> is checked, cycle
counts are inserted into end-of-line comments. This works the same as
Expand All @@ -229,6 +229,15 @@ <h3 id="appset-asmconfig">Asm Config</h3>
the source file what the intended target assembler is, or what options
are required to process the file correctly.</p>

<p>Some 6502 instructions have an "implied" accumulator address mode, e.g.
<code>LSR</code> and <code>ASL</code>. The operand may be shown as
"<code>A</code>" to make the address mode explicit, but it can also be
omitted. Some assemblers require it to be present, some require it to be
absent, most allow either. By default, the operand is shown, but enabling
<samp>omit implied accumulator operands if allowed</samp> will cause it to
be omitted on-screen, in the instruction chart, and in source generated for
assemblers that don't require it to be present.</p>

<p>Labels can generally be placed either on the same line as a code or data
operand, or on the line before it. Placing them on the same line makes
the output a bit more compact, but if the label is longer than the label
Expand Down

0 comments on commit ec9017c

Please sign in to comment.