Stack Pointer, 8-bit offset

Stack Pointer, 8-bit offset instructions behave the same way than Indexed 8-bit offset instructions, except that the offset is added to the Stack Pointer SP in place of the HX Index register.

This addressing mode allow easy access of the data on the stack. If the interrupts are disabled, the Stack pointer can also be used as a second Index register. See the following listing for an example of using the Stack Pointer *8-bit offset) addressing mode.

Listing: Stack Pointer (8-bit offset) addressing mode

entry:
       LDHX  #$0500   ; init Stack Pointer to 04FF

       TXS

       LDA   #$40

       STA   $50, SP   ; Location $54F = $40

In this example, stack pointer, 8-bit offset mode is used to store the value $40 in memory location $54F.