/*--------------------------------------------------------------------------- polyeval.asm: N-Order Polynomial Evaluation of two values ----------------------------------------------------------------------------- Description: Evaluates the N-order polynomial N ___ i f(x) = \ c * x ( contains N+1 terms ) /__ i i=0 which can be factored as f(x) = ( ( ... ( ( c * x + c ) * x + c ) * x ... + c N N-1 N-2 0 To evaluate a single value requires two instructions in the inner loop, since the multiply-add operations cannot be pipelined for this algorithm. Because of the ADSP-21020's multifunction instructions, two values can be evaluated simultaneously in the inner loop in just two instructions. ----------------------------------------------------------------------------- Program Characteristics: Calling Values: REGISTER FILE: f0 = input datum #1 f1 = input datum #2 r2 = N-2 = polynomial order minus two DAG1 (Data Memory): i0 = index to coefficients ( ordered c --> c ) l0 = N+1 N 0 m0 = +0 m1 = +1 Computation Time = 2N+9 cycles FOR TWO EVALUATIONS = N+4.5 cycles per evaluation = 380ns per 5th order evaluation @ 25MHz = 2.6 million 5th order evaluations/sec @ 25MHz ----------------------------------------------------------------------------- Note: For order < 3, use straight-line code (no loops) ----------------------------------------------------------------------------- Author: Jim Donahue, Analog Devices DSP Division Revised: 14-AUG-91 ----------------------------------------------------------------------------*/ .GLOBAL polyeval; #define N_M2 r2 #define CN f12 #define X1 f0 #define SUM1 f4 #define PROD1 f8 #define X2 f1 #define SUM2 f5 #define PROD2 f9 .SEGMENT /pm pm_code; polyeval: SUM1 = dm(i0,m0); SUM2 = SUM1; PROD1 = X1 * SUM1, CN = dm(i0,m0); PROD2 = X2 * SUM2, SUM1 = PROD1 + CN; lcntr = N_M2, do plp until lce; PROD1 = X1 * SUM1, SUM2 = PROD2 + CN, CN = dm(i0,m0); plp: PROD2 = X2 * SUM2, SUM1 = PROD1 + CN; PROD1 = X1 * SUM1, SUM2 = PROD2 + CN, CN = dm(i0,m0); rts(db); PROD2 = X2 * SUM2, f0 = PROD1 + CN; f1 = PROD2 + CN; .ENDSEG;