Motorola DSP96002 User Manual

Page 563

Advertising
background image

B-44

DSP96002 USER’S MANUAL

MOTOROLA

B.1.24

Table Lookup with Linear Interpolation Between Points

This performs a table lookup and linear interpolation between points in the table. It is assumed that the

spacing between the known values (breakpoints) is a constant. No range checking is performed on the

input number because it is assumed that previous calculations may have limiting and range checking. This

can be used to approximate arbitrary functions given a set of known points (such as digital sine wave gen-

eration) or to interpolate linearly between values of a set of data such as an image.

The function to be approximated is shown below:

o ¨ known values of function

o o

Y(i) o

o

----+------+------+------+------+

X(i)

1.0 6.0 11.0 16.0 21.0 ¨ indexes

^ / spacing between indexes is INDSPC, 5.0

in this example

FIRSTINDEX - value of the first index in the table, 1.0

in this example

Given an input value "x", the linearly interpolated value "y" from the tabulated known values is:

Y(i+1)-Y(i)

y = --------------(x-X(i)) + Y(i)

X(i+1)-X(i)

Program

ICycles

Words

;

; Approximate d4=exp(d0) for 1.0 <= x <= 21.0

;

page 132,60,1,1

org x:0

table dc 2.7182818e+00 ;exp(1.0)

dc 4.0342879e+02 ;exp(6.0)

dc 5.9874141e+04 ;exp(11.0)

dc 8.8861105e+06 ;exp(16.0)

dc 1.3188157e+09 ;exp(21.0)

org p:$50

firstindex equ 1.0 ;value of first table index

Advertising