IeeeMode.mesa - IEEE float mode control and exceptions
Copyright © 1985 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) May 22, 1985 5:04:41 pm PDT
Doug Wyatt, February 25, 1985 3:29:28 pm PST
DIRECTORY
Ieee USING [BitOn, IResultEnable, IResultSticky, Microcode, MicroSticky],
Real USING [ExceptionFlags, Extended, NoExceptions],
RealExceptions USING [CombinedFlags, GetCombined, GetSticky, SetCombined, SetSticky],
RealOps USING [DefMode, InfinityMode, Mode, NormalizationMode, RoundingMode];
IeeeMode: CEDAR PROGRAM
IMPORTS Ieee, RealExceptions
EXPORTS Ieee, Real, RealOps = BEGIN
normalMode: RealOps.Mode ← RealOps.DefMode;
userMode: RealOps.Mode ← normalMode;
alwaysNormal: BOOLTRUE;
SetStickyFlags: PUBLIC PROC [new: Real.ExceptionFlags ← Real.NoExceptions] RETURNS [old: Real.ExceptionFlags] = {
MicroStickySet[];
IF alwaysNormal
THEN {
old ← Real.NoExceptions
}
ELSE {
entry: RealExceptions.CombinedFlags ← RealExceptions.GetCombined[];
old ← entry.sticky;
entry.sticky ← new;
RealExceptions.SetCombined[entry];
};
};
GetStickyFlags: PUBLIC PROC RETURNS [Real.ExceptionFlags] = {
MicroStickySet[];
RETURN[RealExceptions.GetSticky[]];
};
SetMode: PUBLIC PROC [new: RealOps.Mode] RETURNS [old: RealOps.Mode] = {
IF alwaysNormal
THEN {userMode ← old ← normalMode}
ELSE {old ← userMode; userMode ← new};
MicroStickySet[];
};
GetMode: PUBLIC PROC RETURNS [RealOps.Mode] = {
IF alwaysNormal THEN RETURN [normalMode] ELSE RETURN[userMode];
};
MicroStickySet: PUBLIC PROC = TRUSTED {
IF Ieee.Microcode THEN {
xx: CARDINALIF userMode.traps[inexactResult] THEN Ieee.IResultEnable ELSE 0;
xx ← Ieee.MicroSticky[xx];
IF Ieee.BitOn[xx, Ieee.IResultSticky] THEN RealExceptions.SetSticky[inexactResult];
};
};
RealException: PUBLIC SIGNAL [
flags: Real.ExceptionFlags, vp: REF Real.Extended]
RETURNS [clientFixup: BOOLFALSE] = CODE;
RealError: PUBLIC ERROR = CODE;
END.
L. Stewart, July 6, 1980 4:13 PM, Microcode sticky bit stuff added.
August 25, 1980 4:42 PM, LStewart; Formatting
September 28, 1980 8:06 PM; Stewart, Deleted individual twiddle procs.
17-Nov-81 1:12:39, Stewart, userMode uninitialized
June 3, 1982 11:41 am, L. Stewart, RealException REF
August 27, 1982 1:02 pm, L. Stewart, CEDAR
January 14, 1984 4:55 pm, L. Stewart, change to Ieee