I im learning avr assembler and would like to ask how can i read specific value from array? Here is my code that works very well and it stores digit array into SRAM...now how for example i could read value 6 from digit array?
.include "m328pdef.inc"
.DSEG
digit: .Byte 9 ; Segment Digit
.CSEG
.ORG 0x0000
rjmp _Reset
_Reset:
ldi yl,byte1(RAMEND)
out SPL,yl
ldi yh,byte2(RAMEND)
out SPL+1,yh
sbiw yl,32
; Digit Store To SRAM
ldi XH, HIGH(digit)
ldi XL, Low(digit)
ldi R16, 0x3F ; Digit 0
st X+, R16
ldi R16, 0x06 ; Digit 1
st X+, R16
ldi R16, 0x5B ; Digit 2
st X+, R16
ldi R16, 0x4F ; Digit 3
st X+, R16
ldi R16, 0x66 ; Digit 4
st X+, R16
ldi R16, 0x6D ; Digit 5
st X+, R16
ldi R16, 0x7D ; Digit 6
st X+, R16
ldi R16, 0x07 ; Digit 7
st X+, R16
ldi R16, 0x7F ; Digit 8
st X+, R16
ldi R16, 0x6F ; Digit 9
st X+, R16
; Digit Read From SRAM
ldi XH, HIGH(digit) ; load X = address of digit array
ldi XL, Low(digit) ; ...high Byte also
add XH, R24 ; add the array index
Adc XL, R25 ; ...And add 0 To propagate the carry
ld R26, X
rjmp _Reset
So in this example in simulator i need to get for read value 6 in my digit array it should get me value: 0x7D, if i would like to read value 9 in array i need to get 0x6F.
I success write array to SRAM and reading is only first index (0x3F) so how can i specifiy what index in array to read?
Thanks