3

I was looking through some source for a 6502 cross-assembler and noticed that the extensions for the 45GS02/65CE02 (C65) have an oddity - while most of the new registers are set through the acc using TAZ/TZA etc., the stack base page register is set using Y, TYS/TSY.

I poked about, but I can't see a specific reason for this mentioned anywhere. My suspicion is that it was intended to allow the easy construction of large stacks by placing the base page in Y and then INY when needed. But it's also entirely possible that it was just easier to wire up internally.

Anyone have a documented answer on this?

1 Answer 1

3

Anyone have a documented answer on this?

No, but a good hint might be noting that already handled the (lower) stack pointer thru X, TXS/TSX. This was to allow stack pointer relative addressing by using ABS,X with ABS being $100 +/- the offset needed.

By keeping that scheme but using Y added flexibility by not cluttering X.

7
  • The TSX/TXS instructions of the 6502 long predated any stack-indexed addressing mode, unless the 6502 had one in early designs that was replaced by ZP,X mode. I would think later processors would have used X as a transfer register for other things for consistency.
    – supercat
    May 22 at 14:41
  • My guess is that the use of Y instead of X would have been motivated by a desire to allow a chunk of code to accept or return a 16-bit stack pointer in a pair of registers, though I'm curious how the amount of effort to special-case things like that compares with the amount of effort that would have been required to have all such instructions, including SP transfers, be capable of operating on either the X register or accumulator.
    – supercat
    May 22 at 16:10
  • @supercat Mind to read? The 6502 has an ABS,X mode right from the start, so accessing data on stack is done by TSX followed by OP $100,X, or any higher base value for bytes above TOS.
    – Raffzahn
    May 22 at 16:28
  • 1
    Minor thing: $101,X would be TOS (or better, INX then OP $100,X to handle a full stack).
    – WimC
    May 22 at 18:30
  • 1
    Ahh Raff, I had not noticed the stack-offset addressing. I suspect that is indeed the reason. That way you could move through large stacks by INCing X and Y. May 26 at 18:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .