POLY Instruction

Purpose:Allows fast calculation of math functions
Format:opcode arg.rx, degree.rx, tbladdr.ab
Operation: result <- tbladdr[0]; tbladdr being an array of type x
tmp <- 1;
while i <= degree do
{
    result <- arg * result
      ;Peform the multiply and retain an extended floating fraction of 31 bits (POLYF) or 63 bits (POLYD) in result.
    result <- result + tbladdr[tmp];
      ;Normalize, round, and check for under or overflow only after the combined multiply and add sequence.
    tmp <- tmp + 1;
    If an overflow then trap;
    If an underflow then clear result, remember overflow and continue looping.
}
If a remembered underflow occurred then trap
R0 <- result
Condition
Codes:
N <- R0 LSS 0;
Z <- R0 EQL 0;
V <- Floating Overflow;
C <- 0;
Exceptions:Floating Overflow
Floating Underflow
Reserved Operand (Floating Point)
Opcodes:
55POLYFPolynomial Evaluation Float
75POLYDPolynomial Evaluation Double
Description: The table address operand (tbladdr) points to a table of polynomial coefficients with the highest order term of the polynomial pointed to by the table address operand. The table is specified with lower order coefficients stored at increasing addresses. The Data type of the coefficients is the same as the data type of the argument operand (arg).

The evaluation is carried out by Horner's method and the contents of R0 (R1,R0 for POLYD) are replace by the result. The result computed is:

    if d = degree and x = arg
    result = C[0] + x * (C[1] + x *(C[2] + ... x*C[d]))
The unsigned word degree operand specifies the highest number coefficient to participate in the evaluation.
Notes:
1.
After execution:

POLYF
R0 = result
R1 = 0
R2 = 0
R3 = table address + degree * 4 + 4

POLYD
R0 = high order part of the result.
R1 = low order part of the result.
R2 = 0
R3 = table address + degree * 8 + 8
R4 = 0
R5 = 0

2.
The multiplication is performed such that the precision of the product is equivalent to a floating point datum having a 31 bit (63 bit for POLYD) fraction.
3.
If the unsigned word degree operand is 0, the result is C0.
4.
If the unsigned word degree operand is greater than 31, a reserved operand exception occurs.
5.
On a reserved operand exception:
1.
If PSL<FPD> = 0, the reserved operand is either the degree operand (greater than 31) or the argument operand, or some source coefficient.
2.
If the PSL = 1, the reserved operand is a coefficient and R3 is pointing at the value which caused the exception.
3.
The state of the saved condition codes and other registers is unpredictable. If the reserved operand is changed and the contents of the condition codes and all registers are preserved, the fault is continuable.
6.
On floating point uderflow after the rounding operation, the temporary result (tmp3) is replaced by 0, and the operation continues. A floating point underflow trap occurs at the end of the instruction if the underflow occurred during any iteration of the computation loop. Note that the final result may be non zero if underflow occured before the last iteration.
7.
On floating overflow after the rounding operation at any iteration of the computation loop, the instuction terminates and causes a trap. On overflow the contents of R2 and R3 (R2 through R5 for POLYD) are unpredictable. R0 contains the reserved operand (-0) and R1 = 0.
8.
POLY can have both overflow and underflow in the same instruction. If both occur, overflow trap is taken; underflow trap is lost.
9.
If the argument is zero and one of the coefficients in the table is a reserved operand, whether a reserved operand fault occurs is unpredictable.