Code: Select all
08 PHP
68 PLA
28 PLP
9A TXS
BA TSX
10-stack
FailedAdding to my confusion - these five instructions are REALLY simple. If these fundamental instructions were broken, how could my emulator do so well on the other CPU tests?
Moderator: Moderators
Code: Select all
08 PHP
68 PLA
28 PLP
9A TXS
BA TSX
10-stack
FailedCode: Select all
inline void CPU::PushStack(uint8_t value)
{
Write(value, STACK + Registers.sp);
--Registers.sp;
}
inline uint8_t CPU::PopStack()
{
++Registers.sp;
return Read(STACK + Registers.sp);
}Code: Select all
// dummy read of top of stack
Read(STACK + Registers.sp);
Registers.p.raw = (PopStack() | 0x20) & 0xEF; // bit 5 is always 1, b is set back to 0Code: Select all
Registers.x = Registers.sp;
Registers.p.n = (Registers.x >= 0x80);
Registers.p.z = (Registers.x == 0);Code: Select all
Registers.sp = Registers.x;Code: Select all
PushStack(Registers.p.raw | 0x10); // PHP pushes the flags with b set to 1