Please see the file utilities/kobb.s for an actual implementation of
this algorithm.
SLJ 6/11/97
-------
Well, my idea is pretty simple. Numbers are read in left to right, and
each time a number is read in, the total is multiplied by ten and the
digit is added in:
total=0
digit=0
:loop total= total*10
total= total + digit
read digit (and convert from ASCII to integer)
if not EOF then goto :loop
There are two ways to multiply by ten. The first way is to use a general
multiplication method. The second is to realize that 10 = 8+2, thus
x*10 = x*8 + x*2 = x*2*(1+4), so with a few shifts, a temporary location, and
an addition, multiplying by ten can be done very quickly.
Example: read in the number 1653
total=0
digit=0
1st read: digit=1
total= total*10 => total=0
total= total+digit => total=1
2nd read: digit=6
total= total*10 => total=10
total= total+digit => total=16
3rd read: digit=5
total= total*10 => total=160
total= total+digit => total=165
4th read: digit=3
total= total*10 => total=1650
total= total+digit => total=1653
Voila!
SLJ 10/96