Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: This assembly oughta be something silly...

2005-06-15 by Alex De Lara

--- In AVR-Chat@yahoogroups.com, Dave VanHorn <dvanhorn@d...> wrote:
> >     ldi     ZH,high(Test_str)  ; Load Z register high
> >     ldi     ZL,low(Test_str)   ; Load Z register low
> 
> As a couple of others have pointed out, you need to mult 
> the string address by two. This is because Z is a BYTE pointer, 
> pointing to data that is stored as WORDS.

Ok, I see that.
 
> Also, be aware, the data is stored as words by the
> asembler/compiler, so if you store 
> "ABC" you'll end up with $41,$42,$43,$00

That's exactly what I expect if I store strings. (yeah, that
0x00 at the end is fine.)

So, I am looking at the code right now. 
Just opened the "Memory" window so I could browse all 
"spaces" (data, program, eeprom, registers, etc)
My string is actually in the code space, which is fine since 
right now I just need it to be in someplace.

What I see is that the instruction
    ld    r16,Z+
is not retrieving the byte stored there.

The address of the begining of the string is physically 
0x0016 but when the instruction is executed, some other 
value comes back to the register (0xFF or 0x00 whenever 
I use .dseg or leave it out)

So the question becomes: is there anything else to be set
so I can tell the Z register to grab the byte located
in the [code segment]:0x0020 ?

It seems it is not reading from the code segment, i.e. the
place where the string is right now.

Thanks the help.

-Alex

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.