Re: A86: Re: Re: Re: Re: Re: Z80 & new game preview


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

Re: A86: Re: Re: Re: Re: Re: Z80 & new game preview




if you are multiplying, say 4 times 5, a+b=9, 9*9=81, 81/4=20 <- note the
rounging error.  a-b=1, 1*1=1, 1/4=0 <- rounding error.  20-0=20.  now
the thing is, does this rounding error always cancel, or with larger
numbers is it possible for it to affect the result?  the fact that it
cancels out when you simplify it algebraicly means nothing (or does it?)
the concern is that you're rounding in the table, and that's what you're
actually using to do the calculation.

so with the table business, it's low byte table, then high byte table,
not
;  .db 0*0/4,1*1/4,2*2/4,...,255*255/4
;  and then the msb's of those...
;  .db 256*256/4,...,511*511/4
;  and then the msb's of those.
which sounds like 4 tables?  and how does the table get loaded to d&h? 
is one the high byte of the location, or is the table aligned on a 256
byte boundary?  or is this all irrelivant in this new routine you've got?

-josh

On Sun, 28 Nov 1999 13:41:18 -0700 "Kirk Meyer" <kirkmeyer@bigfoot.com>
writes:
>
>In response to David, actually, it has to be DEC A \ CPL, right? 
>consider 0,
>that would do $00 -> $FF -> $00 which is correct, INC A doesn't work 
>unless
>you put it after the CPL.
>
>In response to Josh, here's how it works:
>((a+b)^2)/4 - ((a-b)^2)/4
>When expanindg that, you get:
>(a^2)/4 + (a*b)/2 + (b^2)/4 - (a^2)/4 + (a*b)/2 - (b^2)/4
>Which reduces to:
>(a*b)
>
>Since the parts that are divided by four cancel, we don't have to 
>worry
>about the rounding on them. The tables are kind of weird, hehe. 
>Consider the
>sequence 0*0/4, 1*1/4, 2*2/4, ..., 511*511/4. The first $200 bytes of 
>the
>table contains the LSB of those products (so LSB 0*0/4, ...) and the 
>last
>$200 bytes of the table contains the MSB of those products (so MSB 
>0*0/4,
>...). You don't need the ABS table anymore.
>
>After combining Jimmy's, mine, and URL's posted on the list, I've come 
>up
>with a pretty dang optimized version. I'll post it once I confer 
>further
>about possibilities, document it, and make a signed version.
>
>David Phillips wrote:
>> It doesn't have NEG, but INC A \ CPL will do the same thing (same 
>size and
>> time).  Very nice!
>
>rabidcow@juno.com wrote:
>> ok, i don't understand the explaination of those tables here.  
>also,
>> doesn't the divide by 4 introduce a little bit of rounding error?
>
>

___________________________________________________________________
Get the Internet just the way you want it.
Free software, free e-mail, and free Internet access for a month!
Try Juno Web: http://dl.www.juno.com/dynoget/tagj.


Follow-Ups: