mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-19 07:59:47 +03:00
refactor xors
This commit is contained in:
@ -67,10 +67,8 @@ public class XorImmWithRm16SignExtendedHandler : InstructionHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the immediate value and sign-extend it
|
||||
byte imm8 = Decoder.ReadByte();
|
||||
// Sign-extend to 16 bits by converting to sbyte first
|
||||
short imm16 = (short)((sbyte)imm8);
|
||||
// Read the immediate value and sign-extend it to 16 bits
|
||||
short imm16 = (sbyte)Decoder.ReadByte();
|
||||
|
||||
// Format the immediate value
|
||||
string immStr = $"0x{(ushort)imm16:X4}";
|
||||
|
@ -67,10 +67,8 @@ public class XorImmWithRm32SignExtendedHandler : InstructionHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the immediate value and sign-extend it
|
||||
byte imm8 = Decoder.ReadByte();
|
||||
// Sign-extend to 32 bits by converting to sbyte first
|
||||
int imm32 = (int)((sbyte)imm8);
|
||||
// Read the immediate value and sign-extend it to 32 bits
|
||||
int imm32 = (sbyte)Decoder.ReadByte();
|
||||
|
||||
// Format the immediate value
|
||||
string immStr;
|
||||
@ -79,15 +77,10 @@ public class XorImmWithRm32SignExtendedHandler : InstructionHandler
|
||||
// For negative values, show the full sign-extended 32-bit value
|
||||
immStr = $"0x{imm32:X8}";
|
||||
}
|
||||
else if (imm8 == 0)
|
||||
{
|
||||
// For zero, use the expected format
|
||||
immStr = "0x00";
|
||||
}
|
||||
else
|
||||
{
|
||||
// For positive values, show without leading zeros
|
||||
immStr = $"0x{imm8:X}";
|
||||
immStr = $"0x{imm32:X2}";
|
||||
}
|
||||
|
||||
// Set the operands
|
||||
|
@ -68,8 +68,7 @@ public class XorImmWithRm8Handler : InstructionHandler
|
||||
}
|
||||
|
||||
// Read the immediate value
|
||||
byte imm8 = CodeBuffer[position];
|
||||
Decoder.SetPosition(position + 1);
|
||||
byte imm8 = Decoder.ReadByte();
|
||||
|
||||
// Format the immediate value
|
||||
string immStr = $"0x{imm8:X2}";
|
||||
|
@ -45,17 +45,8 @@ public class XorMemRegHandler : 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);
|
||||
|
||||
// Decode the destination operand
|
||||
string destOperand = ModRMDecoder.DecodeModRM(mod, rm, false);
|
||||
|
||||
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Get the source register
|
||||
string srcReg = GetRegister32(reg);
|
||||
|
||||
|
@ -45,17 +45,8 @@ public class XorRegMemHandler : 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);
|
||||
|
||||
// Decode the source operand
|
||||
string srcOperand = ModRMDecoder.DecodeModRM(mod, rm, false);
|
||||
|
||||
var (mod, reg, rm, srcOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Get the destination register
|
||||
string destReg = GetRegister32(reg);
|
||||
|
||||
|
Reference in New Issue
Block a user