Typewriter User Manual

5- 32 MC68340 USER’S MANUAL MOTOROLA
Table 5-14. Compressed Table Entries
Entry Number X Value Y Value
2 512 1311
3 786 1966
Since the table is reduced from 257 to 5 entries, independent variable X must be scaled
appropriately. In this case the scaling factor is 64, and the scaling is done by a single
instruction:
LSR.W #6,Dx
Thus, Dx now contains the following bit pattern:
31 16 15 0
NOT USED 0000001010001110
Table Entry Offset Dx [8:15] = $02 = 2
Interpolation Fraction Dx [0:7] = $8E = 142
Using this information, the table instruction calculates dependent variable Y:
Y = 1331 + (142 (1966 – 1311)) / 256 = 1674
The function chosen for Examples 1 and 2 is linear between data points. If another
function had been been used, interpolated values might not have been identical.
5.3.4.3 TABLE EXAMPLE 3: 8-BIT INDEPENDENT VARIABLE. This example shows
how to use a table instruction within an interpolation subroutine. Independent variable X is
calculated as an 8-bit value, allowing 16 levels of interpolation on a 17-entry table. X is
passed to the subroutine, which returns an 8-bit result. The subroutine uses the data listed
in Table 5-15, based on the function shown in Figure 5-9.
Frees
cale Semiconductor,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...