0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-19 07:59:47 +03:00

Refactor SUB handlers

This commit is contained in:
bird_egop
2025-04-13 18:22:44 +03:00
parent a04a16af7d
commit e91a0223f7
18 changed files with 493 additions and 200 deletions

View File

@ -1,6 +1,24 @@
namespace X86DisassemblerTests.InstructionTests;
using X86Disassembler.X86;
namespace X86DisassemblerTests.InstructionTests;
public class SubRm8Imm8Tests
{
[Fact]
public void SubRm8Imm8_Decodes_Correctly()
{
// Arrange
// SUB BL, 0x42
byte[] codeBuffer = new byte[] { 0x80, 0xeb, 0x42 };
var decoder = new Disassembler(codeBuffer, 0x1000);
// Act
var instructions = decoder.Disassemble();
// Assert
Assert.Single(instructions);
Assert.NotNull(instructions[0]);
Assert.Equal("sub", instructions[0].Mnemonic);
Assert.Equal("bl, 0x42", instructions[0].Operands);
}
}

View File

@ -6,26 +6,26 @@ RawBytes;Instructions
90;[{ "Mnemonic": "nop", "Operands": "" }]
# Multi-byte NOP instructions (used for alignment)
# 2-byte NOP
# 2-byte NOP (xchg AX, AX)
6690;[{ "Mnemonic": "nop", "Operands": "" }]
# 3-byte NOP (XCHG EAX, EAX)
0F1F00;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax]" }]
# 4-byte NOP
0F1F4000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax+0x00]" }]
0F1F4000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax]" }]
# 5-byte NOP
0F1F440000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax+eax]" }]
0F1F440000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax+eax*1]" }]
# 6-byte NOP
660F1F440000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax+eax]" }]
660F1F440000;[{ "Mnemonic": "nop", "Operands": "word ptr [eax+eax*1]" }]
# 7-byte NOP
0F1F8000000000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax+0x00000000]" }]
0F1F8000000000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax]" }]
# 8-byte NOP
0F1F840000000000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax+eax]" }]
0F1F840000000000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax+eax*1]" }]
# 9-byte NOP
660F1F840000000000;[{ "Mnemonic": "nop", "Operands": "dword ptr [eax+eax]" }]
660F1F840000000000;[{ "Mnemonic": "nop", "Operands": "word ptr [eax+eax*1]" }]

Can't render this file because it contains an unexpected character in line 6 and column 7.