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 theY
register zero extended to 16 bits.For example, if the memory and
Y
arethen
(0), Y
isgiving an effective address of
0310
. Similarly(3), Y
isthat results in an effective address of value
0390
.You can see that when considered as 16-bit quantities the word at 0 is
0280
andY
is0090
, their addition is0310
as expected.The long description just encodes these facts: a) the 16-bit word pointed by
Indirect
is stored in little-endian b)Y
is zero-extended c) the addition is a 16-bit one.In C, it should look like this