diff --git a/README.md b/README.md
index 7a9fa16..6b65a12 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
6502.Net, A .Net-Based Cross-Assembler for Several 8-Bit Microprocessors.
-Version 3.1
+Version 3.1.1
## Overview
diff --git a/Sixty502DotNet.Tests/Sixty502DotNet.Tests.csproj b/Sixty502DotNet.Tests/Sixty502DotNet.Tests.csproj
index d221078..8859305 100644
--- a/Sixty502DotNet.Tests/Sixty502DotNet.Tests.csproj
+++ b/Sixty502DotNet.Tests/Sixty502DotNet.Tests.csproj
@@ -4,13 +4,13 @@
net5.0
false
- 3.1.0.1
+ 3.1.1.1
-
-
-
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/Sixty502DotNet.sln b/Sixty502DotNet.sln
index c7458a8..2ff45b5 100644
--- a/Sixty502DotNet.sln
+++ b/Sixty502DotNet.sln
@@ -40,7 +40,7 @@ Global
SolutionGuid = {9BE7575F-6E99-4243-AEAA-4D1E1064DA97}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
- version = 3.1.0.1
+ version = 3.1.1.1
Policies = $0
$0.VersionControlPolicy = $1
$1.CommitMessageStyle = $2
diff --git a/Sixty502DotNet/Sixty502DotNet.csproj b/Sixty502DotNet/Sixty502DotNet.csproj
index df2685e..40c7d71 100644
--- a/Sixty502DotNet/Sixty502DotNet.csproj
+++ b/Sixty502DotNet/Sixty502DotNet.csproj
@@ -5,17 +5,17 @@
net5.0
Major
6502.Net
- 3.1.0.1
+ 3.1.1.1
informedcitizenry
informedcitizenry
6502.Net
6502.Net, A .Net Cross Assembler for Several 8-Bit Microprocessors.
(C) Copyright 2017-2022 informedcitizenry
- 3.1.0.1
+ 3.1.1.1
Sixty502DotNet.Program
6502.Net
- 3.1.0.1
- 3.1.0.1
+ 3.1.1.1
+ 3.1.1.1
false
8.0
enable
diff --git a/Sixty502DotNet/src/ExpressionEvaluation/Converters/BinaryConverter.cs b/Sixty502DotNet/src/ExpressionEvaluation/Converters/BinaryConverter.cs
index 796bb65..6eb80b0 100644
--- a/Sixty502DotNet/src/ExpressionEvaluation/Converters/BinaryConverter.cs
+++ b/Sixty502DotNet/src/ExpressionEvaluation/Converters/BinaryConverter.cs
@@ -49,7 +49,7 @@ public class BinaryDoubleConverter : ICustomConverter
public Value Convert(string str)
{
string bString = str[0] == '%' ? str[1..] : str[2..];
- return new Value(NumberConverter.GetDoubleAtBase(bString, 2));
+ return NumberConverter.GetDoubleAtBase(bString, 2);
}
}
}
diff --git a/Sixty502DotNet/src/ExpressionEvaluation/Converters/HexConverter.cs b/Sixty502DotNet/src/ExpressionEvaluation/Converters/HexConverter.cs
index 4961125..3e9b49b 100644
--- a/Sixty502DotNet/src/ExpressionEvaluation/Converters/HexConverter.cs
+++ b/Sixty502DotNet/src/ExpressionEvaluation/Converters/HexConverter.cs
@@ -19,7 +19,7 @@ public Value Convert(string str)
Value hexVal = str[0] == '$' ?
new Value(System.Convert.ToInt64(str[1..], 16)) :
new Value(System.Convert.ToInt64(str[2..], 16));
- return Evaluator.ConvertToIntegral(hexVal);
+ return NumberConverter.ConvertToIntegral(hexVal);
}
}
@@ -32,7 +32,7 @@ public class HexDoubleConverter : ICustomConverter
public Value Convert(string str)
{
var hString = str[0] == '$' ? str[1..] : str[2..];
- return new Value(NumberConverter.GetDoubleAtBase(hString, 16));
+ return NumberConverter.GetDoubleAtBase(hString, 16);
}
}
}
diff --git a/Sixty502DotNet/src/ExpressionEvaluation/Converters/NumberConverter.cs b/Sixty502DotNet/src/ExpressionEvaluation/Converters/NumberConverter.cs
index 1427de3..9bb0bd8 100644
--- a/Sixty502DotNet/src/ExpressionEvaluation/Converters/NumberConverter.cs
+++ b/Sixty502DotNet/src/ExpressionEvaluation/Converters/NumberConverter.cs
@@ -28,7 +28,7 @@ public class NumberConverter : ICustomConverter
/// The non-decimal string.
/// The number base.
/// The converted string as a double.
- public static double GetDoubleAtBase(string str, int atBase)
+ public static Value GetDoubleAtBase(string str, int atBase)
{
var regex = atBase == 16 ? s_hexDoubleParserRegex : s_nonHexDoubleParserRegex;
var mantissaExponent = regex.Match(str.Replace("_", ""));
@@ -40,10 +40,33 @@ public static double GetDoubleAtBase(string str, int atBase)
if (mantissaExponent.Groups.Count > 2 && mantissaExponent.Groups[3].Success)
{
var base_ = mantissaExponent.Groups[2].Value.ToLower()[0] == 'e' ? 10 : 2;
- var exponentent = double.Parse(mantissaExponent.Groups[3].Value);
- return mantissa * Math.Pow(base_, exponentent);
+ var exponent = double.Parse(mantissaExponent.Groups[3].Value);
+ return new Value(mantissa * Math.Pow(base_, exponent));
}
- return mantissa;
+ return new Value(mantissa);
+ }
+
+ ///
+ /// Convert a to an or
+ /// if the converted value is able to be converted.
+ /// Otherwise, the returned value is the original value itself.
+ ///
+ /// The as an .
+ ///
+ /// The converted or as an
+ /// if conversion was successful, otherwise the
+ /// original value itself.
+ public static Value ConvertToIntegral(Value value)
+ {
+ if (value.ToDouble() >= int.MinValue && value.ToDouble() <= uint.MaxValue)
+ {
+ if (value.ToDouble() <= int.MaxValue)
+ {
+ return new Value(unchecked((int)(value.ToLong() & 0xFFFF_FFFF)));
+ }
+ return new Value((uint)(value.ToLong() & 0xFFFF_FFFF));
+ }
+ return value;
}
public Value Convert(string str)
@@ -53,15 +76,15 @@ public Value Convert(string str)
{
if (!char.IsDigit(str[1]))
{
- return Evaluator.ConvertToIntegral(new Value(System.Convert.ToInt64(str[2..], 8)));
+ return ConvertToIntegral(new Value(System.Convert.ToInt64(str[2..], 8)));
}
- return Evaluator.ConvertToIntegral(new Value(System.Convert.ToInt64(str, 8)));
+ return ConvertToIntegral(new Value(System.Convert.ToInt64(str, 8)));
}
var numVal = new Value(System.Convert.ToDouble(str));
bool isDouble = str.IndexOf('.') > -1 || str.IndexOf('e') > -1 || str.IndexOf('E') > -1;
if (!isDouble)
{
- return Evaluator.ConvertToIntegral(numVal);
+ return ConvertToIntegral(numVal);
}
return numVal;
}
@@ -76,7 +99,7 @@ public class OctalDoubleConverter : ICustomConverter
public Value Convert(string str)
{
string octalStr = !char.IsDigit(str[1]) ? str[2..] : str[1..];
- return new Value(NumberConverter.GetDoubleAtBase(octalStr, 8));
+ return NumberConverter.GetDoubleAtBase(octalStr, 8);
}
}
}
diff --git a/Sixty502DotNet/src/ExpressionEvaluation/Evaluator.cs b/Sixty502DotNet/src/ExpressionEvaluation/Evaluator.cs
index d19edc1..54dadfe 100644
--- a/Sixty502DotNet/src/ExpressionEvaluation/Evaluator.cs
+++ b/Sixty502DotNet/src/ExpressionEvaluation/Evaluator.cs
@@ -347,29 +347,6 @@ public static Value CondOp(Value cond, Value then, Value els)
throw new InvalidOperationException(Errors.TypeMismatchError);
}
- ///
- /// Convert a to an or
- /// if the converted value is able to be converted.
- /// Otherwise, the returned value is the original value itself.
- ///
- /// The as an .
- ///
- /// The converted or as an
- /// if conversion was successful, otherwise the
- /// original value itself.
- public static Value ConvertToIntegral(Value value)
- {
- if (value.ToDouble() >= int.MinValue && value.ToDouble() <= uint.MaxValue)
- {
- if (value.ToDouble() <= int.MaxValue)
- {
- return new Value(unchecked((int)(value.ToLong() & 0xFFFF_FFFF)));
- }
- return new Value((uint)(value.ToLong() & 0xFFFF_FFFF));
- }
- return value;
- }
-
private static bool ExpressionContainsPC(Sixty502DotNetParser.ExprContext context)
{
if (context.refExpr()?.programCounter() != null)
diff --git a/Sixty502DotNet/src/ExpressionEvaluation/ValueTypes/Value.cs b/Sixty502DotNet/src/ExpressionEvaluation/ValueTypes/Value.cs
index 0313161..1c23e0e 100644
--- a/Sixty502DotNet/src/ExpressionEvaluation/ValueTypes/Value.cs
+++ b/Sixty502DotNet/src/ExpressionEvaluation/ValueTypes/Value.cs
@@ -77,7 +77,7 @@ public virtual bool Equals(Value? other)
{
if (IsNumeric && other.IsNumeric == true)
{
- return ToDouble() == other.ToDouble();
+ return Math.Abs(ToDouble() - other.ToDouble()) < 0.0000001;
}
if (IsString && other.IsString || (DotNetType == TypeCode.Char && other.DotNetType == TypeCode.Char))
{
@@ -92,7 +92,14 @@ public virtual bool Equals(Value? other)
/// Get the value's hash code.
///
/// A hash code for the current object.
- public override int GetHashCode() => Data.GetHashCode();
+ public override int GetHashCode()
+ {
+ if (DotNetType != TypeCode.Double)
+ {
+ return Data.GetHashCode();
+ }
+ return Math.Round((double)Data, 7).GetHashCode();
+ }
///
/// Determine if this value is equal to another object.