mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-05-19 20:01:17 +03:00
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
![]() |
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);
|
||
|
}
|
||
|
}
|