Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Re: This assembly oughta be something silly...

2005-06-15 by Zack Widup

On Wed, 15 Jun 2005, Alex De Lara wrote:

> 
> 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 ?
> 

I go about it a little differently.  Here's a little subroutine I use to 
do the same thing you're doing. ZL and ZH are set up in the main program 
just before calling the subroutine.

SENDIT:
        sbi     UCSRB, TXEN     ; Enable transmit
SENDLOOP:
        lpm                     ; Load character 
        adiw    ZL, $01         ; Increment Z reg
        tst     R0              ; Test for zero
        breq    SENDDONE        ; If so, done
        out     UDR, R0         ; send ASCII character
XMITWAIT:
        sbis    UCSRA, UDRE     ; loop till character shifted out
        rjmp    XMITWAIT
        rjmp    SENDLOOP        ; get next character when done
SENDDONE:
        ret                     ; go home

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.