beautypg.com

Motorola DSP96002 User Manual

Page 564

background image

MOTOROLA

DSP96002 USER’S MANUAL

B-45

indspc equ 5.0 ;index spacing

rindspc equ 1.0/indspc ;reciprocal of index spacing

move #table,n0 ;point to start of table

move #firstindex,d6.s ;value of first index

move #rindspc,d7.s ;reciprocal of index spacing

fsub.s d6,d0 ;adjust input relative to index 1 1

fmpy.s d7,d0,d0 ;reduce range and create index 1 1

floor d0,d1 ;get index 1 1

int d1 d1.s,d2.s ;convert index to int,copy int part 1 1

fsub.s d2,d0 d1.l,r0 ;x-X(i), get ptr to table 1 1

nop ;clear address ALU pipe 1 1

move (r0)+n0 ;point to Y(i) 1 1

move x:(r0)+,d4.s ;get Y(i) 1 1

move x:(r0),d5.s ;get Y(i+1) 1 1

fsub.s d4,d5 ;Y(i+1)-Y(i) 1 1

fmpy.s d0,d5,d5 ; *(x-X(i)) 1 1

fadd.s d5,d4 ;+Y(i) 1 1

--- ---

Totals: 12 12

B.1.25

Argument Reduction

Argument reduction (AR) is the problem of having a desired floating point number range and an argument

that is outside of the range. The argument is placed inside of the desired range by adding or subtracting

multiples of the desired number range. Of course, adding and subtracting multiples of a number is inher-

ently slow and requires infinite precision. Some simple methods can be used with some assumptions on

the precision of the data and relative argument sizes.

The following program performs AR when the desired range is arbitrary and the input value is arbitrary. This

may be used to reduce an angle to the range of -pi to pi.

The following variables are defined:

rmin = range minimum value, -pi in this example

rmax = range maximum value, pi in this example

range = rmax-rmin, 2*pi in this example

o_range = 1.0/range

Assume the input is in d0.