Re: A86: Re: new ideas...
[Prev][Next][Index][Thread]
Re: A86: Re: new ideas...
Well, whether it's rotative or additive multiplication, is it not still
multiplication either way?
00000010 starting value =2
rla -> 00000100 (4)
rla -> 00001000 (8)
rla -> 00010000 (16)
sub 2 -> 00001110 (14)
2*7=14
True, this will only work with small numbers (before bit rotation wraps
back around to bit 0), but it still results in the desired answer. I
did not, however, intend to mean that this is a generic mult routine,
which it definitely is not, because this would only work on a small
range of numbers.
Cassady Roop
> Except that what you did just rotates the bits, so it's not *7. You need to
> use add a,a to multiply.
...
> > >;multiply n by 7
> > >ld a, 2 ;n=2
> > >ld b, a ;store value of n
> > >rla ;n*2
> > >rla ;n*4
> > >rla ;n*8
> > >sub b ;(n*8-n) or n*7
> > >;a now holds result of n times 7. n=2, so value in A is 14.
Follow-Ups:
References: