Yahoo Groups archive

AVR-Chat

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

Message

Re: problems

2008-03-23 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "steamphreaque" <tjkeller@...> 
wrote:
>I have a problem:
You have two problems.  Firstly, the Z "register" is actually two 8-
bit registers and you have to load them separately.  Secondly, to 
read indirectly through the Z register, you need to use either ld or 
ldd.  (The lds instruction is for loading from an absolute address.)

ldi r30, lo8(LABEL)
ldi r31, hi8(LABEL)
ld r22, Z+

I have used a macro to simplify loading the Z register:

// macro to load a data address into r31:30
.macro	ldiZ	_data
  ldi  r30, lo8(\_data)
  ldi  r31, hi8(\_data)
.endm

Then, you can use it thusly:

ldiZ LABEL
ld r22, Z+

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

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.