Changes

Jump to: navigation, search

Programming:Integer Multiplication

175 bytes added, 10:18, 18 October 2015
additional info
== Very fast 8bit * 8bit Unsigned with only 1K of tables ==
 
'''Input''': B = Multiplier, C = Multiplicant
 
'''Output''': DE = Product
 
'''Clocks''': 104-112 (108 on average)
 
'''Size''': 24 bytes of code and 1024 bytes for the tables
Here's a new routine I've developed which uses the formula ab = ((a + b)<sup>2</sup> - (a - b)<sup>2</sup>) / 4. It's based on a routine for the 6502 by Stephen Judd in a C= Hacking article. Because of differences between the way the 6502 does register indexing it was quite difficult to actually get this working, but it's a great compromise between speed and space since it only uses 1K of tables (as opposed to the 16K or 8K table routines above), and can still manage to do the job in a maximum of 28 microseconds.
</pre>
This code could easily be converted to a macro as it's only 24 bytes. I've tried to optimise optimize it further but with no luck!
[[User:Executioner|Executioner]] 06:25, 4 April 2008 (CEST)
22
edits