DIRECTORY
IeeeInternal USING [InitIeee],
PrincOps USING [StateVector, UnboundLink, aFADD, aFSUB, aFMUL, aFDIV, aFCOMP, aFIX, aFLOAT, aFIXI, aFIXC, aFSTICKY, aFREM, aROUND, aROUNDI, aROUNDC, aFSQRT, aFSC, SD, sFADD, sFSUB, sFMUL, sFDIV, sFCOMP, sFIX, sFLOAT],
PrincOpsUtils USING [MyLocalFrame],
Real,
RealOps,
TrapSupport USING [BumpPC, opTrapTable];
RealControl:
PROGRAM
IMPORTS PrincOpsUtils, IeeeInternal, RealOps, TrapSupport
EXPORTS Real, RealOps
=
BEGIN
microSticky: CARDINAL ← 0;
InitReals:
PUBLIC
SAFE
PROC =
TRUSTED {
OPEN PrincOps, TrapSupport;
SD[sFADD] ← SD[sFSUB] ← SD[sFMUL] ← SD[sFDIV] ← SD[sFCOMP] ← SD[sFIX] ← SD[sFLOAT] ← UnboundLink;
opTrapTable.misc[aFADD] ← LOOPHOLE[TFAdd];
opTrapTable.misc[aFSUB] ← LOOPHOLE[TFSub];
opTrapTable.misc[aFMUL] ← LOOPHOLE[TFMul];
opTrapTable.misc[aFDIV] ← LOOPHOLE[TFDiv];
opTrapTable.misc[aFCOMP] ← LOOPHOLE[TFComp];
opTrapTable.misc[aFIX] ← LOOPHOLE[TFix];
opTrapTable.misc[aFLOAT] ← LOOPHOLE[TFloat];
opTrapTable.misc[aFIXI] ← LOOPHOLE[TFixI];
opTrapTable.misc[aFIXC] ← LOOPHOLE[TFixC];
opTrapTable.misc[aFSTICKY] ← LOOPHOLE[TFSticky];
opTrapTable.misc[aFREM] ← LOOPHOLE[TFRem];
opTrapTable.misc[aROUND] ← LOOPHOLE[TRound];
opTrapTable.misc[aROUNDI] ← LOOPHOLE[TRoundI];
opTrapTable.misc[aROUNDC] ← LOOPHOLE[TRoundC];
opTrapTable.misc[aFSQRT] ← LOOPHOLE[TSqRt];
opTrapTable.misc[aFSC] ← LOOPHOLE[TFSc];
IeeeInternal.InitIeee[];
};
TFAdd:
PROC [a, b:
REAL]
RETURNS [c:
REAL] = {
state: PrincOps.StateVector;
state ← STATE;
c ← RealOps.FAdd[a, b];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFSub:
PROC [a, b:
REAL]
RETURNS [c:
REAL] = {
state: PrincOps.StateVector;
state ← STATE;
c ← RealOps.FSub[a, b];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFMul:
PROC [a, b:
REAL]
RETURNS [c:
REAL] = {
state: PrincOps.StateVector;
state ← STATE;
c ← RealOps.FMul[a, b];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFDiv:
PROC [a, b:
REAL]
RETURNS [c:
REAL] = {
state: PrincOps.StateVector;
state ← STATE;
c ← RealOps.FDiv[a, b];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFComp:
PROC [a, b:
REAL]
RETURNS [i:
INTEGER] = {
state: PrincOps.StateVector;
state ← STATE;
i ← RealOps.FComp[a, b];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFix:
PROC [a:
REAL]
RETURNS [li:
LONG
INTEGER] = {
state: PrincOps.StateVector;
state ← STATE;
li ← RealOps.RoundLI[a, RealOps.FixMode];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFloat:
PROC [a:
LONG
INTEGER]
RETURNS [c:
REAL] = {
state: PrincOps.StateVector;
state ← STATE;
c ← RealOps.Float[a];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFixI:
PROC [a:
REAL]
RETURNS [i:
INTEGER] = {
state: PrincOps.StateVector;
state← STATE;
i ← RealOps.RoundI[a, RealOps.FixMode];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFixC:
PROC [a:
REAL]
RETURNS [c:
CARDINAL] = {
state: PrincOps.StateVector;
state ← STATE;
c ← RealOps.RoundC[a, RealOps.FixMode];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFSticky:
PROC [c:
CARDINAL]
RETURNS [cr:
CARDINAL] = {
state: PrincOps.StateVector;
state ← STATE;
cr ← microSticky;
microSticky ← c;
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFRem:
PROC [a, b:
REAL]
RETURNS [c:
REAL] = {
state: PrincOps.StateVector;
state ← STATE;
c ← RealOps.FRem[a, b];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TRound:
PROC [a:
REAL]
RETURNS [li:
LONG
INTEGER] = {
state: PrincOps.StateVector;
state ← STATE;
li ← RealOps.RoundLI[a];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TRoundI:
PROC [a:
REAL]
RETURNS [i:
INTEGER] = {
state: PrincOps.StateVector;
state ← STATE;
i ← RealOps.RoundI[a];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TRoundC:
PROC [a:
REAL]
RETURNS [c:
CARDINAL] = {
state: PrincOps.StateVector;
state ← STATE;
c ← RealOps.RoundC[a];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TSqRt:
PROC [a:
REAL]
RETURNS [b:
REAL] = {
state: PrincOps.StateVector;
state ← STATE;
b ← RealOps.SqRt[a];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
TFSc:
PROC [a:
REAL, scale:
INTEGER]
RETURNS [b:
REAL] = {
state: PrincOps.StateVector;
state ← STATE;
b ← RealOps.FScale[a, scale];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
Mainline code
InitReals[];
END.