namespace X86DisassemblerTests; using System; using Xunit; using X86Disassembler.X86; /// /// Tests for CMP r/m8, imm8 instruction (0x80 /7) /// public class CmpImmWithRm8Tests { /// /// Tests the CMP r8, imm8 instruction (0x80 /7) with register operand /// [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); } /// /// Tests the CMP m8, imm8 instruction (0x80 /7) with memory operand /// [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); } }