Download Microelectronics : Systems and Devices

Transcript
204
Microelectronics – Systems and Devices
Lookup tables
Sometimes a value that is required may be calculated from another
value by using a formula. For example, to convert a Fahrenheit
temperature into a Celsius temperature we can use a formula. If it is
needed several times in a program, it can be defined as a function:
DEF FN FtoC = (f - 32)*5/9
Other pairs of values may not be related in a mathematical way. For
example, the groups of Morse Code are not directly related to the
letters and numerals they represent. As another example, the voltage
produced by a circuit using a thermistor is not directly related to the
temperature.
In such cases as these we use a lookup table. If you are using
assembler, this is a table in ROM, or it could be downloaded into
RAM. When using a high-level language the data is stored in an array.
In assembler, the table has a starting address incorporated in the
program and we can access any particular value by offsetting the
starting address by a given amount. For example, a table of the number
of days in a month would be:
Month RAM
Value
1
0100
31
2
0101
28
3
0102
31
4
0103
30
5
0104
31
6
0105
30
7
0106
31
8
0107
31
9
0108
30
10
0109
31
11
010A
30
12
010B
31