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 homeMessage
Re: [AVR-Chat] Re: This assembly oughta be something silly...
2005-06-15 by Zack Widup
Attachments
- No local attachments were found for this message.