>>I was wondering how BASIC calculates LOG(x). Does it use a look-up table
>>(would require massive amounts of memory), some sort of algorithm (would
>>require massive amounts of CPU time), or some mixed method?
I checked "the MSX red book". Usually, this explains all these matters. So
we check the index for log... page 93... okay here goes:
Address...2A72H
This routine is used by the factor evaluator to apply the "LOG" function to
a double precision operand contained in the DAC. The function is computed by
polynomial approximation using the list of coefficients at 2DA5H.
I checked this. 2DA5H contains two sequences of double-precision
coefficients, each sequence preceded by a byte that indicates the number of
coefficients in the sequence. The first sequence has four coefficients, the
second five. So that makes a data area of (1+8*4)+(1+8*5)=74 bytes.
Some routines at 2C88H and 2C9AH are used to compute odd or even series of a
polynomal, for the approximation. For input the sequences at 2DA5H are used.
>There must be using a way that requires only a little memory. There are
>many math functions present in the math pack in the ROM, for example LOG,
>EXP, SIN, COS, TAN, ATN. They can't all use large tables, there is simply
>not enough space in a 32K ROM.
So there are. Isn't the MSX red book online somewhere? Am I the only one who
has this book?? I can hardly believe that!
>They might use Taylor sequences or a technique like that. Although it's not
>fast (on a Z80), it results in compact code that needs no tables.
As stated, it uses a minimal table for some coefficients.
It is probably a good thing to use something like the routine used by basic.
Sometimes it's even smart to use the routines embedded in the BIOS - the
math routines for double precision are actually quite good.
>>I calculated I'd need about 96kB for a look-up table with reasonable
>>accuracy. Because log(256*256)=4.8164 I'd need 48164 x 2 bytes.
>
>I don't understand that calculation.
me neither.
>
>By the way, there is not just a 10log, you could use 2log or ln (e-log)
>instead.
yeah but it's wise to just do the e-log (as basic does) and compute the rest
from there.
It all depends on priorities...speed or memory?
>If you don't mind wasting memory, why not make a 256x256 table that
>contains the result of x*y? It would take 128K, but it's fast. Although
>slot switching would degrade the performance a bit.
:) I'm wondering what kind of program we are thinking about here...
>Anyway, I don't think using logs will get your multiplications any faster.
>Maybe it's a better strategy to cut down the number of multiplications you
>need to perform?
Yep. And a normal multiplication isn't even that slow. It's a small loop
that gets traversed 8 times at most...
>I think that the fastest way of multiplying a large amount of numbers on
>MSX would be to use a GFX9000. Think about that... ;)
Sure, and use moonsound ram to store the level graphics 8)
Bye,
Cas
http://www.stack.nl/~cas/par/
****
MSX Mailinglist. To unsubscribe, send an email to [EMAIL PROTECTED] and put
in the body (not subject) "unsubscribe msx [EMAIL PROTECTED]" (without the
quotes :-) Problems? contact [EMAIL PROTECTED] (www.stack.nl/~wiebe/mailinglist/)
****