Invalid carry flag after DAA
KarolS opened this issue · 2 comments
Steps to reproduce:
Assemble and run the following code:
LDA #$91
ADD #$91
DAA
What happened?
Carry was reset.
When similar code was used for multi-byte decimal addition, it yielded incorrect results.
What was expected?
Carry should be set. DAA keeps the carry flag set if it was set beforehand, see the mc6809 emulator sources for comparison: https://github.com/spc476/mc6809/blob/master/mc6809.c#L420 or the official Programming Manual: https://archive.org/details/bitsavers_motorola68_13419254/page/n83/mode/2up
C – Set if a carry is generated or if the carry bit was set before the operation; cleared otherwise.
After some research, I noticed that this is a common bug in many 6809 emulators.
Fix implemented and unit test added. (testDAA2)
Thanks for implementing it, I could finally test my multibyte decimal subtraction code and make it correct.