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,36 @@ public class OrRm8R8HandlerTests
|
||||
// Arrange
|
||||
// OR [ebx+ecx*4+0x41], al (08 44 8B 41)
|
||||
byte[] codeBuffer = new byte[] { 0x08, 0x44, 0x8B, 0x41 };
|
||||
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("or", instruction.Mnemonic);
|
||||
Assert.Equal("byte ptr [ebx+ecx*4+0x41], al", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Or, instruction.Type);
|
||||
|
||||
// Check that we have two operands
|
||||
Assert.Equal(2, instruction.StructuredOperands.Count);
|
||||
|
||||
// Check the first operand (memory operand with SIB)
|
||||
var memOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<ScaledIndexMemoryOperand>(memOperand);
|
||||
var scaledIndexMemoryOperand = (ScaledIndexMemoryOperand)memOperand;
|
||||
Assert.Equal(RegisterIndex.B, scaledIndexMemoryOperand.BaseRegister);
|
||||
Assert.Equal(RegisterIndex.C, scaledIndexMemoryOperand.IndexRegister);
|
||||
Assert.Equal(4, scaledIndexMemoryOperand.Scale);
|
||||
Assert.Equal(0x41, scaledIndexMemoryOperand.Displacement);
|
||||
Assert.Equal(8, scaledIndexMemoryOperand.Size); // Validate that it's an 8-bit memory reference
|
||||
|
||||
// Check the second operand (AL)
|
||||
var alOperand = instruction.StructuredOperands[1];
|
||||
Assert.IsType<RegisterOperand>(alOperand);
|
||||
var registerOperand = (RegisterOperand)alOperand;
|
||||
Assert.Equal(RegisterIndex.A, registerOperand.Register);
|
||||
Assert.Equal(8, registerOperand.Size); // Validate that it's an 8-bit register (AL)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -36,14 +58,32 @@ public class OrRm8R8HandlerTests
|
||||
// Arrange
|
||||
// OR bl, ch (08 EB)
|
||||
byte[] codeBuffer = new byte[] { 0x08, 0xEB };
|
||||
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("or", instruction.Mnemonic);
|
||||
Assert.Equal("bl, ch", instruction.Operands);
|
||||
Assert.Equal(InstructionType.Or, instruction.Type);
|
||||
|
||||
// Check that we have two operands
|
||||
Assert.Equal(2, instruction.StructuredOperands.Count);
|
||||
|
||||
// Check the first operand (BL)
|
||||
var blOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<RegisterOperand>(blOperand);
|
||||
var registerOperand1 = (RegisterOperand)blOperand;
|
||||
Assert.Equal(RegisterIndex.B, registerOperand1.Register);
|
||||
Assert.Equal(8, registerOperand1.Size); // Validate that it's an 8-bit register (BL)
|
||||
|
||||
// Check the second operand (CH)
|
||||
var chOperand = instruction.StructuredOperands[1];
|
||||
Assert.IsType<RegisterOperand>(chOperand);
|
||||
var registerOperand2 = (RegisterOperand)chOperand;
|
||||
Assert.Equal(RegisterIndex.C, registerOperand2.Register);
|
||||
Assert.Equal(8, registerOperand2.Size); // Validate that it's an 8-bit register (CH)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user