Indirect-Indexed Mode – (Indirect) + Y

Syntax

instruction (base_pointer), Y

Description

In the indirect-indexed addressing mode, the effective address is calculated by fetching a 16-bit address from the zero-page location specified by the base_pointer. The Y register is then added to this 16-bit address to obtain the actual target address.

The instruction operates on the memory location pointed to by this target address.

Example

Here’s an example using the LDA instruction in indirect-indexed addressing mode:

LDA ($20),Y

Assume that the Y register contains $04, and the memory locations $20 through $21 has the following contents:

$20: $30
$21: $40

The instruction will perform the following steps:

  1. Fetch the low byte of the target address from $20 ($30).

  2. Fetch the high byte of the target address from $21 ($40).

  3. Combine the high and low bytes to form the target address: $4030.

  4. Add the Y register ($04) to the target address, resulting in the address $4034.

  5. Load the value at memory location $4034 into the accumulator.

Timing

When the sum of the 16-bit address fetched from the zero-page location and the Y register results in a carry from the low byte to the high byte, an additional clock cycle is required to properly handle the carry. Be aware of this limitation when working with indirect-indexed addressing mode.

Use Cases

Indirect-indexed addressing mode is useful for accessing elements in an array or a data structure using an index. It is also commonly used for implementing loops and for addressing data structures in high-level languages.

Comments