Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADC wrong N & Z flags in BCD #70

Open
adumont opened this issue Jan 3, 2023 · 0 comments
Open

ADC wrong N & Z flags in BCD #70

adumont opened this issue Jan 3, 2023 · 0 comments

Comments

@adumont
Copy link

adumont commented Jan 3, 2023

I believe I've found a bug in ADC handling of N & Z flags in BCD mode:

the idea is to run this test:

; f8 38 a9 00 69 99
SED
SEC
LDA #$00
ADC #$99

So I run this piece of code:

from py65.devices.mpu65c02 import MPU as CMOS65C02

mpu = CMOS65C02()
mpu.memory = 0x10000 * [0xEA]

mpu.p |= mpu.DECIMAL
mpu.p |= mpu.CARRY
mpu.pc = 0x0000

mpu.a = 0
mpu.memory[0x0000]=0x69
mpu.memory[0x0001]=0x99
mpu.step()

which result in:

        PC  AC XR YR SP NV-BDIZC
65C02: 0002 00 00 00 ff 10111001

Accumulator is correctly set to 00 but the Z and N flags seem to have incorrect values.

Running the same test in Easy6502 (https://skilldrick.github.io/easy6502/), and Visual6502 (http://www.visual6502.org/JSSim/expert.html) return:

NV-BDIZC  A=$00 X=$00 Y=$00
00111011

so here N is not set (expected), and Z is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant