0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-05-19 03:41:18 +03:00
ParkanPlayground/X86DisassemblerTests/CmpImmWithRm8Tests.cs

50 lines
1.3 KiB
C#
Raw Normal View History

2025-04-13 01:11:45 +03:00
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);
}
}