mre / mos6502

MOS 6502 emulator written in Rust
BSD 3-Clause "New" or "Revised" License
77 stars 15 forks source link

Fix addition and subtraction #72

Closed omarandlorraine closed 1 year ago

omarandlorraine commented 1 year ago

solid65 is throwing up some errors with add and subtract, so I've started this to fix it up a bit.

(Locally, I have a solid65 which is rigged to only do add and subtract, and does not exercise decimal mode. When I'm satisfied that this emulator agrees with the rubbermallet one, I'll mark this pull request as ready.)

omarandlorraine commented 1 year ago

There was one bug to do with carry propagation, possibly introduced by me 😱

Turns out that most of the "bugs" thrown up by solid65 here were because of decimal mode involving invalid inputs. Most emulators get this wrong, and in different ways. If this is something we want to do correctly, we need to first establish what "correct" means!

mre commented 1 year ago

What's the status on this? Looks good to me, but I'm not sure if you were in the middle of something before this can be merged.

omarandlorraine commented 1 year ago

What's the status on this?

I think we need a decision on what to do about decimal addition/subtraction on bytes that are not valid decimal. Mimic original hardware (and then, which one?)? Mimic other emulators (and then, which one?)?

mre commented 1 year ago

Ah, okay. I understand that invalid binary-coded decimal (BCD) inputs are considered undefined on real hardware and are a programming error. Is that correct? If so, I wouldn't bother to implement that and merge the fixes for the actual valid cases. So looks like we're done here? (Correct me if I'm wrong.)

omarandlorraine commented 1 year ago

So looks like we're done here?

That's fine, in that case it's ready to merge

mre commented 1 year ago

Yay, great improvement. Thanks! 🙏