diff --git a/X86Disassembler/X86/InstructionType.cs b/X86Disassembler/X86/InstructionType.cs index dc7943d..09a1593 100644 --- a/X86Disassembler/X86/InstructionType.cs +++ b/X86Disassembler/X86/InstructionType.cs @@ -136,19 +136,25 @@ public enum InstructionType Fst, // Store floating point value Fstp, // Store floating point value and pop Fadd, // Add floating point + Faddp, // Add floating point and pop Fiadd, // Add integer to floating point Fild, // Load integer to floating point Fist, // Store integer Fistp, // Store integer and pop Fsub, // Subtract floating point + Fsubp, // Subtract floating point and pop Fisub, // Subtract integer from floating point Fsubr, // Subtract floating point reversed + Fsubrp, // Subtract floating point reversed and pop Fisubr, // Subtract floating point from integer (reversed) Fmul, // Multiply floating point + Fmulp, // Multiply floating point and pop Fimul, // Multiply integer with floating point Fdiv, // Divide floating point + Fdivp, // Divide floating point and pop Fidiv, // Divide integer by floating point Fdivr, // Divide floating point reversed + Fdivrp, // Divide floating point reversed and pop Fidivr, // Divide floating point by integer (reversed) Fcom, // Compare floating point Ficom, // Compare integer with floating point @@ -159,6 +165,7 @@ public enum InstructionType Fcomi, // Compare floating point, set EFLAGS Fucom, // Unordered compare floating point Fucomp, // Unordered compare floating point and pop + Fucompp, // Unordered compare floating point and pop twice Fucomip, // Unordered compare floating point and pop, set EFLAGS Fucomi, // Unordered compare floating point, set EFLAGS Ffreep, // Free floating point register and pop @@ -174,9 +181,12 @@ public enum InstructionType Finit, // Initialize FPU (with FWAIT prefix) Fninit, // Initialize FPU without checking for pending unmasked exceptions Fclex, // Clear floating-point exceptions + Fnclex, // Clear floating-point exceptions without checking for pending unmasked exceptions Fldenv, // Load FPU environment Fnstenv, // Store FPU environment Frstor, // Restore FPU state + Fnsave, // Save FPU state without checking for pending unmasked exceptions + Fsave, // Save FPU state // Flag control instructions Stc, // Set Carry Flag @@ -188,27 +198,26 @@ public enum InstructionType Cli, // Clear Interrupt Flag Sahf, // Store AH into Flags Lahf, // Load Flags into AH - Fnsave, // Save FPU state Fxch, // Exchange floating point registers Fchs, // Change sign of floating point value Fabs, // Absolute value of floating point Ftst, // Test floating point F2xm1, // 2^x - 1 Fyl2x, // y * log2(x) + Fyl2xp1, // y * log2(x+1) Fptan, // Partial tangent Fpatan, // Partial arctangent Fxtract, // Extract exponent and significand - Fprem1, // Partial remainder (IEEE) - Fdecstp, // Decrement stack pointer - Fincstp, // Increment stack pointer Fprem, // Partial remainder - Fyl2xp1, // y * log2(x+1) - Fsqrt, // Square root - Fsincos, // Sine and cosine + Fprem1, // Partial remainder (IEEE) + Fdecstp, // Decrement FPU stack pointer + Fincstp, // Increment FPU stack pointer Frndint, // Round to integer Fscale, // Scale by power of 2 Fsin, // Sine Fcos, // Cosine + Fsincos, // Sine and cosine + Fsqrt, // Square root Fnop, // No operation Fwait, // Wait for FPU diff --git a/X86DisassemblerTests/CsvJsonConverter.cs b/X86DisassemblerTests/CsvJsonConverter.cs index 4b5e5b9..887892e 100644 --- a/X86DisassemblerTests/CsvJsonConverter.cs +++ b/X86DisassemblerTests/CsvJsonConverter.cs @@ -1,15 +1,20 @@ -using System.Text.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using CsvHelper; using CsvHelper.Configuration; using CsvHelper.TypeConversion; +using X86Disassembler.X86; namespace X86DisassemblerTests; // ReSharper disable once ClassNeverInstantiated.Global public sealed class CsvJsonConverter : DefaultTypeConverter { - private static JsonSerializerOptions _options = new JsonSerializerOptions() + // Configure JSON options with case-insensitive enum handling + private static readonly JsonSerializerOptions _options = new JsonSerializerOptions { + PropertyNameCaseInsensitive = true, + Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) } }; public override object? ConvertFromString(string? text, IReaderRow row, MemberMapData memberMapData) @@ -19,11 +24,11 @@ public sealed class CsvJsonConverter : DefaultTypeConverter return null; } - return JsonSerializer.Deserialize(text); + return JsonSerializer.Deserialize(text, _options); } public override string? ConvertToString(object? value, IWriterRow row, MemberMapData memberMapData) { - return JsonSerializer.Serialize(value); + return JsonSerializer.Serialize(value, _options); } } \ No newline at end of file diff --git a/X86DisassemblerTests/TestDataProvider.cs b/X86DisassemblerTests/TestDataProvider.cs index 08fa8e8..60e0c0c 100644 --- a/X86DisassemblerTests/TestDataProvider.cs +++ b/X86DisassemblerTests/TestDataProvider.cs @@ -1,6 +1,6 @@ using System.Collections; using System.Globalization; -using System.Reflection; +using System.IO; using CsvHelper; using CsvHelper.Configuration; @@ -14,38 +14,51 @@ public class TestDataProvider : IEnumerable /// /// Gets all CSV test files from the TestData directory /// - /// An enumerable of test file names + /// An enumerable of test file paths private IEnumerable GetTestFiles() { - // Get all CSV files from the TestData directory in the assembly - var assembly = Assembly.GetExecutingAssembly(); - var resourceNames = assembly.GetManifestResourceNames() - .Where(name => name.StartsWith("X86DisassemblerTests.TestData.") && name.EndsWith(".csv")); - - // Return all CSV files from the TestData directory - // All files have been converted to the new format - foreach (var resourceName in resourceNames) + // Get the directory where the test assembly is located + var assemblyLocation = typeof(TestDataProvider).Assembly.Location; + var assemblyDirectory = Path.GetDirectoryName(assemblyLocation); + + // Navigate to the TestData directory + // First try to find it in the project structure (for development) + string testDataDirectory = Path.Combine(assemblyDirectory!, "..", "..", "..", "TestData"); + + // If the directory doesn't exist (e.g., in a published build), try the output directory + if (!Directory.Exists(testDataDirectory)) { - // Return the full resource name - yield return resourceName; + testDataDirectory = Path.Combine(assemblyDirectory!, "TestData"); + + // If still not found, throw an exception + if (!Directory.Exists(testDataDirectory)) + { + throw new DirectoryNotFoundException($"Could not find TestData directory at {testDataDirectory}"); + } } + + // Get the absolute path + testDataDirectory = Path.GetFullPath(testDataDirectory); + + // Return all CSV files from the TestData directory + return Directory.GetFiles(testDataDirectory, "*.csv"); } /// /// Loads test entries from a CSV file /// - /// The full resource name of the CSV file + /// The full path to the CSV file /// An enumerable of TestFromFileEntry objects - private IEnumerable LoadTestEntries(string resourceName) + private IEnumerable LoadTestEntries(string filePath) { - // Load the CSV test file from embedded resources - using var stream = Assembly.GetExecutingAssembly() - .GetManifestResourceStream(resourceName); - - if (stream == null) + // Check if the file exists + if (!File.Exists(filePath)) { - throw new InvalidOperationException($"Could not find {resourceName} embedded resource"); + throw new FileNotFoundException($"Could not find test file at {filePath}"); } + + // Open the file directly from the file system + using var stream = File.OpenRead(filePath); // Configure CSV reader with semicolon delimiter var config = new CsvConfiguration(CultureInfo.InvariantCulture) @@ -79,13 +92,13 @@ public class TestDataProvider : IEnumerable /// public IEnumerator GetEnumerator() { - foreach (var resourceName in GetTestFiles()) + foreach (var filePath in GetTestFiles()) { // Extract just the filename part for display purposes - string fileName = resourceName.Replace("X86DisassemblerTests.TestData.", ""); + string fileName = Path.GetFileName(filePath); int testIndex = 0; - foreach (var entry in LoadTestEntries(resourceName)) + foreach (var entry in LoadTestEntries(filePath)) { // Yield each test entry as a separate test case // Include the file name and index for better test identification diff --git a/X86DisassemblerTests/X86DisassemblerTests.csproj b/X86DisassemblerTests/X86DisassemblerTests.csproj index 44e2e97..2b293db 100644 --- a/X86DisassemblerTests/X86DisassemblerTests.csproj +++ b/X86DisassemblerTests/X86DisassemblerTests.csproj @@ -28,50 +28,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + PreserveNewest +