0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-20 08:18:36 +03:00

nice big refactor

This commit is contained in:
bird_egop
2025-04-13 23:06:52 +03:00
parent 59df064ca4
commit 11a2cfada4
92 changed files with 981 additions and 1509 deletions

View File

@ -43,10 +43,10 @@ public class SubImmFromRm16Handler : InstructionHandler
}
// Extract the fields from the ModR/M byte
var (mod, reg, rm, operand) = ModRMDecoder.ReadModRM();
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
// Check if this is a SUB instruction (reg field must be 5)
if (reg != 5)
if (reg != RegisterIndex.Di)
{
return false;
}
@ -54,9 +54,6 @@ public class SubImmFromRm16Handler : InstructionHandler
// Set the mnemonic
instruction.Mnemonic = "sub";
// Update the decoder position
Decoder.SetPosition(position);
// For mod == 3, the r/m field specifies a register
string destination;
if (mod == 3)
@ -66,11 +63,8 @@ public class SubImmFromRm16Handler : InstructionHandler
}
else
{
// Get the memory operand string
destination = ModRMDecoder.DecodeModRM(mod, rm, false);
// Replace "dword" with "word" in the memory operand
destination = destination.Replace("dword", "word");
destination = destOperand.Replace("dword", "word");
}
// Get the current position after processing the ModR/M byte