Changes

Jump to: navigation, search

Talk:Programming:Integer Multiplication

517 bytes added, 09:51, 7 May 2007
The add hl,hl can also be removed if the tables are split with low-byte in one page and high-byte in the other and changing the &42 to &84. Since there are 512 entries in the anti-log table, you'd need two INC L's.
 
:So the more optimal way would look like this:
 
<pre>
FastMult:
ld l,c
ld h,logtab/256
ld a,(hl) ; a = 32 * log_2(c)
ld l,b
add (hl) ; cf,a = 32 * log_2(c) + 32 * log_2(b)
ld l,a
ld a,h
adc 1
ld h,a
ld e,(hl)
inc h
inc h
ld d,(hl) ; de = 2^((hl)/32)
ret
</pre>
 
The two low and highbyte antilogtabs have to follow directly after the logtab. -- [[User:Prodatron|Prodatron]] 11:51, 7 May 2007 (CEST)