Quarter Square Multiplication - analog computing and 6502 MOS

Quarter Square Multiplication:
a*b = ((a+b)² -(a-b)²) / 4
Multiplication algorithm - Wikipedia

From the book:
Instrument Engineers’ Handbook, Volume Two: Process Control and Optimization
edited by Bela G. Liptak
Instrument Engineers’ Handbook, Volume Two: Process Control and Optimization - Google Books
Quarter Square Multiplication in Analog Computing:

The Quarter square multiplier technique has also benefitted 8-bit systems that do not have any support for a hardware multiplier. Charles Putney implemented this for the 6502
Fastest 6502 Multiplication Yet
Apple Assembly Line - V6N6 - Mar 1986 (txbobsc.com)
Charles Putney:
Charles Putney - Professional Profile - CodeProject


Nice connection back to analogue computing! I notice the book you linked is a 4th edition from 2005, but I can confirm (by google book search) that the quarter-square multiplier also appears in the index of the first edition, from 1969.

A 1k lookup table is fairly large for a 6502 system, but then the resultant multiplication is gratifyingly rapid!

1 Like

By coincidence I implemented that quarter square code a few months ago - also used another old coder’s trick for generating the table of squares. I was experimenting to see if I could speed up some of the arithmetic that the 6809 version of gcc generated. (I couldn’t but got quite close for some operations). Here’s a C version of quarter square plus some other junk: mul8.c ; a more polished version of 8-bit stuff for the vectrex: vectrex-muldiv.c (and a version that ran on the Vectrex and accurately timed execution to cycle precision using the VIA timer: cycle-counting.c ) - I’m not sure how useful any of that is but you might find it fun to try some of them if you still code for any 8-bit platforms…