Classic Computer Magazine Archive COMPUTE! ISSUE 11 / APRIL 1981 / PAGE 124

Odds and Ends

Charles A. McCarthy
St. Paul MN

Microsoft Basic for the PET, and probably for other 6502 machines, treats multiplication z =x*y asymmetrically. The execution time depends upon the binary representation of the factor y, and not on x. This can be inferred from studying the coding of the multiplication routine, and is proved by experiment. On my PET, the execution time for one multiplication z = x*y is about 3840 + 30 A + 230 B microseconds where A is the number of non-zero bits in y and B is the number of non-zero bytes in y.

As a practical consequence, if you know that one of your factors must have only one or two non­zero bytes, it should be placed as y. When x = 3 and y = π, the execution time is about the same as when x = π and y = π , and is about 20% longer than when x = π and y = 3.