diff --git a/X86Disassembler/X86/Handlers/FloatingPoint/Int32OperationHandler.cs b/X86Disassembler/X86/Handlers/FloatingPoint/Int32OperationHandler.cs
index 5763f2e..9721784 100644
--- a/X86Disassembler/X86/Handlers/FloatingPoint/Int32OperationHandler.cs
+++ b/X86Disassembler/X86/Handlers/FloatingPoint/Int32OperationHandler.cs
@@ -7,7 +7,7 @@ public class Int32OperationHandler : FloatingPointBaseHandler
{
// DA opcode - operations on int32
private static readonly string[] Mnemonics =
- {
+ [
"fiadd",
"fimul",
"ficom",
@@ -15,8 +15,8 @@ public class Int32OperationHandler : FloatingPointBaseHandler
"fisub",
"fisubr",
"fidiv",
- "fidivr",
- };
+ "fidivr"
+ ];
///
/// Initializes a new instance of the Int32OperationHandler class
diff --git a/X86Disassembler/X86/Handlers/InstructionHandlerFactory.cs b/X86Disassembler/X86/Handlers/InstructionHandlerFactory.cs
index e49643d..dec1ac7 100644
--- a/X86Disassembler/X86/Handlers/InstructionHandlerFactory.cs
+++ b/X86Disassembler/X86/Handlers/InstructionHandlerFactory.cs
@@ -18,7 +18,7 @@ namespace X86Disassembler.X86.Handlers;
///
public class InstructionHandlerFactory
{
- private readonly List _handlers = new();
+ private readonly List _handlers = [];
private readonly byte[] _codeBuffer;
private readonly InstructionDecoder _decoder;
private readonly int _length;
diff --git a/X86Disassembler/X86/Handlers/Jump/ConditionalJumpHandler.cs b/X86Disassembler/X86/Handlers/Jump/ConditionalJumpHandler.cs
index 014cb13..c1e645e 100644
--- a/X86Disassembler/X86/Handlers/Jump/ConditionalJumpHandler.cs
+++ b/X86Disassembler/X86/Handlers/Jump/ConditionalJumpHandler.cs
@@ -6,11 +6,11 @@ namespace X86Disassembler.X86.Handlers.Jump;
public class ConditionalJumpHandler : InstructionHandler
{
// Mnemonics for conditional jumps
- private static readonly string[] ConditionalJumpMnemonics = new string[]
- {
+ private static readonly string[] Mnemonics =
+ [
"jo", "jno", "jb", "jnb", "jz", "jnz", "jbe", "jnbe",
"js", "jns", "jp", "jnp", "jl", "jnl", "jle", "jnle"
- };
+ ];
///
/// Initializes a new instance of the ConditionalJumpHandler class
@@ -44,7 +44,7 @@ public class ConditionalJumpHandler : InstructionHandler
{
// Get the mnemonic from the table
int index = opcode - 0x70;
- instruction.Mnemonic = ConditionalJumpMnemonics[index];
+ instruction.Mnemonic = Mnemonics[index];
// Get the current position in the code buffer
int position = Decoder.GetPosition();
diff --git a/X86Disassembler/X86/Handlers/Jump/TwoByteConditionalJumpHandler.cs b/X86Disassembler/X86/Handlers/Jump/TwoByteConditionalJumpHandler.cs
index bb1a243..1c1f1e3 100644
--- a/X86Disassembler/X86/Handlers/Jump/TwoByteConditionalJumpHandler.cs
+++ b/X86Disassembler/X86/Handlers/Jump/TwoByteConditionalJumpHandler.cs
@@ -6,11 +6,11 @@ namespace X86Disassembler.X86.Handlers.Jump;
public class TwoByteConditionalJumpHandler : InstructionHandler
{
// Mnemonics for conditional jumps
- private static readonly string[] ConditionalJumpMnemonics = new string[]
- {
+ private static readonly string[] ConditionalJumpMnemonics =
+ [
"jo", "jno", "jb", "jnb", "jz", "jnz", "jbe", "jnbe",
"js", "jns", "jp", "jnp", "jl", "jnl", "jle", "jnle"
- };
+ ];
///
/// Initializes a new instance of the TwoByteConditionalJumpHandler class
diff --git a/X86Disassembler/X86/Instruction.cs b/X86Disassembler/X86/Instruction.cs
index 28c8253..12274aa 100644
--- a/X86Disassembler/X86/Instruction.cs
+++ b/X86Disassembler/X86/Instruction.cs
@@ -23,7 +23,7 @@ public class Instruction
///
/// Gets or sets the raw bytes of the instruction
///
- public byte[] RawBytes { get; set; } = Array.Empty();
+ public byte[] RawBytes { get; set; } = [];
///
/// Returns a string representation of the instruction
diff --git a/X86Disassembler/X86/InstructionDecoder.cs b/X86Disassembler/X86/InstructionDecoder.cs
index 1ae5ed9..b05cc99 100644
--- a/X86Disassembler/X86/InstructionDecoder.cs
+++ b/X86Disassembler/X86/InstructionDecoder.cs
@@ -1,6 +1,6 @@
namespace X86Disassembler.X86;
-using X86Disassembler.X86.Handlers;
+using Handlers;
///
/// Decodes x86 instructions from a byte buffer
@@ -25,7 +25,7 @@ public class InstructionDecoder
private bool _segmentOverridePrefix;
private bool _lockPrefix;
private bool _repPrefix;
- private string _segmentOverride = string.Empty;
+ private string _segmentOverride;
///
/// Initializes a new instance of the InstructionDecoder class
@@ -37,7 +37,7 @@ public class InstructionDecoder
_codeBuffer = codeBuffer;
_length = length;
_position = 0;
- _segmentOverride = string.Empty;
+ _segmentOverride = "";
// Create the instruction handler factory
_handlerFactory = new InstructionHandlerFactory(_codeBuffer, this, _length);
diff --git a/X86Disassembler/X86/InstructionType.cs b/X86Disassembler/X86/InstructionType.cs
deleted file mode 100644
index cc1aed3..0000000
--- a/X86Disassembler/X86/InstructionType.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-namespace X86Disassembler.X86;
-
-///
-/// Represents the different types of x86 instructions
-///
-public enum InstructionType
-{
- ///
- /// Unknown or unrecognized instruction
- ///
- Unknown,
-
- ///
- /// Data transfer instructions (e.g., MOV, PUSH, POP, XCHG)
- ///
- DataTransfer,
-
- ///
- /// Arithmetic instructions (e.g., ADD, SUB, MUL, DIV)
- ///
- Arithmetic,
-
- ///
- /// Logical instructions (e.g., AND, OR, XOR, NOT)
- ///
- Logical,
-
- ///
- /// Shift and rotate instructions (e.g., SHL, SHR, ROL, ROR)
- ///
- ShiftRotate,
-
- ///
- /// Control flow instructions (e.g., JMP, CALL, RET)
- ///
- ControlFlow,
-
- ///
- /// Conditional jump instructions (e.g., JE, JNE, JG, JL)
- ///
- ConditionalJump,
-
- ///
- /// String instructions (e.g., MOVS, CMPS, SCAS)
- ///
- String,
-
- ///
- /// I/O instructions (e.g., IN, OUT)
- ///
- IO,
-
- ///
- /// Flag control instructions (e.g., STC, CLC, CMC)
- ///
- FlagControl,
-
- ///
- /// Processor control instructions (e.g., HLT, WAIT)
- ///
- ProcessorControl,
-
- ///
- /// Floating-point instructions (e.g., FADD, FSUB, FMUL)
- ///
- FloatingPoint,
-
- ///
- /// SIMD instructions (e.g., MMX, SSE, AVX)
- ///
- SIMD
-}
diff --git a/X86Disassembler/X86/ModRMDecoder.cs b/X86Disassembler/X86/ModRMDecoder.cs
index 5f6bf03..dcf3ba5 100644
--- a/X86Disassembler/X86/ModRMDecoder.cs
+++ b/X86Disassembler/X86/ModRMDecoder.cs
@@ -239,34 +239,4 @@ public class ModRMDecoder
_ => RegisterNames32[index]
};
}
-
- ///
- /// Gets the 8-bit register name based on the register number
- ///
- /// The register number (0-7)
- /// The register name
- public static string GetRegister8(int reg)
- {
- if (reg >= 0 && reg < RegisterNames8.Length)
- {
- return RegisterNames8[reg];
- }
-
- return $"r{reg}?";
- }
-
- ///
- /// Gets the 32-bit register name based on the register number
- ///
- /// The register number (0-7)
- /// The register name
- public static string GetRegister32(int reg)
- {
- if (reg >= 0 && reg < RegisterNames32.Length)
- {
- return RegisterNames32[reg];
- }
-
- return $"r{reg}?";
- }
}
diff --git a/X86Disassembler/X86/OpcodeMap.cs b/X86Disassembler/X86/OpcodeMap.cs
index 2e1a5e1..c2097e2 100644
--- a/X86Disassembler/X86/OpcodeMap.cs
+++ b/X86Disassembler/X86/OpcodeMap.cs
@@ -3,7 +3,7 @@ namespace X86Disassembler.X86;
///
/// Provides mapping between opcodes and their mnemonics
///
-public class OpcodeMap
+public static class OpcodeMap
{
// One-byte opcode map
private static readonly string[] OneByteOpcodes = new string[256];
@@ -14,16 +14,6 @@ public class OpcodeMap
"s", "ns", "p", "np", "l", "ge", "le", "g"
};
- // Group 1 operations (used with opcodes 0x80, 0x81, 0x83)
- public static readonly string[] Group1Operations = {
- "add", "or", "adc", "sbb", "and", "sub", "xor", "cmp"
- };
-
- // Group 3 operations (used with opcodes 0xF6, 0xF7)
- public static readonly string[] Group3Operations = {
- "test", "???", "not", "neg", "mul", "imul", "div", "idiv"
- };
-
// Static constructor to initialize the opcode maps
static OpcodeMap()
{
@@ -138,34 +128,4 @@ public class OpcodeMap
{
return OneByteOpcodes[opcode];
}
-
- ///
- /// Checks if the opcode is a Group 1 opcode
- ///
- /// The opcode to check
- /// True if the opcode is a Group 1 opcode
- public static bool IsGroup1Opcode(byte opcode)
- {
- return opcode == 0x80 || opcode == 0x81 || opcode == 0x83;
- }
-
- ///
- /// Checks if the opcode is a Group 3 opcode
- ///
- /// The opcode to check
- /// True if the opcode is a Group 3 opcode
- public static bool IsGroup3Opcode(byte opcode)
- {
- return opcode == 0xF6 || opcode == 0xF7;
- }
-
- ///
- /// Checks if the opcode is a floating-point instruction
- ///
- /// The opcode to check
- /// True if the opcode is a floating-point instruction
- public static bool IsFloatingPointOpcode(byte opcode)
- {
- return opcode >= 0xD8 && opcode <= 0xDF;
- }
}