Michael J. Mahon <mjmahon@aol.com> wrote:
David Empson wrote:
The 6502's carry flag is "backwards" for a subtract: CLC, SBC will
subtract one more, while SEC, SBC will not. This also affects the logic
of compare-and-branch sequences: BCC is "branch if less than" (unsigned)
on a 6502, but it is "branch if greater than or equal" on other
processors.
I see it as *more* consistent, in that Carry = NOT Borrow.
In the hardware, it means that SBC need only 1's complement its operand
and add, since the carry being set will add 1 for the 2's complement.
I wasn't suggesting that it was illogical, it is just different from
what someone might be used to on another processor.
It simplifies the 6502's ALU, since it only needs to implement a single
add operation with alternative inputs.