Re: [stella] 65xx Questions

Subject: Re: [stella] 65xx Questions
From: Chris Wilkson <ecwilkso@xxxxxxx>
Date: Mon, 8 Jul 2002 12:53:03 -0400 (EDT)
On Mon, 8 Jul 2002, Paul Slocum wrote:

> 1) What is the difference between overflow and carry?

For addition, the carry bit is set when the result is to large to fit
in a byte.  For subtration, the carry (borrow) bit is set when you
try to subract a number from a smaller number.

The overflow bit works the same way, but for signed integers.
I.E. the largest value you can have is 127, and the smallest you can
have is -128.

Try running a couple of tests with ADC and SBC to see how the differences
work.  The overflow flag is also set by the BIT instruction, and the stack
operators too.

> 2) What are some common situations where EOR is useful?

If you want to flip a bit without knowledge of it's current value,
you can EOR it with 1.  EOR is also used to test for equality.
For example:

; testing if value is $45

        EOR #45     ; unlike BIT, this changes the accumulator value
        BNE Not_45
Is_45   ......
Not_45  ......

Exclusive OR is also used in most LFSR (pseudo-random number generator)


Archives (includes files) at
Unsub & more at

Current Thread