mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-17 15:07:10 +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:
parent
8a285aace8
commit
3439ec51a8
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user