mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 00:18:02 +03:00
unbreak tests
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using X86Disassembler.X86;
|
||||
using X86Disassembler.X86.Operands;
|
||||
|
||||
namespace X86DisassemblerTests.InstructionTests;
|
||||
|
||||
@ -16,15 +17,26 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FNSTSW AX (DF E0)
|
||||
byte[] codeBuffer = new byte[] { 0xDF, 0xE0 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fnstsw", instruction.Mnemonic);
|
||||
Assert.Equal("ax", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fnstsw, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (AX)
|
||||
var axOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<RegisterOperand>(axOperand);
|
||||
var registerOperand = (RegisterOperand)axOperand;
|
||||
Assert.Equal(RegisterIndex.A, registerOperand.Register);
|
||||
Assert.Equal(16, registerOperand.Size); // Validate that it's a 16-bit register (AX)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -36,15 +48,31 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FADD ST(0), ST(1) (D8 C1)
|
||||
byte[] codeBuffer = new byte[] { 0xD8, 0xC1 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fadd", instruction.Mnemonic);
|
||||
Assert.Equal("st(0), st(1)", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fadd, instruction.Type);
|
||||
|
||||
// Check that we have two operands
|
||||
Assert.Equal(2, instruction.StructuredOperands.Count);
|
||||
|
||||
// Check the first operand (ST(0))
|
||||
var st0Operand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<FPURegisterOperand>(st0Operand);
|
||||
var fpuRegisterOperand1 = (FPURegisterOperand)st0Operand;
|
||||
Assert.Equal(FpuRegisterIndex.ST0, fpuRegisterOperand1.RegisterIndex);
|
||||
|
||||
// Check the second operand (ST(1))
|
||||
var st1Operand = instruction.StructuredOperands[1];
|
||||
Assert.IsType<FPURegisterOperand>(st1Operand);
|
||||
var fpuRegisterOperand2 = (FPURegisterOperand)st1Operand;
|
||||
Assert.Equal(FpuRegisterIndex.ST1, fpuRegisterOperand2.RegisterIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -56,15 +84,26 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FADD dword ptr [eax] (D8 00)
|
||||
byte[] codeBuffer = new byte[] { 0xD8, 0x00 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fadd", instruction.Mnemonic);
|
||||
Assert.Equal("dword ptr [eax]", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fadd, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (dword ptr [eax])
|
||||
var memoryOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
|
||||
var baseRegisterMemoryOperand = (BaseRegisterMemoryOperand)memoryOperand;
|
||||
Assert.Equal(RegisterIndex.A, baseRegisterMemoryOperand.BaseRegister);
|
||||
Assert.Equal(32, baseRegisterMemoryOperand.Size); // Validate that it's a 32-bit memory reference
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -76,15 +115,26 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FLD dword ptr [eax] (D9 00)
|
||||
byte[] codeBuffer = new byte[] { 0xD9, 0x00 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fld", instruction.Mnemonic);
|
||||
Assert.Equal("dword ptr [eax]", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fld, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (dword ptr [eax])
|
||||
var memoryOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
|
||||
var baseRegisterMemoryOperand = (BaseRegisterMemoryOperand)memoryOperand;
|
||||
Assert.Equal(RegisterIndex.A, baseRegisterMemoryOperand.BaseRegister);
|
||||
Assert.Equal(32, baseRegisterMemoryOperand.Size); // Validate that it's a 32-bit memory reference
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -96,15 +146,26 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FLDCW [eax] (D9 28)
|
||||
byte[] codeBuffer = new byte[] { 0xD9, 0x28 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fldcw", instruction.Mnemonic);
|
||||
Assert.Equal("word ptr [eax]", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fldcw, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (word ptr [eax])
|
||||
var memoryOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
|
||||
var memoryOperandCast = (BaseRegisterMemoryOperand)memoryOperand;
|
||||
Assert.Equal(RegisterIndex.A, memoryOperandCast.BaseRegister);
|
||||
Assert.Equal(16, memoryOperandCast.Size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -116,15 +177,26 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FIADD dword ptr [eax] (DA 00)
|
||||
byte[] codeBuffer = new byte[] { 0xDA, 0x00 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fiadd", instruction.Mnemonic);
|
||||
Assert.Equal("dword ptr [eax]", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fiadd, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (dword ptr [eax])
|
||||
var memoryOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
|
||||
var baseRegisterMemoryOperand = (BaseRegisterMemoryOperand)memoryOperand;
|
||||
Assert.Equal(RegisterIndex.A, baseRegisterMemoryOperand.BaseRegister);
|
||||
Assert.Equal(32, baseRegisterMemoryOperand.Size); // Validate that it's a 32-bit memory reference
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -136,15 +208,26 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FILD dword ptr [eax] (DB 00)
|
||||
byte[] codeBuffer = new byte[] { 0xDB, 0x00 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fild", instruction.Mnemonic);
|
||||
Assert.Equal("dword ptr [eax]", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fild, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (dword ptr [eax])
|
||||
var memoryOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
|
||||
var baseRegisterMemoryOperand = (BaseRegisterMemoryOperand)memoryOperand;
|
||||
Assert.Equal(RegisterIndex.A, baseRegisterMemoryOperand.BaseRegister);
|
||||
Assert.Equal(32, baseRegisterMemoryOperand.Size); // Validate that it's a 32-bit memory reference
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -156,15 +239,26 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FADD qword ptr [eax] (DC 00)
|
||||
byte[] codeBuffer = new byte[] { 0xDC, 0x00 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fadd", instruction.Mnemonic);
|
||||
Assert.Equal("qword ptr [eax]", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fadd, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (qword ptr [eax])
|
||||
var memoryOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
|
||||
var baseRegisterMemoryOperand = (BaseRegisterMemoryOperand)memoryOperand;
|
||||
Assert.Equal(RegisterIndex.A, baseRegisterMemoryOperand.BaseRegister);
|
||||
Assert.Equal(64, baseRegisterMemoryOperand.Size); // Validate that it's a 64-bit memory reference
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -176,15 +270,31 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FADD ST(1), ST(0) (DC C1)
|
||||
byte[] codeBuffer = new byte[] { 0xDC, 0xC1 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fadd", instruction.Mnemonic);
|
||||
Assert.Equal("st(1), st(0)", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fadd, instruction.Type);
|
||||
|
||||
// Check that we have two operands
|
||||
Assert.Equal(2, instruction.StructuredOperands.Count);
|
||||
|
||||
// Check the first operand (ST(1))
|
||||
var st1Operand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<FPURegisterOperand>(st1Operand);
|
||||
var fpuRegisterOperand1 = (FPURegisterOperand)st1Operand;
|
||||
Assert.Equal(FpuRegisterIndex.ST1, fpuRegisterOperand1.RegisterIndex);
|
||||
|
||||
// Check the second operand (ST(0))
|
||||
var st0Operand = instruction.StructuredOperands[1];
|
||||
Assert.IsType<FPURegisterOperand>(st0Operand);
|
||||
var fpuRegisterOperand2 = (FPURegisterOperand)st0Operand;
|
||||
Assert.Equal(FpuRegisterIndex.ST0, fpuRegisterOperand2.RegisterIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -196,15 +306,26 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FLD qword ptr [eax] (DD 00)
|
||||
byte[] codeBuffer = new byte[] { 0xDD, 0x00 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fld", instruction.Mnemonic);
|
||||
Assert.Equal("qword ptr [eax]", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fld, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (qword ptr [eax])
|
||||
var memoryOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
|
||||
var baseRegisterMemoryOperand = (BaseRegisterMemoryOperand)memoryOperand;
|
||||
Assert.Equal(RegisterIndex.A, baseRegisterMemoryOperand.BaseRegister);
|
||||
Assert.Equal(64, baseRegisterMemoryOperand.Size); // Validate that it's a 64-bit memory reference
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -216,15 +337,26 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FIADD word ptr [eax] (DE 00)
|
||||
byte[] codeBuffer = new byte[] { 0xDE, 0x00 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fiadd", instruction.Mnemonic);
|
||||
Assert.Equal("word ptr [eax]", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fiadd, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (word ptr [eax])
|
||||
var memoryOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
|
||||
var baseRegisterMemoryOperand = (BaseRegisterMemoryOperand)memoryOperand;
|
||||
Assert.Equal(RegisterIndex.A, baseRegisterMemoryOperand.BaseRegister);
|
||||
Assert.Equal(16, baseRegisterMemoryOperand.Size); // Validate that it's a 16-bit memory reference
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -236,14 +368,25 @@ public class FloatingPointInstructionTests
|
||||
// Arrange
|
||||
// FILD word ptr [eax] (DF 00)
|
||||
byte[] codeBuffer = new byte[] { 0xDF, 0x00 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("fild", instruction.Mnemonic);
|
||||
Assert.Equal("word ptr [eax]", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Fild, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (word ptr [eax])
|
||||
var memoryOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<BaseRegisterMemoryOperand>(memoryOperand);
|
||||
var baseRegisterMemoryOperand = (BaseRegisterMemoryOperand)memoryOperand;
|
||||
Assert.Equal(RegisterIndex.A, baseRegisterMemoryOperand.BaseRegister);
|
||||
Assert.Equal(16, baseRegisterMemoryOperand.Size); // Validate that it's a 16-bit memory reference
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user