mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-19 16:08:02 +03:00
Unified ADC accumulator handlers into a single handler
This commit is contained in:
@ -148,9 +148,9 @@ public class DataTransferInstructionTests
|
||||
|
||||
// Check the first operand (AL)
|
||||
var alOperand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<RegisterOperand>(alOperand);
|
||||
var alRegisterOperand = (RegisterOperand)alOperand;
|
||||
Assert.Equal(RegisterIndex.A, alRegisterOperand.Register);
|
||||
Assert.IsType<Register8Operand>(alOperand);
|
||||
var alRegisterOperand = (Register8Operand)alOperand;
|
||||
Assert.Equal(RegisterIndex8.AL, alRegisterOperand.Register);
|
||||
Assert.Equal(8, alRegisterOperand.Size); // Validate that it's an 8-bit register (AL)
|
||||
|
||||
// Check the second operand (Immediate)
|
||||
|
@ -0,0 +1,97 @@
|
||||
using X86Disassembler.X86;
|
||||
using X86Disassembler.X86.Operands;
|
||||
|
||||
namespace X86DisassemblerTests.InstructionTests;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for PUSH instruction handlers
|
||||
/// </summary>
|
||||
public class PushInstructionTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests the PUSH imm32 instruction (0x68)
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestPushImm32()
|
||||
{
|
||||
// Arrange
|
||||
byte[] code = { 0x68, 0x78, 0x56, 0x34, 0x12 }; // PUSH 0x12345678
|
||||
|
||||
// Act
|
||||
Disassembler disassembler = new Disassembler(code, 0x1000);
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.Equal(InstructionType.Push, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (immediate value)
|
||||
var operand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<ImmediateOperand>(operand);
|
||||
var immOperand = (ImmediateOperand)operand;
|
||||
Assert.Equal(0x12345678u, immOperand.Value);
|
||||
Assert.Equal(32, immOperand.Size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the PUSH imm16 instruction with operand size prefix (0x66 0x68)
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestPushImm16WithOperandSizePrefix()
|
||||
{
|
||||
// Arrange
|
||||
byte[] code = { 0x66, 0x68, 0x78, 0x56 }; // PUSH 0x5678 (with operand size prefix)
|
||||
|
||||
// Act
|
||||
Disassembler disassembler = new Disassembler(code, 0x1000);
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.Equal(InstructionType.Push, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (immediate value)
|
||||
var operand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<ImmediateOperand>(operand);
|
||||
var immOperand = (ImmediateOperand)operand;
|
||||
Assert.Equal(0x5678u, immOperand.Value);
|
||||
Assert.Equal(16, immOperand.Size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the PUSH imm8 instruction (0x6A)
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestPushImm8()
|
||||
{
|
||||
// Arrange
|
||||
byte[] code = { 0x6A, 0x42 }; // PUSH 0x42
|
||||
|
||||
// Act
|
||||
Disassembler disassembler = new Disassembler(code, 0x1000);
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.Equal(InstructionType.Push, instruction.Type);
|
||||
|
||||
// Check that we have one operand
|
||||
Assert.Single(instruction.StructuredOperands);
|
||||
|
||||
// Check the operand (immediate value)
|
||||
var operand = instruction.StructuredOperands[0];
|
||||
Assert.IsType<ImmediateOperand>(operand);
|
||||
var immOperand = (ImmediateOperand)operand;
|
||||
Assert.Equal(0x42u, immOperand.Value);
|
||||
Assert.Equal(8, immOperand.Size);
|
||||
}
|
||||
}
|
@ -245,27 +245,6 @@ public class SegmentOverrideTests
|
||||
Assert.Equal(-4, memoryOperand.Displacement);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that the FS segment override prefix (0x64) is correctly recognized when it's the only byte
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void FsSegmentOverride_Alone_IsRecognized()
|
||||
{
|
||||
// Arrange
|
||||
// Just the FS segment override prefix (0x64)
|
||||
byte[] codeBuffer = new byte[] { 0x64 };
|
||||
var disassembler = new Disassembler(codeBuffer, 0);
|
||||
|
||||
// Act
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
var instruction = instructions[0];
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal(InstructionType.Rep, instruction.Type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests segment override with a complex addressing mode
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user