mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 16:18:37 +03:00
nice big refactor
This commit is contained in:
@ -56,16 +56,7 @@ public class AndImmToRm32Handler : 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); // Should be 4 for AND
|
||||
byte rm = (byte)(modRM & 0x07);
|
||||
|
||||
// Decode the destination operand
|
||||
string destOperand = ModRMDecoder.DecodeModRM(mod, rm, false);
|
||||
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Read the immediate value
|
||||
if (position + 3 >= Length)
|
||||
@ -74,18 +65,11 @@ public class AndImmToRm32Handler : InstructionHandler
|
||||
}
|
||||
|
||||
// Read the immediate value in little-endian format
|
||||
byte b0 = CodeBuffer[position];
|
||||
byte b1 = CodeBuffer[position + 1];
|
||||
byte b2 = CodeBuffer[position + 2];
|
||||
byte b3 = CodeBuffer[position + 3];
|
||||
var imm = Decoder.ReadUInt32();
|
||||
|
||||
// Format the immediate value as expected by the tests (0x12345678)
|
||||
// Note: The bytes are reversed to match the expected format in the tests
|
||||
string immStr = $"0x{b3:X2}{b2:X2}{b1:X2}{b0:X2}";
|
||||
|
||||
// Advance the position past the immediate value
|
||||
position += 4;
|
||||
Decoder.SetPosition(position);
|
||||
string immStr = $"0x{imm:X8}";
|
||||
|
||||
// Set the operands
|
||||
instruction.Operands = $"{destOperand}, {immStr}";
|
||||
|
Reference in New Issue
Block a user