0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-21 00:28:36 +03:00

float handlers

This commit is contained in:
bird_egop
2025-04-18 02:37:19 +03:00
parent 18ecf31c46
commit e967c0e0c0
27 changed files with 646 additions and 776 deletions

View File

@ -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;
}