2 comments on “Thoughts on C Programming for the 6502

  1. Does 6502 provide stack-indexed addressing (specify constant offset from SP), or are you restricted to pushes and pops? I’ve been wrestling with 68hc11 which only provides the latter directly, the former has to be simulated by copying SP into 16-bit (slow) Y index register, which is a major hit and nuisance.

    • Not directly – you have to copy the stack pointer to the X register to do anything with it. For example, you could load the byte at SP+3 with:
      TSX
      LDA $0103, X
      which takes 6 clock cycles.

Leave a comment