A stack pointer is a processor state value identifying the current top position of the processor stack. During NES startup, the 6502 initializes it by loading $FF into the X register and transferring that value to the S register with txs. The stack begins at the selected location; each value pushed onto it decreases the stack-pointer offset by 1. section 5.12
cld #1 ldx #$FF txs #2
The two-instruction setup clears decimal mode, loads $FF into X, and transfers X to the stack-pointer register. section 5.12



