A86: Re: Re: Re: Re: Re: Z80 & new game preview
[Prev][Next][Index][Thread]
A86: Re: Re: Re: Re: Re: Z80 & new game preview
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?
Follow-Ups:
References: