I was looking at the addressing modes for the MOS 6502 instruction set from the here.
The description of indirect, Y-indexed is a bit inconsistent with other sources.
It says
OPC ($LL),Y operand is effective address incremented by Y with carry; effective address is word at zeropage address
But other sources don't mention about the addition with carry bit. Like here.
What is the right way of calculating the effective address?
When in doubt it's better to look at the official documentation.
There is a fascinating original datasheet from MOS here also [1] that reads
So there the second addition is performed with carrying.
You can see this as a 16-bit addition between the 16-bit word pointed by
Immediate(in little-endian) and the contents of theYregister zero extended to 16 bits.For example, if the memory and
Yarethen
(0), Yisgiving an effective address of
0310. Similarly(3), Yisthat results in an effective address of value
0390.You can see that when considered as 16-bit quantities the word at 0 is
0280andYis0090, their addition is0310as expected.The long description just encodes these facts: a) the 16-bit word pointed by
Indirectis stored in little-endian b)Yis zero-extended c) the addition is a 16-bit one.In C, it should look like this