Re: [stella] Very BASIC ASM Info needed...

Subject: Re: [stella] Very BASIC ASM Info needed...
From: "Andrew Davie" <adavie@xxxxxxxxxxxxx>
Date: Wed, 7 Mar 2001 22:25:16 +1100
> Can someone please find _and_ explain it to me? :-)

Well, this isn't an eor-trick.  But fairly efficient.
Depends on what's your poison... code size or speed.

    ldy FrameCounter
    lda NextFrame,y
    sta FrameCounter

NextFrame
    .byte 1,2,0


That's just about the quickest I know...   10 cycles
It also uses 10 bytes.

How about this one....

    lda FrameCounter
    cmp #2
    adc #1
    and #3
    sta FrameCounter


That's pretty cool!   If the number is < 2 (ie 0 or 1) it will clear the
carry, and just add 1.
If its >=2 (ie: 2) it will set the carry, therefore adding two - taking it
to 4
The and with 3 will then restore that to 0

Not better than the first version, though.  This one is 12 cycles and 10
bytes.

Still, fun :)


--
 _  _  _| _ _        _| _    * _                               _  ,
(_|| )(_|( (/_\/\/  (_|(_|\/(_(/_                           ,~' L_|\
                                                         ,-'        \
see my Museum of Soviet Calculators at                  (            \
http://www.taswegian.com/MOSCOW/soviet.html              \    __     /
                                                          L,~'  "\__/
                                                              @--> v

----- Original Message -----
From: "Manuel Polik" <manuel.polik@xxxxxxxxxxx>
To: <stella@xxxxxxxxxxx>
Sent: Wednesday, March 07, 2001 10:02 PM
Subject: [stella] Very BASIC ASM Info needed...


> Mornin'
>
> Supposed I want to have a counter which does 0/1/2 and then repeats.
> Straightforward everybody will come up with something like this:
>
> INC frameCounter
> LDA frameCounter
> CMP #$03
> BNE CounterOk
> LDA #$00
> STA frameCounter
>
> Now, I'm almost 100% certain, that there must be a more elegant EOR
> trick here.
>
> Can someone please find _and_ explain it to me? :-)
>
> Greetings,
> Manuel
>
> -
> Archives (includes files) at http://www.biglist.com/lists/stella/archives/
> Unsub & more at http://www.biglist.com/lists/stella/
>


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

Current Thread