Set8087CW Procedure
The Set8087CW
procedure sets the floating-point
control word and saves the value of the
ControlWord
variable in
Default8087CW
. Set8087CW
is a
real procedure.
type
TRoundMode = (rmNearest, rmDown, rmUp, rmZero);
TPrecisionMode = (pmSingle, pmReserved, pmDouble, pmExtended);
TExceptionMask = (emInvalid, emDenormalized, emZeroDivide,
emOverflow, emUnderflow, emPrecision);
TExceptionMasks = set of TExceptionMask;
TFpuControl = record
RoundMode: TRoundMode;
Precision: TPrecisionMode;
ExceptionMask: TExceptionMasks;
end;
const
RoundShift = 10;
PrecisionShift = 8;
// Set the floating-point control word in a structured manner.
procedure SetFpuCW(const FpuCW: TFpuControl);
var
CW: Word;
begin
CW := Byte(FpuCW.ExceptionMask);
CW := CW or (Ord(FpuCW.Precision) shl PrecisionShift);
CW := CW or (Ord(FpuCW.RoundMode) shl RoundShift);
Set8087CW(CW);
end;