Hi,
I'm running Klaus' excellent functional test against my emulator.
At test 2Ah (42) something goes wrong:
Code:
32f4[f8], 2a, a: 2a, x: 0e, y: ff, flags: 71, sp: 01ff, BS: 00 SED
32f5[a2], 2a, a: 2a, x: 0e, y: ff, flags: 79, sp: 01ff, BS: 00 LDX #$0e
32f7[a0], 2a, a: 2a, x: 0e, y: ff, flags: 79, sp: 01ff, BS: 00 LDY #$ff
32f9[a9], 2a, a: 2a, x: 0e, y: ff, flags: f9, sp: 01ff, BS: 00 LDA #$99
32fb[85], 2a, a: 99, x: 0e, y: ff, flags: f9, sp: 01ff, BS: 00 STA $0d
32fd[85], 2a, a: 99, x: 0e, y: ff, flags: f9, sp: 01ff, BS: 00 STA $0e
32ff[8d], 2a, a: 99, x: 0e, y: ff, flags: f9, sp: 01ff, BS: 00 STA $0203
3302[85], 2a, a: 99, x: 0e, y: ff, flags: f9, sp: 01ff, BS: 00 STA $0f
3304[a9], 2a, a: 99, x: 0e, y: ff, flags: f9, sp: 01ff, BS: 00 LDA #$01
3306[85], 2a, a: 01, x: 0e, y: ff, flags: 79, sp: 01ff, BS: 00 STA $0c
3308[85], 2a, a: 01, x: 0e, y: ff, flags: 79, sp: 01ff, BS: 00 STA $10
330a[a9], 2a, a: 01, x: 0e, y: ff, flags: 79, sp: 01ff, BS: 00 LDA #$00
330c[85], 2a, a: 00, x: 0e, y: ff, flags: 7b, sp: 01ff, BS: 00 STA $12
330e[8d], 2a, a: 00, x: 0e, y: ff, flags: 7b, sp: 01ff, BS: 00 STA $0204
3311[38], 2a, a: 00, x: 0e, y: ff, flags: 7b, sp: 01ff, BS: 00 SEC
3312[20], 2a, a: 00, x: 0e, y: ff, flags: 7b, sp: 01ff, BS: 00 JSR $339f
339f[08], 2a, a: 00, x: 0e, y: ff, flags: 7b, sp: 01fd, BS: 00 PHP push status
33a0[a5], 2a, a: 00, x: 0e, y: ff, flags: 7b, sp: 01fc, BS: 00 LDA $0d
33a2[65], 2a, a: 99, x: 0e, y: ff, flags: f9, sp: 01fc, BS: 00 ADC $0e [99]
33a4[08], 2a, a: 99, x: 0e, y: ff, flags: b9, sp: 01fc, BS: 00 PHP push status
33a5[c5], 2a, a: 99, x: 0e, y: ff, flags: b9, sp: 01fb, BS: 00 CMP $0f [99 versus 99]
33a7[d0], 2a, a: 99, x: 0e, y: ff, flags: 3b, sp: 01fb, BS: 00 BNE $33a7
33a9[68], 2a, a: 99, x: 0e, y: ff, flags: 3b, sp: 01fb, BS: 00 PLA pull a
33aa[29], 2a, a: b9, x: 0e, y: ff, flags: b9, sp: 01fc, BS: 00 AND #$01
33ac[c5], 2a, a: 01, x: 0e, y: ff, flags: 39, sp: 01fc, BS: 00 CMP $10 [01 versus 01]
33ae[d0], 2a, a: 01, x: 0e, y: ff, flags: 3b, sp: 01fc, BS: 00 BNE $33ae
33b0[28], 2a, a: 01, x: 0e, y: ff, flags: 3b, sp: 01fc, BS: 00 PLP pull status
33b1[08], 2a, a: 01, x: 0e, y: ff, flags: 7b, sp: 01fd, BS: 00 PHP push status
33b2[a5], 2a, a: 01, x: 0e, y: ff, flags: 7b, sp: 01fc, BS: 00 LDA $0d
33b4[e5], 2a, a: 99, x: 0e, y: ff, flags: f9, sp: 01fc, BS: 00 SBC $12 [99 -= 00]
33b6[08], 2a, a: 98, x: 0e, y: ff, flags: b8, sp: 01fc, BS: 00 PHP
33b7[c5], 2a, a: 98, x: 0e, y: ff, flags: b8, sp: 01fb, BS: 00 CMP $0f [98 versus 99]
33b9[d0], 2a, a: 98, x: 0e, y: ff, flags: b8, sp: 01fb, BS: 00 BNE $33b9
LOOP AT 33b9
at address 33b4 00h is substracted from a which is 99h at that time. The flag-register is F9h so decimal and carry are set.
My emulator calculates 98h of this, the test expects 99h though. I don't understand this.
Is it that maybe SBC does not do the subtraction if the value is 0, even though carry is set? Or something else?