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

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

[Fwd: Re: [Fwd: Re: [avr-gcc-list] in-line assembler]]


From: Robert von Knobloch
Subject: [Fwd: Re: [Fwd: Re: [avr-gcc-list] in-line assembler]]
Date: Tue, 11 Aug 2009 15:44:08 +0200
User-agent: Thunderbird 1.5.0.14 (X11/20060911)

Thanks Jan,
I have reached this conclusion too, I didn't understand the
compiler/assembler interaction (and still don't fully, I can't get an
"sts var, Y" to work, but I'll work at it).
Btw. I like using silly names for variables, but only in very small demo
scripts ;-)

Robert

Robert,

I think you want this:
uint8_t get_ram_byte(uint16_t ram_address)
{
  uint8_t    byte;
  asm  ("ld %0, %a1"    "\n\t"
         : "=&r" (byte) : "e" (ram_address));
  return byte;
}

By using the "=&r" constraint you tell the compiler that it shall allocate a 
register and after the asm routine it shall use its content as the "byte" 
variable (which is, btw., a really bad idea for a name of a variable).

JW








reply via email to

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