Add PHX, PHY, PHB, PHD, PHK and PLX, PLY, PLB, PLD

This commit is contained in:
scawful
2023-08-19 16:18:45 -04:00
parent 76f40531f1
commit 8d0f4110e0
4 changed files with 200 additions and 104 deletions

View File

@@ -636,55 +636,55 @@ void CPU::ExecuteInstruction(uint8_t opcode) {
break;
case 0x48: // PHA Push Accumulator
// PHA();
PHA();
break;
case 0x8B: // PHB Push Data Bank Register
// PHB();
PHB();
break;
case 0x0B: // PHD Push Direct Page Register
// PHD();
PHD();
break;
case 0x4B: // PHK Push Program Bank Register
// PHK();
PHK();
break;
case 0x08: // PHP Push Processor Status Register
// PHP();
PHP();
break;
case 0xDA: // PHX Push X register
// PHX();
PHX();
break;
case 0x5A: // PHY Push Y register
// PHY();
PHY();
break;
case 0x68: // PLA Pull Accumulator
// PLA();
PLA();
break;
case 0xAB: // PLB Pull Data Bank Register
// PLB();
PLB();
break;
case 0x2B: // PLD Pull Direct Page Register
// PLD();
PLD();
break;
case 0x28: // PLP Pull Processor Status Register
// PLP();
PLP();
break;
case 0xFA: // PLX Pull X register
// PLX();
PLX();
break;
case 0x7A: // PLY Pull Y register
// PLY();
PLY();
break;
case 0xC2: // REP Reset status bits

View File

@@ -400,18 +400,61 @@ class CPU : public Memory {
void CLV() { status &= ~0x40; }
// Push Accumulator on Stack
void PHA() { memory.PushByte(A); }
// Pull Accumulator from Stack
void PLA() {
A = memory.PopByte();
SetNegativeFlag((A & 0x80) != 0);
SetZeroFlag(A == 0);
}
// Push Processor Status Register on Stack
void PHP() { memory.PushByte(status); }
// Pull Processor Status Register from Stack
void PLP() { status = memory.PopByte(); }
void PHX() { memory.PushByte(X); }
void PLX() {
X = memory.PopByte();
SetNegativeFlag((A & 0x80) != 0);
SetZeroFlag(X == 0);
}
void PHY() { memory.PushByte(Y); }
void PLY() {
Y = memory.PopByte();
SetNegativeFlag((A & 0x80) != 0);
SetZeroFlag(Y == 0);
}
// Push Data Bank Register on Stack
void PHB() { memory.PushByte(DB); }
// Pull Data Bank Register from Stack
void PLB() {
DB = memory.PopByte();
SetNegativeFlag((DB & 0x80) != 0);
SetZeroFlag(DB == 0);
}
// Push Program Bank Register on Stack
void PHD() { memory.PushWord(D); }
// Pull Direct Page Register from Stack
void PLD() {
D = memory.PopWord();
SetNegativeFlag((D & 0x8000) != 0);
SetZeroFlag(D == 0);
}
// Push Program Bank Register on Stack
void PHK() { memory.PushByte(PB); }
void SEI() { status |= 0x04; }
void SED() { status |= 0x08; }