I use the (zp),Y addressing mode all the time. I have a bunch of records, each a fixed length up to 256 bytes long. To select one of the records, I multiply its index number by the record length, add the address of the beginning of the list, store this address in two consecutive bytes in zero page such as &80+&81, load zero into the Y register and then step along the list using LDA(&80) and INY. Within the fixed-length record, there can be a pointer to, and the length of, another, variable-length record; which is just one of many, squashed into one contiguous list with all the other VLRs. (In BCP, a footprint record has a 23-byte fixed length part, and two variable-length parts: the co-ordinates of the vertices of the silkscreen outline; and the co-ordinates, pad styles and hole sizes of the connection pins.)
So much for that. But the 6502 has another indexed indirect addressing mode (zp,X) where X is added to the zero page address given to get the address of the pointer.
If I have a bunch of pointers in &70+&71, &72+&73, &74+&75 and so forth, I can select the contents of the address pointed to by any one of them with LDA(&70,X) where X=0, 2, 4 ...
But what next? If that's the beginning of a list, then the only way to step through the list is by altering the value in &70,X and &71,X. You can INCrease your way through the list, a byte at a time (there is even a "short" INC zp,X instruction that might have been made for this); but you can't so easily DECrease back down it, because there's no equivalent of the Z flag but that gets set when the ALU output is &FF as opposed to &00.
Also, each of the pointed-to lists -- if it's to be handled in a generic fashion that works irrespective of the value of X, using zp.X instructions to manipulate the pointer in situ -- has to contain records with the same data structure (or randomly-mixed data structures, with the handling code able to detect what each record is and deal with it accordingly).
But I don't really see how using (zp,X) to select your base address and then updating it every time is preferrable to something like
Code: Select all
LDA ptrs,X STA &8E LDA ptrs+1,X STA &8F LDY #0 .read_list LDA (&8F),Y \ ... INY CPY #rlen BMI read_list
Code: Select all
LDY &70 \ &70 does what X did before LDA (&8C),Y STA &8E INY LDA (&8C),Y STA &8F \ now &8E+&8F is base of (&70)th list INY STY &70 LDY #0 .read_list LDA (&8E),Y