Re: [stella] Euchre back with odd behavior

Subject: Re: [stella] Euchre back with odd behavior
From: "Erik J. Eid" <eeid@xxxxxxxxx>
Date: Sat, 16 Jun 2001 10:56:55 -0400
At 05:47 PM 6/16/01 +1000, Andrew Davie helped me out:
Clear the carry flag before doing your addition :)
ie:

    clc                                    ; this one is necessary
    lda Dealer
    adc #1
    and #3
    sta Turn
    clc                                    ; this one might be optional
    adc #MsgNumSouth

Many thanks, Andrew! (It turns out the second one is indeed optional.)


That's what I get for ignoring the advice of the book I used to learn ML (_Machine Language for Beginners_ by Richard Mansfield). It says clc is necessary before any addition and sbc is needed before any subtraction.

Why is this? The reason I didn't think I needed a clc instruction in the code above is that I knew I was dealing with numbers that wouldn't cause the carry flag to change. The value of Dealer is always between zero and three, so adding one should make it between one and four. Why would a carry flag that is set cause the addition to be off?


. . \_ +\_ + o_-/ . O
. \-_o -=/- . .
. . \=// .
---------\_______ ||O ___.______
/* Erik Eid */ \____||L/\_____/
/* eeid@xxxxxxxxx */_______________________



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

Current Thread