Re: [stella] optimization : sneaky fractional bit representation

Subject: Re: [stella] optimization : sneaky fractional bit representation
From: "Andrew Davie" <adavie@xxxxxxxxxxxxxxxxx>
Date: Thu, 4 Jun 1998 08:32:23 +1000
>That was definitely interesting, and could be implemented on the 2600 for a
>password game.  Problem is the lack of memory and the multiplications...
>the 2600 would have a heck of a time multiplying a 40-bit stream by, say,
>11.


Oh, yea of little faith

Multiplying by 11 is the same as multiplying by 12 and subtracting the
original.
That's 2 shifts ( = x4 ) + another shift ( = *8) - the original.  Or, to be
really back-to-basics, what is wrong with a loop which adds the number 11
times?  The assumption in the code following is that the result will not
exceed 40 bits, and that "original..." holds the original number.  Result is
left in "temp..."

    lda #0
    sta temp
    sta temp+1
    sta temp+2
    sta temp+3
    sta temp+4

    ldy #10
loopx11

    clc
    lda original
    adc temp
    sta temp
    lda original+1
    adc temp+1
    sta temp+1
    lda original+2
    adc temp+2
    sta temp+2
    lda original+3
    adc temp+3
    sta temp+3
    lda original+4
    adc temp+4
    sta temp+4

    dey
    bpl loopx11

There we go, that wasn't too hard.  Slow?  Well, slowish... but speed isn't
the issue when we're encoding/decoding a password.  Too many cycles in one
whack?  Do one of the loops every frame.  Think laterally... instead of
making the 40 bits in one monolithic block, break it down and generate the
40 bit stream 5 bits at a time.  Sure, a bit more complex to generate... but
you really aren't limited to doing it the way my walkthrough suggested.

Its about time we started talking about efficient multiply and divide
routines - which are certainly possible.  This is about the third time
someone has balked at the word "multiply" or "divide".  Would anybody care
to post some multiply / divide code?

Cheers
A


--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/stella.html

Current Thread