0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-20 16:18:37 +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

@ -42,13 +42,7 @@ public class SubR32Rm32Handler : InstructionHandler
}
// Read the ModR/M byte
byte modRM = CodeBuffer[position++];
Decoder.SetPosition(position);
// Extract the fields from the ModR/M byte
byte mod = (byte)((modRM & 0xC0) >> 6);
byte reg = (byte)((modRM & 0x38) >> 3);
byte rm = (byte)(modRM & 0x07);
var (mod, reg, rm, operand) = ModRMDecoder.ReadModRM();
// Set the mnemonic
instruction.Mnemonic = "sub";
@ -59,7 +53,6 @@ public class SubR32Rm32Handler : InstructionHandler
// For memory operands, set the operand
if (mod != 3) // Memory operand
{
string operand = ModRMDecoder.DecodeModRM(mod, rm, false);
instruction.Operands = $"{regName}, {operand}";
}
else // Register operand
@ -70,4 +63,4 @@ public class SubR32Rm32Handler : InstructionHandler
return true;
}
}
}