A86: Lookup tables


[Prev][Next][Index][Thread]

A86: Lookup tables




At 22:47 1998-06-02 EDT, you wrote:
>Wouldn't fetching the answer in itself involve multiplication?  I'm
>having trouble thinknig of how to explain this, but how would you be able
>to know where to look in the table without multiplication?

No. It's not that easy though, if you decide to skip half of
the lookup table:

    0  1  2  3  4  5  6  7  8  9
 ---------------------------------
0   0  0  0  0  0  0  0  0  0  0
1      1  2  3  4  5  6  7  8  9
2         4  6  8 10 12 14 16 18
3            9 12 15 18 21 24 27

etc. But you could of course not store it as a 256x256 matrix,
since then you would still need 128k memory. You would need
an extra lookup table to get the offset to the multiplication
lookup table:

Mul0:
 .dw 0,0,0,0,0,0,  ;  256 words
Mul1:
 .dw 1,2,3,4,5,6,  ;  255 words
Mul2:
 .dw 4,6,8,10,12,  ;  254 words
Mul3:
 .dw 9,12,15,18,21 ;  253 words

OffsetTable:
 .dw Mul0,Mul1,Mul2,Mul3,...
   

A*B = (OffsetTable[A])[B-A]  if a<=b

--
Real name: Jimmy Mårdell                "can't go mucking with a 'void *'"
IRC......: Yarin                                // Apple's MPW C compiler
Email....: mailto:yarin@acc.umu.se        
Homepage.: http://www.acc.umu.se/~yarin/   <-- NEW HOMEPAGE!!


Follow-Ups: References: