mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-21 00:28:36 +03:00
float handlers
This commit is contained in:
@ -31,11 +31,13 @@ public class FdivrFloat64Handler : InstructionHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the ModR/M byte has reg field = 7
|
||||
// Check if the ModR/M byte has reg field = 7 and mod != 3 (memory operand)
|
||||
byte modRm = Decoder.PeakByte();
|
||||
byte reg = (byte)((modRm >> 3) & 0x7);
|
||||
byte mod = (byte)((modRm >> 6) & 0x3);
|
||||
|
||||
return reg == 7;
|
||||
// Only handle memory operands (mod != 3) with reg = 7
|
||||
return reg == 7 && mod != 3;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -51,34 +53,20 @@ public class FdivrFloat64Handler : InstructionHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the ModR/M byte using the specialized FPU method
|
||||
// Read the ModR/M byte using the specialized FPU method for 64-bit operands
|
||||
var (mod, reg, fpuRm, rawOperand) = ModRMDecoder.ReadModRMFpu64();
|
||||
|
||||
// We've already verified reg field is 7 (FDIVR) in CanHandle
|
||||
// and we only handle memory operands (mod != 3)
|
||||
|
||||
// Set the instruction type
|
||||
instruction.Type = InstructionType.Fdivr;
|
||||
|
||||
// For memory operands, set the operand
|
||||
if (mod != 3) // Memory operand
|
||||
{
|
||||
// Set the structured operands - the operand already has the correct size from ReadModRM
|
||||
instruction.StructuredOperands =
|
||||
[
|
||||
rawOperand
|
||||
];
|
||||
}
|
||||
else // Register operand (ST(i))
|
||||
{
|
||||
// For DC F8-DC FF, the operands are reversed: ST(i), ST(0)
|
||||
var stiOperand = OperandFactory.CreateFPURegisterOperand(fpuRm); // ST(i)
|
||||
var st0Operand = OperandFactory.CreateFPURegisterOperand(FpuRegisterIndex.ST0); // ST(0)
|
||||
|
||||
// Set the structured operands
|
||||
instruction.StructuredOperands =
|
||||
[
|
||||
stiOperand,
|
||||
st0Operand
|
||||
];
|
||||
}
|
||||
// Set the structured operands - the operand already has the correct size from ReadModRMFpu64
|
||||
instruction.StructuredOperands =
|
||||
[
|
||||
rawOperand
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user