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

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

Re: [avr-gcc-list] Basic inline asm question


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Basic inline asm question
Date: Wed, 23 Nov 2005 16:08:08 +0100 (MET)

cavanus <address@hidden> wrote:

>         void function()
>         {
>                 register uint16_t addr  __asm__ ("r30");
>                 register uint8_t  addrl __asm__ ("r30");
>                 register uint8_t  addrh __asm__ ("r31");

That does not make sense at all (IMHO).  Variables bound to registers
need to be used on global level.  Also, r30/r31 are not available for
that purpose.

> How to generate in function() this assembly lines (loading address
> of global structure [t] in [rZ]) using avr-gcc inline asm?

> ldi     r30, lo8(&t)
> ldi     r31, hi8(&t)
> __asm__ __volatile__("ldi %0, %1" : "=r" (addrl) : "M" (???));
> __asm__ __volatile__("ldi %0, %1" : "=r" (addrh) : "M" (???));

Better explain your overall goal than trying to get the compiler into
generating exact the assembly code you want.  If you want to program
in assembly language, don't use a compiler.  If you want a compiler,
don't try forcing it to become an 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]