Heading:
Mesa Floating Point Implementation Notes
Page Numbers: Yes X: 527 Y: 10.5"
DRAFT - DRAFT - DRAFT - DRAFT
DRAFT - DRAFT - DRAFT - DRAFT
Inter-Office Memorandum
ToMesa Floating Point ImplementorsDateJuly 9, 1980
FromL. StewartLocationPalo Alto
SubjectMesa Floating PointOrganizationPARC/CSL
Hints
XEROX
Filed on: [Maxc]<LStewart>MesaFPImpl.bravo
Introduction
This memo presents some discussion of the implementation of Mesa 6 floating point.
Instructions
MISC opcodes are used for Mesa 6 floating point. Here is the appropriate section of FPMiscAlpha.mesa
alpha: TYPE = [0..400B);
-- Floating Point
aFADD: alpha = 20B;
aFSUB: alpha = 21B;
aFMUL: alpha = 22B;
aFDIV: alpha = 23B;
aFCOMP: alpha = 24B;
aFIX: alpha = 25B;
aFLOAT: alpha = 26B;
aFIXI: alpha = 27B;
aFIXC: alpha = 30B;
aFSTICKY: alpha = 31B;
aFREM: alpha = 32B;
aROUND: alpha = 33B;
aROUNDI: alpha = 34B;
aROUNDC: alpha = 35B;
aSETS: alpha = 36B;
Add, Subtract, Multiply, Divide, and Remainder take two REALs on the stack (4 words) and return one REAL (2 words).
Compare takes two REALS and returns an INTEGER (1 word).
Fix and Round take one REAL and return a LONG INTEGER (2 words).
Float takes one LONG INTEGER and returns a REAL.
FixI, FixC, RoundI, and RoundC take one REAL and return either an INTEGER or a CARDINAL (1 word in either case).
SETS sets the FP package sticky flags from 1 word on the stack, it returns nothing.
FSTICKY takes one word and returns one word. It is used to set and read the microcode copy of the inexactResult sticky flag and the microcode copy of the inexactResult trap enable.
Runtime
Because of the complexity of the Ieee FP standard, the microcode does not handle all the ’defficult’ cases. Roughly speaking, the microcode should handle operands which are normal numbers or which are true zero. The microcode should handle normal rounding. The microcode should handle the inexact result trap and sticky flag. All other cases, including denormalized operands, infinities, Not-A-Numbers, and exceptions, should be handled by trapping to Mesa code.
Whenever the microcode finds unreasonable operands or otherwise gets into trouble, or encounters an unimplemented instruction, it should push the MISC alpha byte on the stack and trap through SD[137B]. The module [Ivy]<CedarLib>Real>IeeeControl.mesa includes a procedure called FError which is accessed by SD[137B]. This procedure is called with a variable number of words on the stack. It uses the STATE construct in mesa to execute the Dump State instruction and then examines the stack to figure out what to do. FError dispatches on the alpha byte of the faulted instruction (left on top of the stack), picks up the original operands (the microcode must not disturb them!) and re-executes the faulted operation in Mesa. When the Mesa operation returns to FError, the results are stored in the state vector and the RETURN WITH state construct is used to return a variable number of words (depending on the instruction which faulted) to the client which executed the original instruction.
In the case of the standard operations, the interface RealOps.mesa and inplementing modules provide FP operations that do handle all the funny cases.
Alto
There are two sets of Alto microcode on [Ivy]<CedarLib>Real>. Float6ni.mu does not do any work. It always traps to Mesa. In fact, rather than push the alpha byte on the stack, it is directly stuffed into stk4 and the stack pointer set to 5. This works because there are never more than 4 operands for a floating point instruction and because FError inspects the stack pointer to find the alpha byte, but works from stack[0] upwards to find the operands.
Float6.mu actually implements most of the operations. Remainder and the Round instructions are not implemented.
References
Definitions files:
[Ivy]<CedarLib>Real>FPMiscAlpha.mesa
[Ivy]<CedarLib>Real>Real.mesa
[Ivy]<CedarLib>Real>RealOps.mesa
Implementations:
[Ivy]<CedarLib>Real>IeeeControl.mesa
[Ivy]<CedarLib>Real>Float6ni.mu
[Ivy]<CedarLib>Real>Float6.mu