Mats wrote:
You are right that there are some problems with signed arithmetics in BCD. But if signed arithmetics with N and V flags at all shall be possible $80 has to signify -20 as $20 + $ 80 =$00. Like with binary signed arithmetics $20 signifies -224 because $E0 + $20 =$00.
A correct rule for setting the V flag could be worked out from this. But this is not how the 6502 sets the V flag as we now that for example $90 + $90 = $80 with the V flag set. But this is not an overflow situation but simply -10 + -10 = -20.
I would submit that BCD really isn't a signed representation anyway. The whole idea of BCD is that the digits are contained in the hexadecimal value. In the signed BCD method you suggest, where $80 represents -20, the upper digit of $80 is 8, not 2, though of course the 2 can be easily calculated. I would say signed BCD is analogous to floating point. You can write routines for any implemenation you choose, but it is not directly supported on a 6502.
Anyway, ADC and SBC affect the V flag, even in decimal mode, and I was trying to accurately describe what that effect was in decimal mode, even though (a) it's complicated (b) it doesn't make much sense, and (c) it doesn't seem to be useful.
Mats wrote:
Quote:
For ADC in decimal mode, the lower digits are added as though they were BCD, but the upper digits are added as though they are binary, which is why this is such a mess.
Why do you say this?
What I meant was that this was true for the sole purpose of deterimining what the V flag will actually be. I wasn't referring to the resulting accumulator value or carry flag. I should have have stated this more clearly.