Re: I need more info about the 6502 CPU instruction set.
I'll see if I can find it.koitsu wrote:Strongly urge you to read "Programming the 65816 (including the 6502, 65C02, and 65802)". It is 65816-focused (e.g. 16-bit CPU used in SNES and Apple IIGS), but it goes over 8-bit 6502 (NES etc.) and 65C02 (Apple IIE etc.) as well. Your questions like about ADC/SBC and signed numbers are covered in very great detail (several pages, with examples), as well as general nuances. There is a reason a CPU manufacturer boughts right to this book. You just have to learn how to "ignore" the 65816/16-bit-specific stuff. It's still a good manual for 6502 despite that.timl132 wrote:Thanks. I will take a look, but I think I have enough for now.
Also, with regards to ADC/SBC, because you're writing an emulator: these two opcodes are still the top struggle point for emulator authors. Please see here for almost two decades of details. Edit: you're already posting about emulation problems with these opcodes and how overflow fits into the picture. Please see what I linked here. Take the 30+ minutes to read the threads/links, you will find code as well.
Thanks for the link, will read it. I guess ADC and SBC are so hard because of how they are handled in programming languages?
Also, not sure if it will work, but I just got the idea of casting the numbers to 16 bit signed, then doing the addition, and then checking if it is higher than 255 or below 0, then set the carry bit accordingly.(then taking the last 8 bits and creating a uint8_t from it) Can anyone give input on if that would work?