0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-05-21 04:41:18 +03:00
This commit is contained in:
bird_egop 2025-04-13 01:11:45 +03:00
parent 8123ced2d6
commit 9cad5ff95c
3 changed files with 51 additions and 2 deletions

View File

@ -1,4 +1,4 @@
namespace X86Disassembler.X86.Handlers.Group5;
namespace X86Disassembler.X86.Handlers.Call;
/// <summary>
/// Handler for CALL r/m32 instruction (0xFF /2)

View File

@ -1,4 +1,4 @@
namespace X86Disassembler.X86.Handlers.Group1;
namespace X86Disassembler.X86.Handlers.Cmp;
/// <summary>
/// Handler for CMP r/m8, imm8 instruction (0x80 /7)

View File

@ -0,0 +1,49 @@
namespace X86DisassemblerTests;
using System;
using Xunit;
using X86Disassembler.X86;
/// <summary>
/// Tests for CMP r/m8, imm8 instruction (0x80 /7)
/// </summary>
public class CmpImmWithRm8Tests
{
/// <summary>
/// Tests the CMP r8, imm8 instruction (0x80 /7) with register operand
/// </summary>
[Fact]
public void TestCmpR8Imm8()
{
// Arrange
byte[] code = { 0x80, 0xF9, 0x02 }; // CMP CL, 0x02
// Act
Disassembler disassembler = new Disassembler(code, 0x1000);
var instructions = disassembler.Disassemble();
// Assert
Assert.Single(instructions);
Assert.Equal("cmp", instructions[0].Mnemonic);
Assert.Equal("cl, 0x02", instructions[0].Operands);
}
/// <summary>
/// Tests the CMP m8, imm8 instruction (0x80 /7) with memory operand
/// </summary>
[Fact]
public void TestCmpM8Imm8()
{
// Arrange
byte[] code = { 0x80, 0x39, 0x05 }; // CMP BYTE PTR [ECX], 0x05
// Act
Disassembler disassembler = new Disassembler(code, 0x1000);
var instructions = disassembler.Disassemble();
// Assert
Assert.Single(instructions);
Assert.Equal("cmp", instructions[0].Mnemonic);
Assert.Equal("byte ptr [ecx], 0x05", instructions[0].Operands);
}
}