Can anyone tell me why the Z register instruction does not load correctly with an address in Program space? It seems that the Tiny10 Reference and the AVR 8-bit programming set have documentation errors. If I follow their simple usage, I load Zreg this way:
LD ZH,High(Data*2) LD ZL,Low(Data*2) LD Rd,Z
This does not work because ZH is not pointed to the code segment upon assembly and resulting Hex code loads it with 00.
This is also impossible to work with in the simulator.
After reading that code segmant starts ar 0x40, and looking at the assembler stats, my code for my larger project ends at 0x0140, so I load ZH with 0x41. The following example works at 0x40 because it is small, but I found this after much searching and trial and error.
.INCLUDE "tn10def.inc" .cseg main: ldi r16,0 ;index provided in r16 loop: ldi ZH,0x40 ;This is start of Code in Tiny10 ldi ZL, low (Data*2) ; init Z-pointer to storage bytes add ZL,R16 ld r17,Z ; Pull value directly inc r16 ;vary the index for example rjmp loop .dw 0xEEEE Data: .db 0,1, 2, 3, 4, 5, 6, 7, 8
So where can the novice find correct forms of these (and probably other) obscure assembly language programming methods?