RealControl.mesa - Microcode to Mesa floating point translator
Copyright © 1985 by Xerox Corporation. All rights reserved.
Stewart, January 14, 1984 4:58 pm
Rovner, May 4, 1983 10:27 am
Russ Atkinson (RRA) May 22, 1985 9:53:23 pm PDT
Doug Wyatt, February 25, 1985 3:30:21 pm PST
DIRECTORY
Ieee USING [InitIeee, SetInvalidOperation],
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 USING [],
RealFns USING [SqRt],
RealOps USING [FAdd, FComp, FDiv, FixMode, Float, FMul, FRem, FScale, FSub, RoundC, RoundI, RoundLI],
TrapSupport USING [BumpPC, opTrapTable];
RealControl: PROGRAM
IMPORTS PrincOpsUtils, Ieee, RealFns, RealOps, TrapSupport
= BEGIN
NoteTrap: PROC = {
RRA: This procedure is here for debugging purposes. A trap is already so expensive that the additional cost should be negligible. Plant a Spy breakpoint here to see the users of trapping REAL instructions!
realTraps ← realTraps + 1;
};
realTraps: INT ← 0;
microSticky: CARDINAL ← 0;
InitReals: PROC = {
OPEN PrincOps, TrapSupport;
SD[sFADD] ← SD[sFSUB] ← SD[sFMUL] ← SD[sFDIV] ← SD[sFCOMP] ← SD[sFIX] ← SD[sFLOAT] ← LOOPHOLE[UnboundLink, WORD];
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];
Ieee.InitIeee[];
};
TFAdd: PROC [a, b: REAL] RETURNS [c: REAL] = {
state: PrincOps.StateVector;
state ← STATE;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
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;
NoteTrap[];
IF a < 0.0 THEN Ieee.SetInvalidOperation[];
b ← RealFns.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;
NoteTrap[];
b ← RealOps.FScale[a, scale];
TrapSupport.BumpPC[2];
state.dest ← [frame[PrincOpsUtils.MyLocalFrame[]]];
TRANSFER WITH state;
};
Mainline code
InitReals[];
END.
L. Stewart, December 11, 1980 11:37 AM, modify for Pilot from RealControl.mesa
L. Stewart, 4-Feb-81 18:31:04, change to new trap handling
L. Stewart, 6-Feb-81 10:40:32, update trap procedure style
R. Atkinson, 23-Mar-81 16:10:36,
replaced Frame.MyLocalFrame[] with [frame[Frame.MyLocalFrame[]]]
L. Stewart, June 3, 1982 11:11 am, added FScale and SqRt, removed SETS
L. Stewart, August 27, 1982 1:15 pm, SAFE
L. Stewart, January 14, 1984 4:58 pm, change to Ieee