mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 08:18:36 +03:00
Added support for MOV r/m8, imm8 (0xC6) and ADD r/m32, r32 (0x01) instructions with tests
This commit is contained in:
49
X86DisassemblerTests/AddRm32R32Tests.cs
Normal file
49
X86DisassemblerTests/AddRm32R32Tests.cs
Normal file
@ -0,0 +1,49 @@
|
||||
namespace X86DisassemblerTests;
|
||||
|
||||
using System;
|
||||
using Xunit;
|
||||
using X86Disassembler.X86;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for ADD r/m32, r32 instruction (0x01)
|
||||
/// </summary>
|
||||
public class AddRm32R32Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests the ADD r32, r32 instruction (0x01) with register operand
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestAddR32R32()
|
||||
{
|
||||
// Arrange
|
||||
byte[] code = { 0x01, 0xC1 }; // ADD ECX, EAX
|
||||
|
||||
// Act
|
||||
Disassembler disassembler = new Disassembler(code, 0x1000);
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
Assert.Equal("add", instructions[0].Mnemonic);
|
||||
Assert.Equal("ecx, eax", instructions[0].Operands);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the ADD m32, r32 instruction (0x01) with memory operand
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestAddM32R32()
|
||||
{
|
||||
// Arrange
|
||||
byte[] code = { 0x01, 0x01 }; // ADD DWORD PTR [ECX], EAX
|
||||
|
||||
// Act
|
||||
Disassembler disassembler = new Disassembler(code, 0x1000);
|
||||
var instructions = disassembler.Disassemble();
|
||||
|
||||
// Assert
|
||||
Assert.Single(instructions);
|
||||
Assert.Equal("add", instructions[0].Mnemonic);
|
||||
Assert.Equal("dword ptr [ecx], eax", instructions[0].Operands);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user