liveBook · Manning

Txs instruction

As explained in Classic Game Programming on the NES: Make your own retro video game

The TXS instruction transfers the value in the 6502 X register to the stack pointer.

TXS transfers the value in the 6502 X register to the stack pointer. During NES startup, load X with $FF, then execute TXS to establish the stack's starting offset. section 5.12

Set the NES stack pointer

After clearing decimal mode, initialize the stack with: cld ldx #$FF txs The stack starts at the location specified by the transferred value. Each pushed item decreases the stack pointer offset by 1. section 5.12

How Classic Game Programming on the NES: Make your own retro video game covers it

How deep it goes
Explains the register transfer and stack-offset decrement, without detailing broader stack operations.
Examples
Uses the startup sequence CLD, LDX #$FF, and TXS to establish the stack.
What you can do after
Operate/configure NES startup by setting the stack pointer from the X register.
How it connects
Connects the X register, stack pointer, 6502 processor, and stack operations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Game Programming on the NES: Make your own retro video game. The section links point to the parts of the book it draws on.