Re: How do coders handle 16-bit numbers?



On 18 Mar 2006 19:25:14 -0800, "David Murray" <adric22@xxxxxxxxx>
wrote:

What I need to do is add and subtract, multiply,
and divide 16-bit numbers.

Take a look at the online copy of the July 1987 Transactor ... V8 N01
( in particular, the article "High-speed Multiplies and Divides -- ML
Math Routines Explained"

Go to Craig Bruce's ( www.csbruce.com/~csbruce ) Go to his CBM link
then Transactor archive.

Note that there are specific routines that can be performed for
constant-multpliers.

Multiplies by two are easily done by shift-left operations.

To multiply by 10:
Assume you have to work variables A and B and you want to multiply
A by 10.
Copy A to B
Shift A left 3 bits ( A = A * 2 * 2 * 2 ) or ( A = A * 8 )
Shift B left 1 bit ( B = B * 2 )
Add B to A

....etc.

Smaller multiplies for constant multipliers might be better done by
successive addition ( inlined, without a loop )

Jim Lawless

.