mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-19 16:08:02 +03:00
Add support for FNSTSW instruction
This commit is contained in:
@ -8,12 +8,16 @@ public class FloatingPointHandler : InstructionHandler
|
|||||||
// Floating-point instruction mnemonics based on opcode and ModR/M reg field
|
// Floating-point instruction mnemonics based on opcode and ModR/M reg field
|
||||||
private static readonly string[][] FpuMnemonics = new string[8][];
|
private static readonly string[][] FpuMnemonics = new string[8][];
|
||||||
|
|
||||||
|
// Two-byte floating-point instructions
|
||||||
|
private static readonly Dictionary<ushort, string> TwoByteInstructions = new Dictionary<ushort, string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Static constructor to initialize the FPU mnemonic tables
|
/// Static constructor to initialize the FPU mnemonic tables
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static FloatingPointHandler()
|
static FloatingPointHandler()
|
||||||
{
|
{
|
||||||
InitializeFpuMnemonics();
|
InitializeFpuMnemonics();
|
||||||
|
InitializeTwoByteInstructions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -105,6 +109,17 @@ public class FloatingPointHandler : InstructionHandler
|
|||||||
FpuMnemonics[7][7] = "fistp";
|
FpuMnemonics[7][7] = "fistp";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the two-byte floating-point instructions
|
||||||
|
/// </summary>
|
||||||
|
private static void InitializeTwoByteInstructions()
|
||||||
|
{
|
||||||
|
// DF E0 - FNSTSW AX (Store FPU status word to AX without checking for pending unmasked floating-point exceptions)
|
||||||
|
TwoByteInstructions.Add(0xDFE0, "fnstsw");
|
||||||
|
|
||||||
|
// Add other two-byte instructions as needed
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the FloatingPointHandler class
|
/// Initializes a new instance of the FloatingPointHandler class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -141,6 +156,27 @@ public class FloatingPointHandler : InstructionHandler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for two-byte instructions
|
||||||
|
if (position < Length)
|
||||||
|
{
|
||||||
|
// Create a two-byte opcode by combining the primary opcode with the next byte
|
||||||
|
ushort twoByteOpcode = (ushort)((opcode << 8) | CodeBuffer[position]);
|
||||||
|
|
||||||
|
// Check if this is a known two-byte instruction
|
||||||
|
if (TwoByteInstructions.TryGetValue(twoByteOpcode, out string? mnemonic) && mnemonic != null)
|
||||||
|
{
|
||||||
|
instruction.Mnemonic = mnemonic;
|
||||||
|
|
||||||
|
// Special handling for specific instructions
|
||||||
|
if (twoByteOpcode == 0xDFE0) // FNSTSW AX
|
||||||
|
{
|
||||||
|
instruction.Operands = "ax";
|
||||||
|
Decoder.SetPosition(position + 1); // Skip the second byte
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The opcode index in our tables (0-7 for D8-DF)
|
// The opcode index in our tables (0-7 for D8-DF)
|
||||||
int opcodeIndex = opcode - 0xD8;
|
int opcodeIndex = opcode - 0xD8;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user