/*--------------------------------------------------------------------------- bezier.asm: Cubic Bezier Polynomial Evaluation ----------------------------------------------------------------------------- Description: The Cubic Bezier polynomial is commonly used to represent curves and surfaces as a compact list of control points, or "knots". This routine evaluates the Cubic Bezier polynomial 3 2 2 3 x(t) = p (1-t) + 3 p t (1-t) + 3 p t (1-t) + p t 1x 2x 3x 4x after it has been factored to the form 2 3 x(t) = (t-1) [ -(t-1) p + 3t [ (t-1)p - p t ) ] ] + p t 1x 2x 3x 4x ----------------------------------------------------------------------------- Program Characteristics: Calling Values: f0 = input value (t) f1 = t - 1 f9 = P1 f5 = P2 f6 = P3 f7 = P4 f14 = 3.0 f15 = 1.0 Registers Altered: f8, f12, f13 Return Value: f0 = x(t) Computation Time = 11 cycles per bezier evaluation, straight-line code = 10 cycles per bezier evaluation, looped = 400ns per bezier evaluation @ 25MHz = 2.5 million bezier evaluations/sec @ 25MHz ----------------------------------------------------------------------------- Notes: 1. The register defines used in the code below refer to the various sections of the factored eqn. being assembled: 2 3 x(t) = (t-1) [ -(t-1) p + 3t [ (t-1)p - p t ) ] ] + p t 1x 2x 3x 4x ---B---- --A-- --E--- --------C-------- -----F----- ---------D------------ -----------------G--------------------- ---H--- -------------------I--------------------------- 2. Don't mess around with the register defines too much, the multifunction operations depend on them... ----------------------------------------------------------------------------- Author: Jim Donahue, Analog Devices DSP Division Revised: 14-AUG-91 ----------------------------------------------------------------------------*/ .GLOBAL bezier; #define T f0 /* T, the parametric value */ #define T_M1 f1 /* T - 1 */ #define P1 f9 #define P2 f5 #define P3 f6 #define P4 f7 #define TMP f4 #define A f12 #define B f8 #define C f8 #define D f8 #define E f12 #define F f12 #define G f8 #define H f13 #define I f12 #define ONE f15 /* 1.0 */ #define THREE f14 /* 3.0 */ .SEGMENT /pm pm_code; bezier: A = T * P3, TMP = T_M1; B = T_M1 * P2; E = T_M1 * TMP, C = B - A; C = THREE * C; D = T * C; F = E * P1; H = T * P4, G = D - F; H = H * T; rts (db), H = H * T; I = G * T_M1; f0 = H + I; .ENDSEG;