Implement? Block Move Instructions

This commit is contained in:
2025-07-23 21:51:14 -04:00
parent 8706874c4d
commit 2111163f78
2 changed files with 60 additions and 0 deletions

View File

@@ -453,6 +453,11 @@ void CPU::ExecuteInstruction() {
case 0xE8: INX(); break; // INX - Increment X Register case 0xE8: INX(); break; // INX - Increment X Register
case 0xC8: INY(); break; // INY - Increment Y Register case 0xC8: INY(); break; // INY - Increment Y Register
// Move Block Instructions
// There is zero way this is done right. I don't understand at all.
case 0x54: MVN(); break; // MVN srcbank,destbank
case 0x44: MVP(); break; // MVP srcbank,destbank
// No Operation // No Operation
case 0xEA: NOP(); break; //NOP case 0xEA: NOP(); break; //NOP
@@ -3775,3 +3780,55 @@ void CPU::ORA_StackRelativeIndirectY() {
cycles += 8; cycles += 8;
} }
} }
void CPU::MVN() {
const uint8_t dest_bank = ReadByte(PC++);
const uint8_t src_bank = ReadByte(PC++);
const uint32_t src_address = (src_bank << 16) | X;
const uint32_t dest_address = (dest_bank << 16) | Y;
const uint8_t data = ReadByte(src_address);
WriteByte(dest_address, data);
X++;
Y++;
A--;
if (A != 0xFFFF) {
// Make sure that operation has successfully completed
// If not, stay on this instruction
PC -= 3;
}
DB = dest_bank;
cycles += 7;
}
void CPU::MVP() {
uint8_t dest_bank = ReadByte(PC++);
uint8_t src_bank = ReadByte(PC++);
const uint32_t src_address = (src_bank << 16) | X;
const uint32_t dest_address = (dest_bank << 16) | Y;
const uint8_t data = ReadByte(src_address);
WriteByte(dest_address, data);
X--;
Y--;
A--;
if (A != 0xFFFF) {
// Make sure that operation has successfully completed
// If not, stay on this instruction
PC -= 3;
}
DB = dest_bank;
cycles += 7;
}

View File

@@ -306,6 +306,9 @@ public:
void ORA_AbsoluteLongX(); void ORA_AbsoluteLongX();
void ORA_StackRelative(); void ORA_StackRelative();
void ORA_StackRelativeIndirectY(); void ORA_StackRelativeIndirectY();
void MVN();
void MVP();
}; };
#endif //CPU_H #endif //CPU_H