Re: [cc65] Multiplication

From: Karri Kaksonen <>
Date: 2009-11-02 17:25:39
Ullrich von Bassewitz wrote:
> For some reasons related to TGI and other stuff, I need to redo multiplication
> and - in a second step - divisions. So here's a question:
> Are there some platforms with multiplication or division in hardware, and if
> so, what does it do?
> Regards
>         Uz

The Lynx has a few (16bit * 16bit += 32bit) and (32bit / 16bit = 32bit) 
functions in hardware.

0xAABB * 0xCCDD = 0xEEFFGGHH (accumulate in 0xJJKKLLMM)


The signed multiply has a bug. 0x8000 is a positive number while 0x0000 
is a negative number.
There is also a remainder function that is too buggy to be usable. In 
theory 0xJJKKLLMM contains the remainder after a division.

The math cannot be used while Suzy is drawing sprites. So you have to 
poll a bit to find out if the hardware is busy or not.

If you start a 16 by 16 multiply and immediately write to register EE 
starting a divide we get something defined as:
"As a compromise between the square root and qube root desires of the 
software people, and the schedule desires of the management, we have 
decided to incorporate the function of QbertRoot. "

I have yet to find out if it can be used for anything...

Math Timing
Multiplies with out sign or accumulate take 44 ticks to complete.
Multiplies with sign and accumulate take 54 ticks to complete.

Divides take 176 + 14*N ticks where N is the number of most significant 
zeros in the divisor.

To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Nov 2 17:26:38 2009

This archive was generated by hypermail 2.1.8 : 2009-11-02 17:26:40 CET