Hi,
I read that in when in decimal mode the Zero Flag is invalid. What does this mean? In other words, does it mean that the Zero Flag is not updated?
Thanks,
Andrew
ADC Instruction and BCD
Re: ADC Instruction and BCD
andrewem wrote:
I read that in when in decimal mode the Zero Flag is invalid. What does this mean? In other words, does it mean that the Zero Flag is not updated?
Code: Select all
SED
CLC
LDA #$99
ADC #$01
On the other hand, after:
Code: Select all
SED
SEC
LDA #$01
SBC #$01
The Z flag is only invalid on the 6502. On the 65C02 and the 65816, the Z flag correctly reflect the accumulator contents.
On the 6502, if you want to predict the value of the Z flag after an ADC or SBC, just add or subtract the numbers (accounting for the carry) as though they were binary number rather than BCD numbers. In other words, after:
Code: Select all
SED
ADC NUMBER
Code: Select all
CLD
ADC NUMBER