POLY
Polynomial Evaluation
Format
opcode arg.rx, degree.rw, tbladdr.ab
Condition Codes
N|| <--- R0 LSS 0;
Z|| <--- R0 EQL 0;
V|| <--- 0;
C|| <--- 0;
Exceptions
floating overflow
floating underflow
reserved operand
Opcodes
55 POLYF Polynomial Evaluation F_floating
75 POLYD Polynomial Evaluation D_floating
55FD POLYG Polynomial Evaluation G_floating
75FD POLYH Polynomial Evaluation H_floating
Description
The table address operand points to a table of polynomial coefficients. The coefficient of the highest-order term of the polynomial is 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. The evaluation is carried out by Horner's method, and the contents of R0 (R1'R0 for POLYD and POLYG, R3'R2'R1'R0 for POLYH) are replaced
by the result. The result computed is:
if d = degree
and x = arg
result = C[0]+x**0 + x*(C[1] + x*(C[2] + ... x*C[d]))
The unsigned word degree operand specifies the highest-numbered coefficient to participate in the evaluation. POLYH requires four longwords on the stack to store
arg in case the instruction is interrupted.
Notes
1.After execution:
POLYF:
R0 = result
R1 = 0
R2 = 0
R3 = table address + degree*4 + 4
POLYD and POLYG:
R0 = high-order part of result
R1 = low-order part of result
R2 = 0
R3 = table address + degree*8 + 8
R4 = 0
R5 = 0
POLYH:
R0 = highest-order part of result
R1 = second-highest-order part of result
R2 = second-lowest-order part of result
R3 = lowest-order part of result
R4 = 0
R5 = table address + degree*16 + 16
2.On a floating fault:
If PSL = 0, the instruction faults, and all relevant side effects are restored to their original state.
If PSL = 1, the instruction is suspended, and the state is saved in the general registers as follows:
POLYF:
R0 = tmp3 ! Partial result after iteration
! prior to the one causing the
! overflow/underflow
R1 = arg
R2<7:0> = tmp1 ! Number of iterations remaining
R2<31:8> = implementation specific
R3 = tmp2 ! Points to table entry causing
! exception
POLYD and POLYG:
R1'R0 = tmp3 ! Partial result after iteration
! prior to the one causing the
! overflow/underflow
R2<7:0> = tmp1 ! Number of iterations remaining
R2<31:8> = implementation specific
R3 = tmp2 ! Points to table entry causing
! exception
R5'R4 = arg
POLYH:
R3'R2'R1'R0 = tmp3 ! Partial result after iteration
! prior to the one causing the
! overflow/underflow
R4<7:0> = tmp1 ! Number of iterations remaining
R4<31:8> = implementation specific
R5 = tmp2 ! Points to table entry causing
! exception
arg is saved on the stack in use during the faulting instruction.
Implementation-specific information is saved to allow the instruction to continue after possible scaling of the coefficients and partial result by the fault handler.
3.If the unsigned word degree operand is zero and the argument is not a reserved operand, the result is C[0].
4.If the unsigned word degree operand is greater than 31, a reserved operand fault occurs.
5.On a reserved operand fault:
If PSL = 0, the reserved operand is either the degree operand (greater than 31), or the argument operand, or some coefficient.
If PSL = 1, the reserved operand is a coefficient, and R3 (except for POLYH) or R5 (for POLYH) is pointing at the value that caused the exception.
The state of the saved condition codes and the other registers is UNPREDICTABLE. If the reserved operand is changed and the contents of the condition codes and
all registers are preserved, the fault can be continued.
6.On floating underflow after the rounding operation at any iteration of the computation loop, a fault occurs if FU is set. If FU is clear, the temporary result (tmp3) is replaced by
zero and the operation continues. In this case, the final result may be nonzero if underflow occurred before the last iteration.
7.On floating overflow after the rounding operation at any iteration of the computation loop, the instruction terminates with a fault.
8.If the argument is zero and one of the coefficients in the table is the reserved operand, whether a reserved operand fault occurs is UNPREDICTABLE.
9.For POLYH, some implementations may not save arg on the stack until after an interrupt or fault occurs. However, arg will always be on the stack if an interrupt or floating
fault occurs after FPD is set. If the four longwords on the stack overlap any of the source operands, the results are UNPREDICTABLE.
Example
; To compute P(x) = C0 + C1*x + C2*x**2
; where C0 = 1.0, C1 = .5, and C2 = .25
POLYF X,#2,PTABLE
.
.
.
PTABLE: .FLOAT 0.25 ; C2
.FLOAT 0.5 ; C1
.FLOAT 1.0 ; C0