mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-08-03 09:56:32 +03:00
Added support for CALL r/m32 (0xFF /2) and ADD r32, r/m32 (0x03) instructions with tests
This commit is contained in:
49
X86DisassemblerTests/AddInstructionTests.cs
Normal file
49
X86DisassemblerTests/AddInstructionTests.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace X86DisassemblerTests;
|
||||
|
||||
using System;
|
||||
using Xunit;
|
||||
using X86Disassembler.X86;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for ADD instruction handlers
|
||||
/// </summary>
|
||||
public class AddInstructionTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests the ADD r32, r/m32 instruction (0x03) with register operand
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestAddR32Rm32_Register()
|
||||
{
|
||||
// Arrange
|
||||
byte[] code = { 0x03, 0xF5 }; // ADD ESI, EBP
|
||||
|
||||
// Act
|
||||
Disassembler disassembler = new Disassembler(code, 0x1000);
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
Assert.Equal("add", instructions[0].Mnemonic);
|
||||
Assert.Equal("esi, ebp", instructions[0].Operands);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the ADD r32, m32 instruction (0x03) with memory operand
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestAddR32M32()
|
||||
{
|
||||
// Arrange
|
||||
byte[] code = { 0x03, 0x00 }; // ADD EAX, DWORD PTR [EAX]
|
||||
|
||||
// Act
|
||||
Disassembler disassembler = new Disassembler(code, 0x1000);
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
Assert.Equal("add", instructions[0].Mnemonic);
|
||||
Assert.Equal("eax, dword ptr [eax]", instructions[0].Operands);
|
||||
}
|
||||
}
|
49
X86DisassemblerTests/CallRm32Tests.cs
Normal file
49
X86DisassemblerTests/CallRm32Tests.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace X86DisassemblerTests;
|
||||
|
||||
using System;
|
||||
using Xunit;
|
||||
using X86Disassembler.X86;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for CALL r/m32 instruction (0xFF /2)
|
||||
/// </summary>
|
||||
public class CallRm32Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests the CALL r32 instruction (0xFF /2) with register operand
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestCallReg()
|
||||
{
|
||||
// Arrange
|
||||
byte[] code = { 0xFF, 0xD3 }; // CALL EBX
|
||||
|
||||
// Act
|
||||
Disassembler disassembler = new Disassembler(code, 0x1000);
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
Assert.Equal("call", instructions[0].Mnemonic);
|
||||
Assert.Equal("ebx", instructions[0].Operands);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the CALL m32 instruction (0xFF /2) with memory operand
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestCallMem()
|
||||
{
|
||||
// Arrange
|
||||
byte[] code = { 0xFF, 0x10 }; // CALL DWORD PTR [EAX]
|
||||
|
||||
// Act
|
||||
Disassembler disassembler = new Disassembler(code, 0x1000);
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
Assert.Equal("call", instructions[0].Mnemonic);
|
||||
Assert.Equal("dword ptr [eax]", instructions[0].Operands);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user