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:
@ -42,13 +42,7 @@ public class LeaR32MHandler : 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, destOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// LEA only works with memory operands, not registers
|
||||
if (mod == 3)
|
||||
@ -60,17 +54,14 @@ public class LeaR32MHandler : InstructionHandler
|
||||
instruction.Mnemonic = "lea";
|
||||
|
||||
// Get the register name
|
||||
string regName = GetRegister32(reg);
|
||||
string regName = ModRMDecoder.GetRegisterName(reg, 32);
|
||||
|
||||
// Get the memory operand without the size prefix
|
||||
string operand = ModRMDecoder.DecodeModRM(mod, rm, false);
|
||||
|
||||
// Remove the "dword ptr" prefix for LEA instructions
|
||||
operand = operand.Replace("dword ptr ", "");
|
||||
destOperand = destOperand.Replace("dword ptr ", "");
|
||||
|
||||
// Set the operands
|
||||
instruction.Operands = $"{regName}, {operand}";
|
||||
instruction.Operands = $"{regName}, {destOperand}";
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user