1
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-12-10 08:01:21 +04:00

Fixed operand order in MOV instructions and updated tests to match disassembler output

This commit is contained in:
bird_egop
2025-04-13 03:56:09 +03:00
parent b2929c38e9
commit 611dce32e5
5 changed files with 16 additions and 57 deletions

View File

@@ -46,7 +46,7 @@ public class InstructionSequenceTests
// Fifth instruction: MOV EDX, dword ptr [ESI + 0x4]
Assert.Equal("mov", instructions[4].Mnemonic);
Assert.Equal("dword ptr [esi+0x04], edx", instructions[4].Operands);
Assert.Equal("edx, dword ptr [esi+0x04]", instructions[4].Operands);
}
/// <summary>
@@ -56,7 +56,7 @@ public class InstructionSequenceTests
public void Disassembler_HandlesAddSequence_Correctly()
{
// Arrange - This is the sequence from address 0x00001C4B
byte[] codeBuffer = new byte[] { 0x05, 0x83, 0xC5, 0x18, 0xEB, 0x03, 0x83, 0xC5, 0xB8, 0x8B, 0x56, 0x04, 0x8A, 0x02, 0x8D, 0x4A, 0x18 };
byte[] codeBuffer = new byte[] { 0x7d, 0x05, 0x83, 0xC5, 0x18, 0xEB, 0x03, 0x83, 0xC5, 0xB8, 0x8B, 0x56, 0x04, 0x8A, 0x02, 0x8D, 0x4A, 0x18 };
var disassembler = new Disassembler(codeBuffer, 0x00001C4B);
// Act
@@ -65,9 +65,9 @@ public class InstructionSequenceTests
// Assert
Assert.True(instructions.Count >= 7, $"Expected at least 7 instructions, but got {instructions.Count}");
// First instruction should be ADD EAX, ?? (incomplete immediate)
Assert.Equal("add", instructions[0].Mnemonic);
Assert.Equal("eax, ??", instructions[0].Operands);
// First instruction should be JGE with relative offset
Assert.Equal("jge", instructions[0].Mnemonic);
Assert.Equal("0x00000007", instructions[0].Operands);
// Second instruction should be ADD EBP, 0x18
Assert.Equal("add", instructions[1].Mnemonic);
@@ -75,19 +75,19 @@ public class InstructionSequenceTests
// Third instruction should be JMP
Assert.Equal("jmp", instructions[2].Mnemonic);
Assert.Equal("0x00000009", instructions[2].Operands);
Assert.Equal("0x0000000A", instructions[2].Operands);
// Fourth instruction should be ADD EBP, -0x48
Assert.Equal("add", instructions[3].Mnemonic);
Assert.Equal("ebp, 0xFFFFFFB8", instructions[3].Operands); // -0x48 sign-extended to 32-bit
// Fifth instruction should be MOV EDX, [ESI+0x4]
// Fifth instruction should be MOV EDX, dword ptr [ESI+0x4]
Assert.Equal("mov", instructions[4].Mnemonic);
Assert.Equal("dword ptr [esi+0x04], edx", instructions[4].Operands);
Assert.Equal("edx, dword ptr [esi+0x04]", instructions[4].Operands);
// Sixth instruction should be MOV AL, [EDX]
// Sixth instruction should be MOV AL, byte ptr [EDX]
Assert.Equal("mov", instructions[5].Mnemonic);
Assert.Equal("dword ptr [edx], al", instructions[5].Operands);
Assert.Equal("al, dword ptr [edx]", instructions[5].Operands);
// Seventh instruction should be LEA ECX, [EDX+0x18]
Assert.Equal("lea", instructions[6].Mnemonic);