Jnelson said:
Ok, Amatuer question.
Could someone explain the operation of a lookup table, for say a SLC. I assume that it involves
pre-mapped constants stored in a integer location, but I cant seem to grasp the rest.
Thanks in advance
You're correct so far (the TABLE part). The LOOKUP part comes from the input value.
To LOOKUP a value in the table (it doesn't necessarily have to be a constant),
the input value is used as an 'index' into the table. You have a
table of ten values and some operator input, say, 1-10, which tells
the program which numbered value you want.
First, subtract a value of one from the input given so the
instruction will access the 0th through 9th elements of your table.
You may at this point want to do some validation of the input value
to prevent processor faults. In any case, the conditioned input value
is now applied as an indirect or indexed address to get the lookup value.
As Peter Nachtwey states, it's fast, and, the execution time
is the same no matter what value is being used.
N7:0 = 34
N7:1 = 27
N7:2 = 401
N7:3 = 93
N7:4 = 66
N7:5 = 5280
N7:6 = 119
etc.
one_shot SUB
-----] [---------+------------------+
| A: INPUT |
| B: 1 (CONST) |
| DEST: WORK WORD |
+------------------+
INDIRECT EXAMPLE
WORK WORD becomes a variable address component which 'points' to a
designated address. In contrast, N7:1 points to an address also,
you just can't change it on the fly. IF WORK WORD holds a '2', the
value returned will be '401'.
MOV
-----------------+------------------+
| N7:[WORK WORD] |
| OUTPUT_WORD_1 |
+------------------+
INDEXED EXAMPLE
MOV
-----------------+------------------+
| WORK WORD |
| S:24 (IX REG) |
+------------------+
CROSSHATCH '#' DENOTES INDEXED ADDRESSING
Here, the value in the index register is added to N7:0.
If IX=3 the instruction's effective address will be N7:3
and the value '93' will be returned.
MOV
-----------------+------------------+
| #N7:0 |
| OUTPUT_WORD_2 |
+------------------+
INDEXED INDIRECT
Some A-B processors allow this additional addressing mode.
If IX=3 and WORK WORD=2 the instruction's effective address
will be N7:5 and the value '5280' will be returned.
MOV
-----------------+------------------+
| #N7:[WORK WORD] |
| OUTPUT_WORD_2 |
+------------------+
For what it's worth, most any file structure can be used. You could
just as easily look up canned text messages in a string file using
indirect addresssing like so: ST9:[WORK WORD].