1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-23 16:29:34 +00:00

Add VarDirective to PseudoOpNames

Also, rearranged the pseudo-op app settings XAML to be a bit easier
to maintain.
This commit is contained in:
Andy McFadden 2019-08-29 12:14:47 -07:00
parent 0ed1547e79
commit e82339573f
9 changed files with 118 additions and 83 deletions

View File

@ -106,6 +106,7 @@ namespace SourceGen.AsmGen {
private static PseudoOp.PseudoOpNames sDataOpNames =
new PseudoOp.PseudoOpNames(new Dictionary<string, string> {
{ "EquDirective", "=" },
//VarDirective
{ "OrgDirective", "!pseudopc" },
//RegWidthDirective // !al, !as, !rl, !rs
{ "DefineData1", "!byte" },
@ -470,6 +471,11 @@ namespace SourceGen.AsmGen {
valueStr, SourceFormatter.FormatEolComment(comment));
}
// IGenerator
public void OutputVarDirective(string name, string valueStr, string comment) {
OutputEquDirective(name, valueStr, comment);
}
// IGenerator
public void OutputOrgDirective(int offset, int address) {
// For the first one, set the "real" PC. For all subsequent directives, set the

View File

@ -103,6 +103,7 @@ namespace SourceGen.AsmGen {
private static PseudoOp.PseudoOpNames sDataOpNames =
new PseudoOp.PseudoOpNames(new Dictionary<string, string> {
{ "EquDirective", "=" },
//VarDirective
{ "OrgDirective", ".org" },
//RegWidthDirective // .a8, .a16, .i8, .i16
{ "DefineData1", ".byte" },
@ -504,6 +505,11 @@ namespace SourceGen.AsmGen {
valueStr, SourceFormatter.FormatEolComment(comment));
}
// IGenerator
public void OutputVarDirective(string name, string valueStr, string comment) {
OutputEquDirective(name, valueStr, comment);
}
// IGenerator
public void OutputOrgDirective(int offset, int address) {
// Linear search for offset. List should be small, so this should be quick.

View File

@ -94,6 +94,7 @@ namespace SourceGen.AsmGen {
private static PseudoOp.PseudoOpNames sDataOpNames =
new PseudoOp.PseudoOpNames(new Dictionary<string, string> {
{ "EquDirective", "equ" },
{ "VarDirective", "~=" }, // not really
{ "OrgDirective", "org" },
//RegWidthDirective
{ "DefineData1", "dfb" },
@ -397,6 +398,12 @@ namespace SourceGen.AsmGen {
valueStr, SourceFormatter.FormatEolComment(comment));
}
// IGenerator
public void OutputVarDirective(string name, string valueStr, string comment) {
OutputLine("]" + name, SourceFormatter.FormatPseudoOp(sDataOpNames.EquDirective),
valueStr, SourceFormatter.FormatEolComment(comment));
}
// IGenerator
public void OutputOrgDirective(int offset, int address) {
OutputLine(string.Empty, SourceFormatter.FormatPseudoOp(sDataOpNames.OrgDirective),

View File

@ -120,6 +120,7 @@ namespace SourceGen.AsmGen {
private static PseudoOp.PseudoOpNames sDataOpNames =
new PseudoOp.PseudoOpNames(new Dictionary<string, string> {
{ "EquDirective", "=" },
{ "VarDirective", ".var" },
{ "OrgDirective", ".logical" },
//RegWidthDirective // .as, .al, .xs, .xl
{ "DefineData1", ".byte" },
@ -535,6 +536,12 @@ namespace SourceGen.AsmGen {
valueStr, SourceFormatter.FormatEolComment(comment));
}
// IGenerator
public void OutputVarDirective(string name, string valueStr, string comment) {
OutputLine(name, SourceFormatter.FormatPseudoOp(sDataOpNames.VarDirective),
valueStr, SourceFormatter.FormatEolComment(comment));
}
// IGenerator
public void OutputOrgDirective(int offset, int address) {
// 64tass separates the "compile offset", which determines where the output fits

View File

@ -136,6 +136,14 @@ namespace SourceGen.AsmGen {
/// <param name="comment">End-of-line comment.</param>
void OutputEquDirective(string name, string valueStr, string comment);
/// <summary>
/// Outputs a variable definition directive. The numeric value is already formatted.
/// </summary>
/// <param name="name">Symbol label.</param>
/// <param name="valueStr">Formatted value.</param>
/// <param name="comment">End-of-line comment.</param>
void OutputVarDirective(string name, string valueStr, string comment);
/// <summary>
/// Outputs a code origin directive.
/// </summary>

View File

@ -1331,7 +1331,7 @@ namespace SourceGen {
PseudoOp.FormatNumericOpFlags.None);
string comment = mFormatter.FormatEolComment(defSym.Comment);
return FormattedParts.CreateEquDirective(defSym.Label,
mFormatter.FormatPseudoOp(mPseudoOpNames.EquDirective),
mFormatter.FormatPseudoOp(mPseudoOpNames.VarDirective),
addrStr, comment);
}
}

View File

@ -65,6 +65,7 @@ namespace SourceGen {
/// </summary>
public class PseudoOpNames {
public string EquDirective { get; private set; }
public string VarDirective { get; private set; }
public string OrgDirective { get; private set; }
public string RegWidthDirective { get; private set; }
@ -85,10 +86,9 @@ namespace SourceGen {
public string StrDci { get; private set; }
/// <summary>
/// Constructs an empty PseudoOp.
/// Constructs an empty PseudoOp, for deserialization.
/// </summary>
public PseudoOpNames() : this(new Dictionary<string, string>()) {
}
public PseudoOpNames() : this(new Dictionary<string, string>()) { }
/// <summary>
/// Constructor. Pass in a dictionary with name/value pairs. Unknown names
@ -113,6 +113,7 @@ namespace SourceGen {
return false; // one is null
}
return a.EquDirective == b.EquDirective &&
a.VarDirective == b.VarDirective &&
a.OrgDirective == b.OrgDirective &&
a.RegWidthDirective == b.RegWidthDirective &&
a.DefineData1 == b.DefineData1 &&
@ -217,12 +218,10 @@ namespace SourceGen {
/// <summary>
/// Returns a PseudoOpNames instance with some reasonable defaults for on-screen display.
/// </summary>
public static PseudoOpNames DefaultPseudoOpNames {
get { return sDefaultPseudoOpNames; }
}
private static readonly PseudoOpNames sDefaultPseudoOpNames =
public static PseudoOpNames DefaultPseudoOpNames { get; } =
new PseudoOpNames(new Dictionary<string, string> {
{ "EquDirective", ".eq" },
{ "VarDirective", ".var" },
{ "OrgDirective", ".org" },
{ "RegWidthDirective", ".rwid" },

View File

@ -592,13 +592,10 @@ limitations under the License.
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.8*"/>
<ColumnDefinition Width="0"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.8*"/>
<ColumnDefinition Width="0"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.8*"/>
<ColumnDefinition Width="0"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.8*"/>
</Grid.ColumnDefinitions>
@ -611,114 +608,118 @@ limitations under the License.
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- first column -->
<!-- first row -->
<TextBlock Grid.Column="0" Grid.Row="0" Text="Equate:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<StackPanel Grid.Column="0" Grid.Row="1" VerticalAlignment="Center">
<TextBlock Text="Little-endian" HorizontalAlignment="Right"/>
<TextBlock Text="data, one byte:" HorizontalAlignment="Right"/>
</StackPanel>
<StackPanel Grid.Column="0" Grid.Row="2" VerticalAlignment="Center">
<TextBlock Text="Big-endian data," HorizontalAlignment="Right"/>
<TextBlock Text="two bytes:" HorizontalAlignment="Right"/>
</StackPanel>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Generic str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="0" Grid.Row="4" Text="1-byte len str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="equDirectiveTextBox" Grid.Column="1" Grid.Row="0"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="defineData1TextBox" Grid.Column="1" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="defineBigData2TextBox" Grid.Column="1" Grid.Row="2"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strGenericTextBox" Grid.Column="1" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strLen8TextBox" Grid.Column="1" Grid.Row="4"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<!-- second column -->
<TextBlock Grid.Column="3" Grid.Row="0" Text="Origin:"
<TextBlock Grid.Column="2" Grid.Row="0" Text="Variable:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="3" Grid.Row="1" Text="Two bytes:"
<TextBox Name="varDirectiveTextBox" Grid.Column="3" Grid.Row="0"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Grid.Column="4" Grid.Row="0" Text="Origin:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="3" Grid.Row="3" Text="Reverse str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="3" Grid.Row="4" Text="2-byte len str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="orgDirectiveTextBox" Grid.Column="4" Grid.Row="0"
<TextBox Name="orgDirectiveTextBox" Grid.Column="5" Grid.Row="0"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="defineData2TextBox" Grid.Column="4" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strReverseTextBox" Grid.Column="4" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strLen16TextBox" Grid.Column="4" Grid.Row="4"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<!-- third column -->
<TextBlock Grid.Column="6" Grid.Row="0" Text="Reg width:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="6" Grid.Row="1" Text="Three bytes:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="6" Grid.Row="2" Text="Fill:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="6" Grid.Row="3" Text="Null-term str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="regWidthDirectiveTextBox" Grid.Column="7" Grid.Row="0"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="defineData3TextBox" Grid.Column="7" Grid.Row="1"
<!-- second row -->
<StackPanel Grid.Column="0" Grid.Row="1" VerticalAlignment="Center">
<TextBlock Text="Little-endian" HorizontalAlignment="Right"/>
<TextBlock Text="data, one byte:" HorizontalAlignment="Right"/>
</StackPanel>
<TextBox Name="defineData1TextBox" Grid.Column="1" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="fillTextBox" Grid.Column="7" Grid.Row="2"
<TextBlock Grid.Column="2" Grid.Row="1" Text="Two bytes:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="defineData2TextBox" Grid.Column="3" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strNullTermTextBox" Grid.Column="7" Grid.Row="3"
<TextBlock Grid.Column="4" Grid.Row="1" Text="Three bytes:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="defineData3TextBox" Grid.Column="5" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Grid.Column="6" Grid.Row="1" Text="Four bytes:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="defineData4TextBox" Grid.Column="7" Grid.Row="1"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<!-- fourth column -->
<TextBlock Grid.Column="9" Grid.Row="1" Text="Four bytes:"
<!-- third row -->
<StackPanel Grid.Column="0" Grid.Row="2" VerticalAlignment="Center">
<TextBlock Text="Big-endian data," HorizontalAlignment="Right"/>
<TextBlock Text="two bytes:" HorizontalAlignment="Right"/>
</StackPanel>
<TextBox Name="defineBigData2TextBox" Grid.Column="1" Grid.Row="2"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Grid.Column="4" Grid.Row="2" Text="Fill:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="9" Grid.Row="2" Text="Bulk data:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBlock Grid.Column="9" Grid.Row="3" Text="DCI str:"
<TextBox Name="fillTextBox" Grid.Column="5" Grid.Row="2"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Grid.Column="6" Grid.Row="2" Text="Bulk data:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="denseTextBox" Grid.Column="7" Grid.Row="2"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="defineData4TextBox" Grid.Column="10" Grid.Row="1"
<!-- fourth row -->
<TextBlock Grid.Column="0" Grid.Row="3" Text="Generic str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="strGenericTextBox" Grid.Column="1" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="denseTextBox" Grid.Column="10" Grid.Row="2"
<TextBlock Grid.Column="2" Grid.Row="3" Text="Reverse str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="strReverseTextBox" Grid.Column="3" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBox Name="strDciTextBox" Grid.Column="10" Grid.Row="3"
<TextBlock Grid.Column="4" Grid.Row="3" Text="Null-term str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="strNullTermTextBox" Grid.Column="5" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Grid.Column="6" Grid.Row="3" Text="DCI str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="strDciTextBox" Grid.Column="7" Grid.Row="3"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<!-- fifth row -->
<TextBlock Grid.Column="0" Grid.Row="4" Text="1-byte len str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="strLen8TextBox" Grid.Column="1" Grid.Row="4"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Grid.Column="2" Grid.Row="4" Text="2-byte len str:"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<TextBox Name="strLen16TextBox" Grid.Column="3" Grid.Row="4"
VerticalAlignment="Center" Margin="{StaticResource TBS}"
Text=".placeho" MaxLength="12"
FontFamily="{StaticResource GeneralMonoFont}"/>

View File

@ -139,6 +139,7 @@ namespace SourceGen.WpfGui {
// Map text boxes to PseudoOpName fields.
mPseudoNameMap = new TextBoxPropertyMap[] {
new TextBoxPropertyMap(equDirectiveTextBox, "EquDirective"),
new TextBoxPropertyMap(varDirectiveTextBox, "VarDirective"),
new TextBoxPropertyMap(orgDirectiveTextBox, "OrgDirective"),
new TextBoxPropertyMap(regWidthDirectiveTextBox, "RegWidthDirective"),
new TextBoxPropertyMap(defineData1TextBox, "DefineData1"),