TransWikia.com

Does the 6502's TXS and TSX affect flags or not?

Retrocomputing Asked on November 12, 2021

Title says it all really. Some documentation claims that the S and Z flags are affected by both TXS and TSX, just as with all other transfer commands. Other documentation suggests that neither TXS nor TSX affect the flags.

But this emulator, fake6502 affects the flags with TSX and not with TXS. As fake6502 was made for a NES emulator, could this change be specific to the Ricoh variants? If it’s just a bug, then it is worth noting that there is At least one other emulator that behaves this way. I found the source code of perfect6502 too obtuse to read and understand.

I can see how this could be missed in the emulators because I imagine very little code will depend on this. Probably just code that initialises various registers and will overwrite the status flags anyway. Also, I can see how this mistake could be missed in the documentation, the Transfer instructions are all very similar.

I’d be interested if there’s any variation in this matter between the various incarnations of the 6502 also.

One Answer

Does the 6502's TXS and TSX affect flags or not?

  • TSX does affect N and Z
  • TXS does not affect any flag

In general all instructions moving data to one of the Registers (A, X, Y) do set N and Z according to the data moved.

Excerpt of the instruction list from the 1976 data sheet on page 6:

enter image description here

Answered by Raffzahn on November 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP