1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-09-30 23:55:09 +00:00

Limit value range of project address symbols

Project symbol address values are now limited to positive 24-bit
integers, just as they are for platform symbols.  Constants may
still be 32-bit values.
This commit is contained in:
Andy McFadden 2019-10-27 12:26:34 -07:00
parent 819a363178
commit 70353c82e1
5 changed files with 21 additions and 6 deletions

View File

@ -173,7 +173,8 @@ namespace SourceGen {
bool parseOk;
string valueStr = matches[0].Groups[GROUP_VALUE].Value;
if (isConst) {
// Allow various numeric options, and preserve the value.
// Allow various numeric options, and preserve the value. We
// don't limit the value range.
parseOk = Asm65.Number.TryParseInt(valueStr, out value, out numBase);
badParseMsg =
CommonUtil.Properties.Resources.ERR_INVALID_NUMERIC_CONSTANT;

View File

@ -72,7 +72,8 @@ written.</p>
binary (with a leading '%'). The numeric base will be recorded and used when
formatting the symbol in generated output, so use whichever form is most
appropriate. Values are unsigned 24-bit numbers. The special value
"erase" may be used to erase a symbol defined in an earlier platform file.</p>
"erase" may be used for an address to erase a symbol defined in an earlier
platform file.</p>
<p>The WIDTH is optional, and ignored for constants. It must be a
decimal or hexadecimal value between 1 and 65536, inclusive. If omitted,

View File

@ -483,8 +483,8 @@ value, the one whose label comes first alphabetically is used.</p>
<p>Project symbols always have precedence over platform symbols, allowing
you to redefine symbols within a project. (You can "hide" a platform
symbol by creating a project symbol with the same name and an unused
value, such as $ffffffff.)</p>
symbol by creating a project symbol constant with the same name. Use a
value like $ffffffff or $deadbeef so you'll know why it's there.)</p>
<p><b>Local variables</b> are redefinable symbols that are organized
into tables. They're used to specify labels for zero-page and 65816

View File

@ -23,7 +23,7 @@ limitations under the License.
xmlns:local="clr-namespace:SourceGen.WpfGui"
mc:Ignorable="d"
Title="Edit Symbol"
SizeToContent="Height" Width="350" ResizeMode="NoResize"
SizeToContent="Height" Width="360" ResizeMode="NoResize"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded"
ContentRendered="Window_ContentRendered">
@ -77,6 +77,8 @@ limitations under the License.
IsReadOnly="{Binding ReadOnlyValueAndType}"/>
<TextBlock Name="varValueRangeLabel" Text="• Value between 0-255, including width" Margin="0,4,0,0"
Visibility="{Binding IsVariable, Converter={StaticResource BoolToVis}}"/>
<TextBlock Name="addrValueRangeLabel" Text="• Address between 00/0000 - ff/ffff, incl. width" Margin="0,4,0,0"
Visibility="{Binding IsNotVariable, Converter={StaticResource BoolToVis}}"/>
<TextBlock Name="varValueUniqueLabel" Text="• Values in table must not overlap" Margin="0,4,0,0"
Visibility="{Binding IsVariable, Converter={StaticResource BoolToVis}}"/>
<TextBlock Name="valueNotesLabel" Text="• Decimal, hex ($), or binary (%)" Margin="0,4,0,0"/>

View File

@ -190,7 +190,7 @@ namespace SourceGen.WpfGui {
Label = Value = VarWidth = Comment = string.Empty;
int maxWidth;
int maxWidth, maxAddr;
if (isVariable) {
ConstantLabel = (string)FindResource("str_VariableConstant");
maxWidth = 256;
@ -302,6 +302,16 @@ namespace SourceGen.WpfGui {
if (thisValue < 0 || thisValue + thisWidth > 256) {
valueRangeValid = false;
}
} else if (IsAddress && valueValid) {
// limit to positive 24-bit integers; use a long for value+width so we
// don't get fooled by overflow
long lvalue = thisValue;
if (thisWidth > 0) {
lvalue += thisWidth - 1;
}
if (thisValue < 0 || lvalue > 0x00ffffff) {
valueRangeValid = false;
}
}
Symbol.Type symbolType = IsConstant ? Symbol.Type.Constant : Symbol.Type.ExternalAddr;
@ -328,6 +338,7 @@ namespace SourceGen.WpfGui {
labelUniqueLabel.Foreground = projectLabelUniqueLabel.Foreground =
labelUnique ? mDefaultLabelColor : Brushes.Red;
valueNotesLabel.Foreground = valueValid ? mDefaultLabelColor : Brushes.Red;
addrValueRangeLabel.Foreground = valueRangeValid ? mDefaultLabelColor : Brushes.Red;
varValueRangeLabel.Foreground = valueRangeValid ? mDefaultLabelColor : Brushes.Red;
varValueUniqueLabel.Foreground = valueUniqueValid ? mDefaultLabelColor : Brushes.Red;
widthNotesLabel.Foreground = widthValid ? mDefaultLabelColor : Brushes.Red;