0
votes

If the Y pointer stores the address of the byte in memory it points to, how is the value stored at the location accessed?

.dseg ; Define a data segment
Cap_string: .byte 5 

main:
ldi yl, low(Cap_string)
ldi yh, high(Cap_string)
1

1 Answers

2
votes

The instruction to read from the location that a pointer is pointing to is called "Load Indirect" and looks like this:

ld r5, Y

In the example above, r5 can probably be any register, and Y is the name of the pointer, and can be replaced with X, Y, or Z.

To write to the location, use the "Store Indirect" instruction, which is written like this:

st r5, Y

You can find more information in the AVR Instruction Set Manual.