1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-30 06:29:48 +00:00

inc and dec should work with a zero-address

Just checking if (cpu->eff_addr) is not sufficient. We need to check the
address mode; only increment or decrement the A register if the mode is
literally ACC.
This commit is contained in:
Peter Evans 2018-03-25 19:42:55 -05:00
parent 8a285aace8
commit 3439ec51a8

View File

@ -140,7 +140,10 @@ DEFINE_INST(cpy)
*/
DEFINE_INST(dec)
{
if (cpu->eff_addr) {
bool opcode = mos6502_get(cpu, cpu->PC);
bool is_acc = mos6502_addr_mode(opcode) == ACC;
if (!is_acc) {
MOS_CHECK_NZ(oper - 1);
mos6502_set(cpu, cpu->eff_addr, oper - 1);
return;
@ -175,7 +178,10 @@ DEFINE_INST(dey)
*/
DEFINE_INST(inc)
{
if (cpu->eff_addr) {
bool opcode = mos6502_get(cpu, cpu->PC);
bool is_acc = mos6502_addr_mode(opcode) == ACC;
if (!is_acc) {
MOS_CHECK_NZ(oper + 1);
mos6502_set(cpu, cpu->eff_addr, oper + 1);
return;