I am trying to make simple assembly program for Atmega 128 which send first 5 bytes from array to PORTA.
It works fine when all these bytes are located in same part of the program memory e.g.
.org 0x7000 ARRAY: .db 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
.org 0x8000 ARRAY: .db 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
but when array is located in both parts of memory e.g.
.org 0x7fff ARRAY: .db 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
then my program sends correctly only bytes located in first 32KB of memory.
I tried to use RAMPZ register and all other things I found on the internet but nothing works, so I thought that someone here will know how to do it.
.include "m128def.inc" ldi R20, 0xFF out DDRA, R20 .DEF counter=R16 .DEF value=R17 ldi counter, 0x00 ldi zl,low(2*ROMTAB) ldi zh,high(2*ROMTAB) ldi R20, byte3(2*ROMTAB) out rampz, R20 Loop: elpm value, Z out PORTA, value inc counter cpi counter, 0x05 breq End ADIW ZL,1 rjmp Loop End: .org 0x7fff ARRAY: .db 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF .EXIT