User Tools

Site Tools


base:fastest_multiplication

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
base:fastest_multiplication [2017-04-19 09:47] reposebase:fastest_multiplication [2017-04-19 10:28] repose
Line 15: Line 15:
 ;and being less elegant and harder to follow. ;and being less elegant and harder to follow.
 ;by Repose 2017 ;by Repose 2017
 +;table generator by Graham
 +;addition improvement suggested by JackAsser
 +
 +;data: 2044 bytes
 +;zero page ram required: minimum 8 bytes, ideally 14
 +;do_add: 30 bytes in zp, if used
 +;time: 196 cycles, option for 192 if you use 30 more zp bytes for do_add
 +;measurement method: branches/page boundary crossings were averaged
 +
 +;How to use:
 +;put numbers in x/y and result is Y reg, X reg, z1, z0
  
 ;tables of squares ;tables of squares
Line 35: Line 46:
 y0=$fd;multiplicand, 2 bytes y0=$fd;multiplicand, 2 bytes
 y1=$fe y1=$fe
-z0=$80;product, bytes+z0=$80;product, bytes
 z1=$81 z1=$81
-z2=$82 +;z2=$82 returned in X reg 
-z3=$83+;z3=$83 returned in Y reg
  
 ;Example showing use ;Example showing use
Line 154: Line 165:
 sbc (p_invsqr_hi),y sbc (p_invsqr_hi),y
 tay;x1*y1h;Y=z3, 30 cycles tay;x1*y1h;Y=z3, 30 cycles
-;17+33+31+17+31+30=159+;17+33+31+17+31+30=159 cycles for main multiply part
  
 +;jmp do_adds; can put do_adds in zp for a slight speed increase
 do_adds: do_adds:
 ;-add the first two numbers of column 1 ;-add the first two numbers of column 1
Line 188: Line 200:
  
 Diagram of the additions Diagram of the additions
-                  y1  y0 +                y1    y0 
-               x  x1  x0 +             x  x1    x0 
-               ---------+                --------
              x0y0h x0y0l              x0y0h x0y0l
 +      x0y1h x0y1l +      x0y1h x0y1l
base/fastest_multiplication.txt · Last modified: 2024-02-13 08:24 by repose