avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] inline asm: how to make lds work with array elements?


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] inline asm: how to make lds work with array elements?
Date: Mon, 24 Jan 2005 17:24:59 +0100 (MET)

As Lin Gu <address@hidden> wrote:

>So how shall I specify the address of an element in an array in
>inline asm?

You have to pass it as an argument (actually an output argument in
your case), using the proper constraint declaration for a memory
object.

Alternatively, you can calculate the respective offset as part of the
assembler code:

asm volatile("sts cReg + 27, r27"::);

Be careful, the pointer address calculation in assembler always works
in terms of bytes, while it works in terms of sizeof(cReg[0]) when
done in C.  So if sizeof(cReg[0]) != 1 in your case, you need to
multiply the 27.  Thus it's probably better to use the method
described first, as the compiler would still apply C pointer/array
arithmetics to your expression before passing it down to the
assembler.
-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]