TSX

From NES Hacker Wiki
Jump to: navigation, search
Transfer Stack Pointer to X Index
Opcode: TSX
Operation: S → X
Status Register: Status-List.png
Status-Change.pngStatus-Space.pngStatus-Change.pngStatus-Space.pngStatus-Ignore.pngStatus-Space.pngStatus-Ignore.pngStatus-Space.pngStatus-Ignore.pngStatus-Space.pngStatus-Ignore.png

TSX (Transfer Stack Pointer to X Index) transfers the value in the stack pointer to the X index. The reverse of this opcode is TXS.

Operation

This pseudo C code shows how the TSX opcode functions when it is executed.

unsigned src = S;             // Load the value of the stack pointer as an unsigned byte.
SET_NEGATIVE(src);            // Sets the Negative Flag equal to the 7th bit.
SET_ZERO(src);                // Sets the Zero Flag if the Operand is $#00, otherwise clears it.
X = (src);                    // Stores the value of the stack pointer into the X index.

Addressing Modes

Addressing Mode Assembly Language Form Opcode # Bytes # Cycles
Implied TSX BA 1 2

Examples