Вопрос

I'm very new to assembly language and what I need to do is find the value at a given position in a lookup table. So for example, given the table:

table: .db 1,2,3,4,5,6,7,8,9,10

How would I get the 3rd element of this table and load it into a register, say r16?

Thanks guys!

Это было полезно?

Решение

Load the base address of the table into register X, add the appropriate offset, then use LD to fetch the entry from data memory. If your table is in program memory, use register Z and the LPM instruction.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top