> I'm working on writing a simple 6502 emulator
It sounds like you mean a simulator. An emulator is something you can actually plug into your board to act like the normal processor, but it has ribbon cables to interface to the PC to let you see what's going on inside the processor.
> using instructions like ADC, SBC, INC, DEC, and others like them, > if you do an operation that ends up setting the target byte to 0, > but also sets the carry flag (like doing ADC with 255 + 1), do you > set the zero flag or not?
Yes. There's effectively an implied compare-to-zero included at no charge, which means the N flag is also set if bit 7 is set, and cleared otherwise.
> with undefined opcodes (one of the 104 non-standard opcodes), do > you think it's best to try and emulate the strange reaction the CPU > has to them, or to stop the CPU with an error?
A few people have been taking advantage of the odd behavior of the unofficial op codes. Personally, I find them interesting but hardly useful; and if you use them, you can't plug in a CMOS 6502 (which has more op codes) and expect it to work right. The CMOS 6502 treats its 46 unused op codes as no-ops.
> does anyone know where I can find out how instructions respond to > decimal (BCD) mode? I've found some examples for ADC and SBC
CMP is also affected by the decimal flag. The decimal adjust is done automatically on the fly, so a second "decimal adjust" instruction is not needed, unlike on other processors. The flags are not always valid after these operations on the NMOS 6502 in decimal mode. This bug was fixed in the CMOS versions. Note also that on the NMOS 6502, the D flag state will be unknown following a reset, and will not be cleared upon interrupt.
> I'm wondering if there are any others that are affected, such as > INC or DEC.
INC, DEC, INX, DEX, INY, and DEY are always in hex, not decimal.
Since the CMOS 6502 (65c02) will not be discontinued anytime in the forseeable future and has so many advantages over the NMOS 6502, I would encourage you to make your simulator able to handle it.
Garth
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
|