Motorola HC12 Refrence Manual page 327

Table of Contents

Advertisement

The TBL instruction uses 8-bit table entries (y-values) and returns an 8-bit result. The
ETBL instruction uses 16-bit table entries (y-values) and returns a 16-bit result. A flex-
ible indexed addressing mode is used to identify the effective address of the data point
at the beginning of the line segment, and the data value for the end point of the line
segment is the next consecutive memory location (byte for TBL and word for ETBL).
In both cases, the B accumulator represents the ratio of (the x-distance from the be-
ginning of the line segment to the lookup point) to (the x-distance from the beginning
of the line segment to the end of the line segment). B is treated as an 8-bit binary frac-
tion with radix point left of the MSB, so each line segment can effectively be divided
into 256 pieces. During execution of the TBL or ETBL instruction, the difference be-
tween the end point y-value and the beginning point y-value (a signed byte-TBL or
word-ETBL) is multiplied by the B accumulator to get an intermediate delta-y term. The
result is the y-value of the beginning point, plus this signed intermediate delta-y value.
Because indexed addressing mode is used to identify the starting point of the line seg-
ment of interest, there is a great deal of flexibility in constructing tables. A common
method is to break the x-axis range into 256 equal width segments and store the y val-
ue for each of the resulting 257 endpoints. The 16-bit D accumulator is then used as
the x input to the table. The upper eight bits (A) is used as a coarse lookup to find the
line segment of interest, and the lower eight bits (B) is used to interpolate within this
line segment.
In the program sequence...
LDX
LDD
TBL
The notation A,X causes the TBL instruction to use the A
The low-order half of D (B) is used by TBL to calculate the exact data value from this
line segment. This type of table uses only 257 entries to approximate a table with 16
bits of resolution. This type of table has the disadvantage of equal width line segments,
which means just as many points are needed to describe a flat portion of the desired
function as are needed for the most active portions.
Another type of table stores x:y coordinate pairs for the endpoints of each linear seg-
ment. This type of table may reduce the table storage space compared to the previous
fixed-width segments because flat areas of the functions can be specified with a single
pair of endpoints. This type of table is a little harder to use with the CPU12 TBL and
ETBL instructions because the table instructions expect y-values for segment end-
points to be in consecutive memory locations.
Consider a table made up of an arbitrary number of x:y coordinate pairs, where all val-
ues are eight bits. The table is entered with the x-coordinate of the desired point to
lookup in the A accumulator. When the table is exited, the corresponding y-value is in
the A accumulator.
CPU12
REFERENCE MANUAL
#TBL_START
DATA_IN
A,X
Figure 9-12
shows one way to work with this type of table.
FUZZY LOGIC SUPPORT
th
line segment in the table.
MOTOROLA
9-27

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cpu12

Table of Contents