Typewriter User Manual

5- 34 MC68340 USER’S MANUAL MOTOROLA
The following value has been calculated for independent variable X:
31 16 15 0
NOT USED 0000000010111101
Since X is an 8-bit value, the upper four bits are used as a table offset and the lower four
bits are used as an interpolation fraction. The following results are obtained from the
subroutine:
Table Entry Offset Dx [4:7] = $B = 11
Interpolation Fraction Dx [0:3] = $D = 13
Thus, Y is calculated as follows:
Y = 80 + (13 (64 – 80)) / 16 = 67
If the 8-bit value for X were used directly by the table instruction, interpolation would be
incorrectly performed between entries 0 and 1. Data must be shifted to the left four places
before use:
LSL.W #4, Dx
The new range for X is 0 X 4096; however, since a left shift fills the least significant
digits of the word with zeros, the interpolation fraction can only have one of 16 values.
After the shift operation, Dx contains the following value:
31 16 15 0
NOT USED 000010111 1 010000
Execution of the table instruction using the new value in Dx yields:
Table Entry Offset Dx [8:15] = $0B = 11
Interpolation Fraction Dx [0:7] = $D0 = 208
Thus, Y is calculated as follows:
Y = 80 + (208 (64 – 80)) / 256 = 67
5.3.4.4 TABLE EXAMPLE 4: MAINTAINING PRECISION. In this example, three TBL
operations are performed and the results are summed. The calculation is done once with
the result of each TBL rounded before addition and once with only the final result rounded.
Assume that the result of the three interpolations are as follows (a ".'' indicates the binary
radix point).
TBL # 1
0010 0000 . 0111 0000
TBL# 2
0011 1111 . 0111 0000
TBL # 3
0000 0001 . 0111 0000
Frees
cale Semiconductor,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...