New questions that came up, this time while coding first versions of PHP and PLP:
In emulated mode, can PLP (and REP and SEP) change the b-flag and the "unused flag" (bit 5) ? The handbook seems to say "yes" for PLP (p. 385) and "no" for REP and SEP. Note however that for PLP, we have a dash in the schematic, but an "all flags are replaced" in the text. That's not good, especially if we switch to native mode right after these instructions for some reason.
Then, if the b-flag is clear in emulation mode and we push P to the stack, and then switch into native mode and then pull P again, will this set X and Y to 16 bits (since both use bit 4 of P)? I'm guessing it should, which would make it another source of ugly errors, so I wanted to make sure.
Finally, if we set the m-flag in native mode, and then go emulated, will the "unused flag" (bit 5) be set afterward? The same question occurs with the x- and b-flags. The manual on page 61 simply says:
Quote:
The m bit (bit five) returns to its emulation role as the break flag; the x bit (bit four) becomes once again an unused flag.
Ignoring the typo for the moment (
m turns to unused,
x turns to b), we have no word on if they keep their values or are set to zero.
I realize these pretty much all deserve a "dude, who cares" as an answer, because sane people will avoid these situations. Would be grateful for any suggestions (again), because the emulator still has to deal with them.
(Also, I'm getting somewhat fed up with emulation mode, which seems to cause most of the problems. If there is one thing I'm taking away from all of this, it is to get to native mode ASAP and to stay there.)