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

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

Re: [avr-gcc-list] In line assembly


From: Erik Christiansen
Subject: Re: [avr-gcc-list] In line assembly
Date: Wed, 7 Jul 2004 14:50:47 +1000
User-agent: Mutt/1.3.28i

On Wed, Jul 07, 2004 at 03:46:14AM -0000, Dinesh Kumar wrote:
> I need to use C and assembly together. 

   Have you considered linking the AVR assembler code with your C
program? The avr-gcc function call conventions are documented in the
avr-libc user manual, available at
http://savannah.nongnu.org/download/avr-libc/. In the case of the
powerpc, gcc respects the stadardised ABI. For the avr, avr-gcc and the
IAR compiler have incompatible ABIs, so you can't link a mix of object
files from the two. (This is normally not a problem, though.)

   Looking at some avr-gcc output confirms a char* function parameter
being passed in r24 & r25, while a char is returned in r24.

   So long as the assembler functions take few parameters, you shouldn't
experience avr-gcc throwing the extra ones on the stack, thereby making
your life a little harder.

> I would like to > know how I can put in line assembly in GCC. Looks like
'pragma' is not working. 

That's probably documented in the gcc manual. Seems to be useful if you
just have do something unusual on-the-fly in the middle of a C function.

I've always managed to write separate assembler functions (or
fall-through code linked into one of the init[0-9] sections), so the
assembler can neatly reside in separate files. The other advantage is
that the assembler code remains readable in this case.

HTH,
Erik


reply via email to

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