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

Fixed instruction handlers and tests for Group1, Group3, and XOR instructions

This commit is contained in:
bird_egop
2025-04-12 21:48:41 +03:00
parent f107b8e763
commit a0e40c8a52
6 changed files with 79 additions and 24 deletions

View File

@ -57,15 +57,26 @@ public class AddImmToRm8Handler : Group1BaseHandler
// 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 0 for ADD
byte rm = (byte)(modRM & 0x07);
// Decode the destination operand
string destOperand = _modRMDecoder.DecodeModRM(mod, rm, false);
// For direct register addressing (mod == 3), use 8-bit register names
string destOperand;
if (mod == 3)
{
// Use 8-bit register names for direct register addressing
destOperand = GetRegister8(rm);
}
else
{
// Use ModR/M decoder for memory addressing
destOperand = _modRMDecoder.DecodeModRM(mod, rm, false);
}
Decoder.SetPosition(position);
// Read the immediate value
if (position >= Length)

View File

@ -57,15 +57,26 @@ public class OrImmToRm8Handler : Group1BaseHandler
// 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 1 for OR
byte rm = (byte)(modRM & 0x07);
// Decode the destination operand
string destOperand = _modRMDecoder.DecodeModRM(mod, rm, false);
// For direct register addressing (mod == 3), use 8-bit register names
string destOperand;
if (mod == 3)
{
// Use 8-bit register names for direct register addressing
destOperand = GetRegister8(rm);
}
else
{
// Use ModR/M decoder for memory addressing
destOperand = _modRMDecoder.DecodeModRM(mod, rm, false);
}
Decoder.SetPosition(position);
// Read the immediate value
if (position >= Length)