GARTHWILSON wrote:
I'm not sure what you're saying here.
Well, when talking about arrays yes, the "index" is usually thought of as the offset (in elements, not machine words!) into an array. Note that even in this case on the 6502, the X is not necessarily holding an index as described above: for arrays of 2-byte values X will hold twice the index.
But when talking about index
registers these are mostly thought of as registers that can hold a "complete" address pointing to anywhere in the address space (or current segment, on machines with segmented addressing). X and Y clearly cannot do that.
As I mentioned, the 6800 has the same "16 bit pointer plus 8 bit offset" system that the 6502 does, with the difference that the register and memory relationships are reversed: when you
LDAA 3,X the 16-bit augend comes from the index register
X instead of memory, and the 8-bit addend (called an "offset")
3 comes from memory (the byte immediately after the
LDA opcode).
Quote:
Non-ZP addresses can be indexed too; it's just that they don't have the benefit of being able to combine it with indirection for data access.
Sure, but consider that if you're going to talk about X as holding the "index," (which already has the "X is an offset in bytes, which is not the array index when the elements are something other than bytes" problem I described above), you're now running into indices being duplicated when your array is longer than 256 bytes. If you want to read an array of 512 bytes and send each value to an output port, and you're using the X register, you're going to be using the "index" 3 twice, referring to two different elements in that array.