1
0
mirror of https://github.com/pevans/erc-c.git synced 2025-02-07 03:30:28 +00:00

We also need to check ACC in ASL/LSR/ROL/ROR

And, possibly more importantly--opcode is not a bool.
This commit is contained in:
Peter Evans 2018-03-25 20:34:12 -05:00
parent 3439ec51a8
commit 81bcc7d973
2 changed files with 18 additions and 6 deletions

View File

@ -140,7 +140,7 @@ DEFINE_INST(cpy)
*/ */
DEFINE_INST(dec) DEFINE_INST(dec)
{ {
bool opcode = mos6502_get(cpu, cpu->PC); vm_8bit opcode = mos6502_get(cpu, cpu->PC);
bool is_acc = mos6502_addr_mode(opcode) == ACC; bool is_acc = mos6502_addr_mode(opcode) == ACC;
if (!is_acc) { if (!is_acc) {
@ -178,7 +178,7 @@ DEFINE_INST(dey)
*/ */
DEFINE_INST(inc) DEFINE_INST(inc)
{ {
bool opcode = mos6502_get(cpu, cpu->PC); vm_8bit opcode = mos6502_get(cpu, cpu->PC);
bool is_acc = mos6502_addr_mode(opcode) == ACC; bool is_acc = mos6502_addr_mode(opcode) == ACC;
if (!is_acc) { if (!is_acc) {

View File

@ -31,6 +31,9 @@ DEFINE_INST(and)
*/ */
DEFINE_INST(asl) DEFINE_INST(asl)
{ {
vm_8bit opcode = mos6502_get(cpu, cpu->PC);
bool is_acc = mos6502_addr_mode(opcode) == ACC;
vm_8bit result = oper << 1; vm_8bit result = oper << 1;
MOS_CHECK_NZ(result); MOS_CHECK_NZ(result);
@ -39,7 +42,7 @@ DEFINE_INST(asl)
cpu->P |= MOS_CARRY; cpu->P |= MOS_CARRY;
} }
if (cpu->eff_addr) { if (!is_acc) {
mos6502_set(cpu, cpu->eff_addr, result); mos6502_set(cpu, cpu->eff_addr, result);
} else { } else {
cpu->A = result; cpu->A = result;
@ -111,6 +114,9 @@ DEFINE_INST(eor)
*/ */
DEFINE_INST(lsr) DEFINE_INST(lsr)
{ {
vm_8bit opcode = mos6502_get(cpu, cpu->PC);
bool is_acc = mos6502_addr_mode(opcode) == ACC;
vm_8bit result = oper >> 1; vm_8bit result = oper >> 1;
// The N flag is ALWAYS cleared in LSR, because a zero is always // The N flag is ALWAYS cleared in LSR, because a zero is always
@ -126,7 +132,7 @@ DEFINE_INST(lsr)
cpu->P |= MOS_CARRY; cpu->P |= MOS_CARRY;
} }
if (cpu->eff_addr) { if (!is_acc) {
mos6502_set(cpu, cpu->eff_addr, result); mos6502_set(cpu, cpu->eff_addr, result);
} else { } else {
cpu->A = result; cpu->A = result;
@ -150,6 +156,9 @@ DEFINE_INST(ora)
*/ */
DEFINE_INST(rol) DEFINE_INST(rol)
{ {
vm_8bit opcode = mos6502_get(cpu, cpu->PC);
bool is_acc = mos6502_addr_mode(opcode) == ACC;
vm_8bit result = oper << 1; vm_8bit result = oper << 1;
// Rotations are effectively _9-bit_. So we aren't rotating bit 7 // Rotations are effectively _9-bit_. So we aren't rotating bit 7
@ -166,7 +175,7 @@ DEFINE_INST(rol)
MOS_CHECK_NZ(result); MOS_CHECK_NZ(result);
if (cpu->eff_addr) { if (!is_acc) {
mos6502_set(cpu, cpu->eff_addr, result); mos6502_set(cpu, cpu->eff_addr, result);
} else { } else {
cpu->A = result; cpu->A = result;
@ -179,6 +188,9 @@ DEFINE_INST(rol)
*/ */
DEFINE_INST(ror) DEFINE_INST(ror)
{ {
vm_8bit opcode = mos6502_get(cpu, cpu->PC);
bool is_acc = mos6502_addr_mode(opcode) == ACC;
vm_8bit result = oper >> 1; vm_8bit result = oper >> 1;
// See the code for ROL for my note on 9-bit rotation (vs. 8-bit). // See the code for ROL for my note on 9-bit rotation (vs. 8-bit).
@ -193,7 +205,7 @@ DEFINE_INST(ror)
MOS_CHECK_NZ(result); MOS_CHECK_NZ(result);
if (cpu->eff_addr) { if (!is_acc) {
mos6502_set(cpu, cpu->eff_addr, result); mos6502_set(cpu, cpu->eff_addr, result);
} else { } else {
cpu->A = result; cpu->A = result;